Jump to content
  • entries
    10
  • comments
    30
  • views
    27,614

Simple 1-Node Modbus TCP Master


tmoulder

3,248 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.

1 Comment


Recommended Comments

  • External Moderators

Somebody voted "buggy junk" above :) If anybody is having issues, I'm happy to help. Just post issues here.

Thanks,

TM

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.