ABB机器人socket读取omron D10并写入D11
程序员文章站
2024-01-04 09:28:34
...
MODULE MainModule
VAR socketdev socket2;
VAR byte handshake{20}:=[70, 73, 78, 83, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1];
VAR byte readplcD10{34}:=[70, 73, 78, 83, 0, 0, 0, 26, 0, 0, 0, 2, 0, 0, 0, 0, 128, 0, 2, 0, 2, 0, 0, 1, 0, 0, 1, 1, 130, 0, 10, 0, 0, 1];
VAR byte writeplcD11{36}:=[70, 73, 78, 83, 0, 0, 0, 28, 0, 0, 0, 2, 0, 0, 0, 0, 128, 0, 2, 0, 2, 0, 0, 1, 0, 0, 1, 2, 130, 0, 11, 0, 0, 1, 0, 0];
VAR byte plcback{34}:=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
VAR num D10;
VAR num D10H;
VAR num D10L;
PROC main()
readomronD10;
writeomronD11;
ENDPROC
PROC readomronD10()
SocketClose socket2;
SocketCreate socket2;
SocketConnect socket2,"192.168.125.2", 9600 \Time:= 1;
socketSend socket2 \Data:=handshake;
SocketReceive socket2 \Data:=plcback;
plcback:=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1];
readplcD10:=[70, 73, 78, 83, 0, 0, 0, 26, 0, 0, 0, 2, 0, 0, 0, 0, 128, 0, 2, 0, 2, 0, 0, 1, 0, 0, 1, 1, 130, 0, 10, 0, 0, 1];
SocketSend socket2 \Data:=readplcD10;
SocketReceive socket2 \Data:=plcback;
SocketClose socket2;
D10H:=plcback{31};
D10L:=plcback{32};
D10 := plcback{31}*256 + plcback{32};
ENDPROC
PROC writeomronD11()
SocketClose socket2;
SocketCreate socket2;
SocketConnect socket2,"192.168.125.2", 9600 \Time:= 1;
socketSend socket2 \Data:=handshake;
SocketReceive socket2 \Data:=plcback;
plcback:=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1];
writeplcD11:=[70, 73, 78, 83, 0, 0, 0, 28, 0, 0, 0, 2, 0, 0, 0, 0, 128, 0, 2, 0, 2, 0, 0, 1, 0, 0, 1, 2, 130, 0, 11, 0, 0, 1, 0, 0];
writeplcD11{35}:=D10H;
writeplcD11{36}:=D10L;
SocketSend socket2 \Data:=writeplcD11;
SocketReceive socket2 \Data:=plcback;
SocketClose socket2;
ENDPROC
ENDMODULE
by 17551023102
MODULE MainModule
VAR socketdev socket2;
VAR byte handshake{20}:=[70, 73, 78, 83, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1];
VAR byte readplcD10{34}:=[70, 73, 78, 83, 0, 0, 0, 26, 0, 0, 0, 2, 0, 0, 0, 0, 128, 0, 2, 0, 2, 0, 0, 1, 0, 0, 1, 1, 130, 0, 10, 0, 0, 1];
VAR byte writeplcD11{36}:=[70, 73, 78, 83, 0, 0, 0, 28, 0, 0, 0, 2, 0, 0, 0, 0, 128, 0, 2, 0, 2, 0, 0, 1, 0, 0, 1, 2, 130, 0, 11, 0, 0, 1, 0, 0];
VAR byte plcback{34}:=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
VAR num D10;
VAR num D10H;
VAR num D10L;
PROC main()
readomronD10;
writeomronD11;
ENDPROC
PROC readomronD10()
SocketClose socket2;
SocketCreate socket2;
SocketConnect socket2,"192.168.125.2", 9600 \Time:= 1;
socketSend socket2 \Data:=handshake;
SocketReceive socket2 \Data:=plcback;
plcback:=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1];
readplcD10:=[70, 73, 78, 83, 0, 0, 0, 26, 0, 0, 0, 2, 0, 0, 0, 0, 128, 0, 2, 0, 2, 0, 0, 1, 0, 0, 1, 1, 130, 0, 10, 0, 0, 1];
SocketSend socket2 \Data:=readplcD10;
SocketReceive socket2 \Data:=plcback;
SocketClose socket2;
D10H:=plcback{31};
D10L:=plcback{32};
D10 := plcback{31}*256 + plcback{32};
ENDPROC
PROC writeomronD11()
SocketClose socket2;
SocketCreate socket2;
SocketConnect socket2,"192.168.125.2", 9600 \Time:= 1;
socketSend socket2 \Data:=handshake;
SocketReceive socket2 \Data:=plcback;
plcback:=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1];
writeplcD11:=[70, 73, 78, 83, 0, 0, 0, 28, 0, 0, 0, 2, 0, 0, 0, 0, 128, 0, 2, 0, 2, 0, 0, 1, 0, 0, 1, 2, 130, 0, 11, 0, 0, 1, 0, 0];
writeplcD11{35}:=D10H;
writeplcD11{36}:=D10L;
SocketSend socket2 \Data:=writeplcD11;
SocketReceive socket2 \Data:=plcback;
SocketClose socket2;
ENDPROC
ENDMODULE
by 17551023102