Modbus connection to Simulator?
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)
- print("Start server...")
- print("Server is online")
- while True:
- print("Shutdown server ...")
- 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"
PRINT "Error opening Modbus Port"
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?