资料传输很不可靠,触摸屏更改一下重新下载,数据传输就断了,再下载的时候有数据传输又正常了。
用宏指令做一下数据转化就能实现。但是奇怪的是之前用三菱Q系列PLC就一切正常,现在另一个项目中用欧姆龙NJ系列PLC就不行,外部变量的数据无法转化过来。
以下这段宏指令运行OK;
macro_command main()
//Modbus 读取传递到PLC
short a=0
GetData(a, "MODBUS RTU (Adjustable)", 4x, 2#0, 1)
SetData(a, "Mitsubishi MELSEC-Q/L - Binary Mode", D, 2204, 1) //CH1 实际值传递到D2204
short b=0
GetData(b, "MODBUS RTU (Adjustable)", 4x, 2#1, 1)
SetData(b, "Mitsubishi MELSEC-Q/L - Binary Mode", D, 2206, 1) //CH2 实际值传递到D2206
short c=0
GetData(c, "MODBUS RTU (Adjustable)", 4x, 2#2, 1)
SetData(c, "Mitsubishi MELSEC-Q/L - Binary Mode", D, 2208, 1) //CH3 实际值传递到D2208
short d=0
GetData(d, "MODBUS RTU (Adjustable)", 4x, 2#3, 1)
SetData(d, "Mitsubishi MELSEC-Q/L - Binary Mode", D, 2210, 1) //CH4 实际值传递到D2210
short e=0
GetData(e, "MODBUS RTU (Adjustable)", 4x, 2#4, 1)
SetData(e, "Mitsubishi MELSEC-Q/L - Binary Mode", D, 2212, 1) //CH5 实际值传递到D2212
short f=0
GetData(f, "MODBUS RTU (Adjustable)", 4x, 2#5, 1)
SetData(f, "Mitsubishi MELSEC-Q/L - Binary Mode", D, 2214, 1) //CH6 实际值传递到D2214
short g=0
GetData(g, "MODBUS RTU (Adjustable)", 4x, 2#6, 1)
SetData(g, "Mitsubishi MELSEC-Q/L - Binary Mode", D, 2216, 1) //CH7 实际值传递到D2214
short h=0
GetData(h, "MODBUS RTU (Adjustable)", 4x, 2#7, 1)
SetData(h, "Mitsubishi MELSEC-Q/L - Binary Mode", D, 2218, 1) //CH8 实际值传递到D2218
// PLC设定地址传递到modbus
short a1=0
GetData(a1, "Mitsubishi MELSEC-Q/L - Binary Mode", D, 1002, 1)
SetData(a1, "MODBUS RTU (Adjustable)", 4x, 2#8, 1) //CH1 设定值传递到0008H
short b1=0
GetData(b1, "Mitsubishi MELSEC-Q/L - Binary Mode", D, 1003, 1)
SetData(b1, "MODBUS RTU (Adjustable)", 4x, 2#9, 1) //CH2 设定值传递到0009H
short c1=0
GetData(c1, "Mitsubishi MELSEC-Q/L - Binary Mode", D, 1004, 1)
SetData(c1, "MODBUS RTU (Adjustable)", 4x, 2#10, 1) //CH3 设定值传递到000AH
short d1=0
GetData(d1, "Mitsubishi MELSEC-Q/L - Binary Mode", D, 1005, 1)
SetData(d1, "MODBUS RTU (Adjustable)", 4x, 2#11, 1) //CH4 设定值传递到000BH
short e1=0
GetData(e1, "Mitsubishi MELSEC-Q/L - Binary Mode", D, 1007, 1)
SetData(e1, "MODBUS RTU (Adjustable)", 4x, 2#12, 1) //CH5 设定值传递到000CH
short f1=0
GetData(f1, "Mitsubishi MELSEC-Q/L - Binary Mode", D, 1008, 1)
SetData(f1, "MODBUS RTU (Adjustable)", 4x, 2#13, 1) //CH6 设定值传递到000DH
short g1=0
GetData(g1, "Mitsubishi MELSEC-Q/L - Binary Mode", D, 1009, 1)
SetData(g1, "MODBUS RTU (Adjustable)", 4x, 2#14, 1) //CH7 设定值传递到000EH
short h1=0
GetData(h1, "Mitsubishi MELSEC-Q/L - Binary Mode", D, 1010, 1)
SetData(h1, "MODBUS RTU (Adjustable)", 4x, 2#15, 1) //CH8 设定值传递到000FH
|