Jump to content
  • entries
    10
  • comments
    27
  • views
    21,771

Simple 1-Node Modbus TCP Master

Sign in to follow this  
tmoulder

2,181 views

  

2 members have voted

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

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

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!

TM

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

Sign in to follow this  


1 Comment


Recommended Comments

Guest
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...