Jump to content
  • entries
  • comments
  • views

Simple 1-Node Modbus TCP Master




2 members have voted

  1. 1. Was this code module helpful to you?

    • Yes, as written
    • Yes, with some modifications
    • No
    • Who wrote this buggy junk?

This is a little Modbus routine I wrote to connect to one remote node, in my case a Dalsa IPD vision device. It's not designed to connect to several devices, just a one-to-one such as my camera setup, a single servo drive or VFD.

As such, it is really optimized for maximum communication to that single device. The module reads the vector of addresses from the slave constantly, as fast as possible. Writes only take place when a value in the Tx Vector is changed. So the PLC always has the freshest possible data in the fastest possible manner.

On the HMI Side, I collected about a dozen different status bits into two message objects, one for the Ethernet adapter and one for the socket.

Special thanks go out to Ash Neilson, who was a tremendous help on getting the serial variation of this running last year.

If you look at the source and find yourself wondering why there are two Socket 3 Busy bits, check out the conversation here:

I hope you find it useful!


Edit: forgot something, added rollover for the RHR / PHR counters and an error count.

1 Comment

Recommended Comments

Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...