« Close

Datasheets and User Guides

App Notes

Software & Driver

 

Getting Started

Modbus - Getting Started [referenceable]

To get started with direct Modbus TCP when using any HMI, PLC, or a 3rd party Modbus Client Application, first try writing & reading to/from the test registers.

See the Examples section on the Modbus Protocol Details page.

If using COTS Modbus Client software, keep the following in mind:

  • 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 the registers are defined in our Modbus Map.
  • Use function 3, 4, 6, or 16.  Choose "Holding" if needed.

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

Name Start Address Type Access Default
TEST 55100 UINT32 R 1122867
TEST_UINT16 55110 UINT16 R/W 17
TEST_UINT32 55120 UINT32 R/W 1122867
TEST_INT32 55122 INT32 R/W -2003195205
TEST_FLOAT32 55124 FLOAT32 R/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.  Does not seem to cause problems, but can be confusing.

General Modbus Information

More getting started information and general Modbus resources can be found on the Modbus API Documentation page.