Direct Modbus TCP | LabJack
 
« Close

Datasheets and User Guides

App Notes

Software & Driver

 

Direct Modbus TCP

Overview

LabJack T-Series devices speak Modbus TCP. This makes them compatible with dozens of 3rd-party libraries. For most applications, however, LabJack recommends using the LJM library as it is simpler than using direct Modbus. Other reasons include:

Reasons to use direct Modbus

  • If the programming language you need is not supported in the LJM examples.
    • Please let us know if this describes you, since we like to support LJM for popular languages.
  • If you prefer to use an open-source library.
  • If you're already familiar with Modbus.
  • If you're using an architecture (such as embedded) or an operating system that isn't supported on LJM.

Getting Started

The T7 and T4 have five test registers that should be used before trying to read/write to other registers. This will help in trying to debug any getting-started related issues with addressing or bit-wise (byte-flipping) issues.

Modbus Map

The Modbus Map defines the address and name of all registers, along with other information.  This section has a dynamic map that allows you to filter and search.

Direct Modbus API Documentation

For more information about LabJack's direct Modbus implementation check out the API documentation section.

Modbus TCP Example Code Table

Modbus TCP Example Code Table (Referencable)

Direct Modbus TCP Example Code

T7 T4

T7, T4


Libraries... Windows Mac Linux
LabVIEW
Node.js
Python
C/C++ (Streaming)
C# .NET

To use a 3rd party Modbus program, such as a Rockwell/Allen Bradley application, follow the instructions on the Modbus Client Applications page.

More information about Modbus as well as some getting started information can be found on the Modbus API Documentation page. A list of the available Modbus registers is available on the Modbus Map page.

3 comments

I am attempting to read two values using two Modbus messages.  The first attempts to get AIN0 and the second attempts to get DIO18_EF_READ_A (set to be a high speed counter).  I send these messages on a 10Hz clock.  If I send only the AIN0 message, I get AIN0 responses.  If I send only the DIO18_EF_READ_A message, I get DIO18_EF_READ_A responses.  If I attempt to send both messages back to back, I only get responses from the first message.  Both messages are sent successfully according to the socket write command (I'm writing in C++).  What is happening to the second message?

Can your software capture the raw packets sent and received so we can look at what is going on?  Similar to what you see for the Command and Response in the "Examples" at the bottom of the Modbus TCP - Protocol Details page.  Or if your software can't capture it perhaps you can use Wireshark or similar.

Thanks for the help.  I used Wireshark to grab the messages to send to you and found that the two back to back messages (written with different TCP write calls) got packed into the same TCP packet.  The T7 responded to the first part of the packet and ignored the rest.  I fixed it by flushing the socket before sending the second message.  Now both messages are sent in their own TCP packets and all is well.