Ofer Posted April 30, 2019 Report Share Posted April 30, 2019 Im just a nube so it took me a while to figure it out. on the unitronix side assign a slave to one of the ports like this on the python side read data with something like this import modbus_tk import modbus_tk.defines as cst import modbus_tk.modbus as modbus import modbus_tk.modbus_tcp as modbus_tcp import logging logger = modbus_tk.utils.create_logger("console", level=logging.DEBUG) master = modbus_tcp.TcpMaster(host='172.21.2.183', port=20257, timeout_in_sec=5.0) master.open actual_bits = master.execute(slave=1, function_code=cst.READ_COILS, starting_address=1, quantity_of_x=2) print("actual_bits =", actual_bits) master.close remember the slave number! Hope this helps someone Link to comment Share on other sites More sharing options...
AlexUT Posted April 30, 2019 Report Share Posted April 30, 2019 Thank a lot for example. But it is better to use Socket 2, which use MODBUS port 502 by default. Where do you run Python? At PC side? B.R. Link to comment Share on other sites More sharing options...
Ofer Posted April 30, 2019 Author Report Share Posted April 30, 2019 python on pc side Link to comment Share on other sites More sharing options...
Ofer Posted May 22, 2019 Author Report Share Posted May 22, 2019 some help from friends and this forum - here is the last version of the controller side first added the close every 3 minutes - did not do the trick but helped a bit so i keep it there init the card socket and port and set tcp keep, link lost and connection gave a stable read even when power or cable momentarily removed Link to comment Share on other sites More sharing options...
MVP 2023 Joe Tauser Posted May 25, 2019 MVP 2023 Report Share Posted May 25, 2019 Also look at SI 103 .. SI 108 which are internal timers to close socket after a period of silence. Try disabling your timer networks and setting SI 105 to 600 to achieve the same results. If your system is the Master use SI 109. If you open the Help and search for "SI 105" you can navigate your way to a more thorough description. Joe T. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now