F159_MTRN (n_Number=16#8000)

切换通信模式

CPU通信端口的通信模式可在RUN模式期间更改。您可以通过执行F159_MTRN和将变量n_Number(要发送的字节数)设置为16#8000,在程序控制模式和MEWTOCOL-COM模式之间进行切换。

参数

输入

s_Start (WORD, INT, UINT)

发送缓冲区

n_Number (WORD, INT, UINT)

要发送的字节数:

  • 负值:在系统寄存器中选择的结束代码不会增加到发送字符串。

  • 0(0字节):准备系统以接收更多数据

  • 16#8000:切换通信模式

d_Port (WORD, INT, UINT)

根据PLC的类型指定通信端口:

  • COM端口,例如SYS_COM0_PORT

  • 以太网端口,例如SYS_ETHERNET_USER_CONNECTION_1

  • MCU/SCU,例如COM01中的16#xx01 (xx = 插槽编号)

标注

  • 当电源打开时,将设置在系统寄存器中选择的通信模式。

  • 在RUN模式期间,无法更改为Modbus RTU模式或PLC Link模式。

示例

POU头

所有用于编程此函数的输入和输出变量已在POU头中声明。 所有编程语言使用相同的POU头。

	VAR 
		bSwitchToMewtocolSlave: BOOL:=FALSE;
		wDummy: WORD:=0;
		bSwitchToProgramControlled: BOOL:=FALSE;
	END_VAR

LD本体

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

ST本体

(* 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;

最后更新日期: 此页面上的反馈松下热线