切换通信模式
输入
发送缓冲区
要发送的字节数:
负值:在系统寄存器中选择的结束代码不会增加到发送字符串。
0(0字节):准备系统以接收更多数据
16#8000:切换通信模式
根据PLC的类型指定通信端口:
COM端口,例如SYS_COM0_PORT
以太网端口,例如SYS_ETHERNET_USER_CONNECTION_1
MCU/SCU,例如COM01中的16#xx01 (xx = 插槽编号)
当电源打开时,将设置在系统寄存器中选择的通信模式。
在RUN模式期间,无法更改为Modbus RTU模式或PLC Link模式。
所有用于编程此函数的输入和输出变量已在POU头中声明。 所有编程语言使用相同的POU头。
VAR
bSwitchToMewtocolSlave: BOOL:=FALSE;
wDummy: WORD:=0;
bSwitchToProgramControlled: BOOL:=FALSE;
END_VAR
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 9 ;
NETWORK_BODY
B(B_COMMENT,,Changing COM 1 from program controlled to MEWTOCOL-COM Slave mode.ø^The corresponding transmission mode flag R9032 (sys_bIsComPort1ProgramControlled) is setø^when program controlled mode is selected.,1,0,39,3,);
B(B_VARIN,,wDummy,26,5,28,7,);
B(B_VARIN,,16#8000,26,6,28,8,);
B(B_F,F159_MTRN!,,28,3,36,9,,?DEN?Ds_Start?Dn_Number?Dd_Port?AENO);
B(B_VARIN,,SYS_COM1_PORT,26,7,28,9,);
B(B_CONTACT,,bSwitchToMewtocolSlave,6,4,8,6,R);
B(B_CONTACT,,sys_bIsComPort1ProgramControlled,19,4,21,6,);
L(1,5,6,5);
L(8,5,19,5);
L(21,5,28,5);
L(1,0,1,9);
END_NETWORK_BODY
END_NET_WORK
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 7 ;
NETWORK_BODY
B(B_COMMENT,,Changing COM 1 from MEWTOCOL-COM Slave to program controlled mode.,1,0,30,1,);
B(B_VARIN,,wDummy,26,3,28,5,);
B(B_VARIN,,16#8000,26,4,28,6,);
B(B_F,F159_MTRN!,,28,1,36,7,,?DEN?Ds_Start?Dn_Number?Dd_Port?AENO);
B(B_VARIN,,SYS_COM1_PORT,26,5,28,7,);
B(B_CONTACT,,sys_bIsComPort1ProgramControlled,19,2,21,4,N);
B(B_CONTACT,,bSwitchToProgramControlled,6,2,8,4,R);
L(8,3,19,3);
L(21,3,28,3);
L(1,3,6,3);
L(1,0,1,7);
END_NETWORK_BODY
END_NET_WORK
END_BODY
(* Changing COM 1 from program controlled to MEWTOCOL-COM Slave mode.
The corresponding transmission mode flag R9032 (sys_bIsComPort1ProgramControlled) is set
when program controlled mode is selected. *)
if (DF(bSwitchToMewtocolSlave) AND sys_bIsComPort1ProgramControlled) then
F159_MTRN(s_Start := wDummy, n_Number := 16#8000, d_Port := SYS_COM1_PORT);
end_if;
(* Changing COM 1 from MEWTOCOL-COM Slave to program controlled *)
if (DF(bSwitchToProgramControlled) AND NOT sys_bIsComPort1ProgramControlled) then
F159_MTRN(s_Start := wDummy, n_Number := 16#8000, d_Port := SYS_COM1_PORT);
end_if;