Modbus connection to Simulator?
Hy everybody
I'm new to the Trio controller and to the Modbus protocol and I am trying to understand how to connect the simulator (I would like to test the program without any hardware connected first) to a server that I would be running on my pc.
So far I have written a minimal python script that opens a server that does nothing
- from pyModbusTCP.server import ModbusServer
- server = ModbusServer("127.0.0.1", 502, no_block=True)
- try:
- print("Start server...")
- server.start()
- print("Server is online")
- while True:
- pass
- except:
- print("Shutdown server ...")
- server.stop()
- print("Server is offline")
And then I run the following code on Motion Perfect:
- IF MODBUS(0, -1, 127,0,0,1,502,20)=TRUE THEN
PRINT "Modbus Port Open"
modbus_handle=VR(20)
ELSE
PRINT "Error opening Modbus Port"
ENDIF
However Motion Perfect always fails to connect and the "Error opening Modbus Port" pops up every time.
Does anybody know what I am doing wrong?