Establishing a Modbus TCP connection with PLC

296 views
Skip to first unread message

Greg Madden

unread,
May 14, 2018, 1:56:08 AM5/14/18
to modbus-tk
I am trying to use modes-tk just to make a connection from my PC to a PLC over Modbus TCP. The PLC's IP is 10.0.0.168 and listens on port 502. I was able to communicate with the PLC using pymodbus so I can confirm that there are no network errors and that the PLC does accept connections. I am now trying to do the same thing with modbus-tk.

I have tried running the examples on my computer in two different shells but there are errors between both the master and slave so I cannot learn much from them.

What is the most basic way to establish a connection from my PC to the PLC?

Luc JEAN

unread,
May 14, 2018, 2:13:58 AM5/14/18
to modb...@googlegroups.com
Hello,

The TcpMaster class has 3 parameters on his constructor : host="127.0.0.1", port=502, timeout_in_sec=5.0

By default it tries to connect on localhost but you can change it by changing the value of the host parameter. Something like should work

master = modbus_tcp.TcpMaster(host=’10.0.0.168')

I hope it helps

Best
luc

--
You received this message because you are subscribed to the Google Groups "modbus-tk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modbus-tk+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Samrat Hossain

unread,
Sep 25, 2019, 4:50:05 AM9/25/19
to modbus-tk
hai,
I am new
I would connect with PC to a PLC over Modbus TCP. Plz help me how may i do this communication with the PLC.
Reply all
Reply to author
Forward
0 new messages