Skip to main content
Skip table of contents

Getting Started [Direct Modbus TCP]

To get started with direct Modbus TCP when using any HMI, PLC, or a 3rd party Modbus Client Application, do the following:

  1. Read the "Details to Keep in Mind" section below.
  2. Try writing and reading the test registers. See the "Test Registers" and "Common Issues" sections below.
  3. See the information and examples on the Modbus Protocol Details page.

Further resources can be found on the Modbus API Documentation page.

Details to Keep in Mind

The following list contains some LabJack Modbus implementation details that you should keep in mind. These are especially important if you are using COTS Modbus Client software:

  • The LabJack is a Modbus TCP Server.  A Modbus TCP Client can send a command to the LabJack and get back a response.  Sometimes a Server is called the Slave and a Client is called the Master.
  • We use a single register map with addresses from 0 to 65535.  Each address points to a 16-bit value that might be readable, writable, or both.
  • The meaning of all device registers are defined in our Modbus Map.
  • Use function 3, 4, 6, or 16.  Choose "Holding" if necessary.

When troubleshooting, it can be useful to look at the packets being sent to and from your device. If you don't have a better way to see the bytes written and read for each packet, you can use Wireshark to get a TCP capture.

Test Registers

NameStart AddressTypeAccessDefault
TEST55100UINT32R1122867
TEST_UINT1655110UINT16R/W17
TEST_UINT3255120UINT32R/W1122867
TEST_INT3255122INT32R/W-2003195205
TEST_FLOAT3255124FLOAT32R/W-9999.0

TEST

A read of this test register should always return 0x00112233 or d1122867. If your software has the word swap quirk, you will incorrectly read 0x22330011 or 573767697. If your software has the "address-1" quirk, a UINT16 (1-register) read from 55101 will incorrectly return 0x0011 (should read 0x2233).

TEST_UINT16

Write a value and read back to test UINT16 operation. Default is 0x0011 or d17.

TEST_UINT32

Write a value and read back to test UINT32 operation. Default is 0x00112233 or d1122867. If your software has the word swap quirk, the default will incorrectly read 0x22330011 or 573767697.

TEST_INT32

Write a value and read back to test INT32 operation. Default is 0x8899AABB or d-2003195205. If your software has the word swap quirk, the default will incorrectly read 0xAABB8899 or -1430550375.

TEST_FLOAT32

Write a value and read back to test FLOAT32 operation. Default is 0xC61C3C00 or -9999.0. If your software has the word swap quirk, the default will incorrectly read 0x3C00C61C or 0.00786.

Common Issues

Below is a list of some common issues that customers tend to deal with when configuring & setting up Modbus Client Applications:

  1. The client subtracts 1 from all addresses.  You tell the client you want to read address 2000, but the client puts 1999 in the actual packet.  That means if you want to read address 2000, you have to tell the client 2001.  This seems to be an attempt to give the user addresses that go from 1-65536 rather than 0-65535.  We use 0-65535 addressing.  If you want to read address 2000, then 2000 should be in the packet.
  2. The software flips the order of the words within a 32-bit value.  For example, a read of TEST should return 0x00112233, but the client returns 0x22330011.
  3. The software says it is adding 40000 to the addresses, but if you look at the actual packet it is not.  For example, if you ask the software to read from 2000, it will say it is reading from 42000, but in the actual Modbus packet it specifies address 2000.  This does not seem to cause problems, but can be confusing.
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.