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:
- Read the "Details to Keep in Mind" section below.
- Try writing and reading the test registers. See the "Test Registers" and "Common Issues" sections below.
- 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
to65535
. 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
, or16
. 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
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:
- The client subtracts
1
from all addresses. You tell the client you want to read address2000
, but the client puts1999
in the actual packet. That means if you want to read address2000
, you have to tell the client2001
. This seems to be an attempt to give the user addresses that go from1-65536
rather than0-65535
. We use0-65535
addressing. If you want to read address2000
, then2000
should be in the packet. - The software flips the order of the words within a 32-bit value. For example, a read of
TEST
should return0x00112233
, but the client returns0x22330011
. - 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 from2000
, it will say it is reading from42000
, but in the actual Modbus packet it specifies address2000
. This does not seem to cause problems, but can be confusing.