Reset a specified COM port
This function block sends a COM port reset request to a specified port number. The PLC has to be set to "program controlled" communication. Evaluate the output variables bIsDone and bIsRequested to check if the specified port is reset and can be used again.
Input
If set to TRUE, the COM port reset request is sent to the specified port number
COM0, COM1, COM2 on CPU
16#xx01–16#xx04 (xx = slot number 1–64) on SCU
Output
Set to TRUE, if the COM port is reset and can be used again.
Set to TRUE, if the COM port reset is requested.
Corresponding system variables of outputs (set only, if the COM port has been reset by bReset of the same instance)
Request to reset
COM0: sys_bIsComPort0ResetRequested
COM1: sys_bIsComPort1ResetRequested
COM2: sys_bIsComPort2ResetRequested
Reset is done
COM0: sys_bIsComPort0ResetDone
COM1: sys_bIsComPort1ResetDone
COM2: sys_bIsComPort2ResetDone
All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.
VAR
fbResetComPort: ResetComPort;
bResetComPort: BOOL:=FALSE;
iPort: INT:=0;
bComPortCannotBeUsed: BOOL:=FALSE;
END_VAR
When the variable bResetComPort is set to TRUE, the function block is carried out.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 5 ;
NETWORK_BODY
B(B_VARIN,,iPort,19,3,21,5,);
B(B_CONTACT,,bResetComPort,6,2,8,4,);
B(B_FB,ResetComPort!,fbResetComPort,21,1,30,5,,?BbReset?BPort?AbIsDone?AbIsRequested);
L(1,3,6,3);
L(8,3,21,3);
L(1,0,1,5);
END_NETWORK_BODY
END_NET_WORK
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 3 ;
NETWORK_BODY
B(B_COIL,,bComPortCannotBeUsed,39,1,41,3,S);
B(B_CONTACT,,fbResetComPort.bIsRequested,6,1,8,3,);
L(1,2,6,2);
L(8,2,39,2);
L(1,0,1,3);
END_NETWORK_BODY
END_NET_WORK
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 3 ;
NETWORK_BODY
B(B_COIL,,bComPortCannotBeUsed,39,1,41,3,E);
B(B_CONTACT,,fbResetComPort.bIsDone,6,1,8,3,);
L(1,2,6,2);
L(8,2,39,2);
L(1,0,1,3);
END_NETWORK_BODY
END_NET_WORK
END_BODY
fbResetComPort(bReset := bResetComPort,
Port := iPort);
IF (fbResetComPort.bIsRequested) then
bComPortCannotBeUsed := TRUE;
ELSIF (fbResetComPort.bIsDone) then
bComPortCannotBeUsed := FALSE;
END_IF;