HAWK/JACE and Modbus

Tech
niagaraNX
Published in
4 min readJul 13, 2018

Modbus Information

In a Modbus network there are two types of devices: Masters and Slaves.

Master Devices
These devices ask other devices for information

Slave Devices
These devices provide information, for example energy meters

Modbus also has two serial transmission modes: RTU and ASCII.

All Modbus devices on a network must have the same transmission mode and all Modbus devices have to implement RTU and this is the default mode of devices.

Modbus Data

Modbus defines 4 different types of data:

Discrete Input (Input status)
Single Bit
Read only

Coil (Coil status)
Single Bit
Read and Write

Input Register
16 Bits
Read only

Holding Register
16 Bits
Read and Write

Modbus defines a basic data type (word) as a 16 bit value. To read 32 bit values, two consecutive 16 bit values can be read.

Reading Modbus Data

Step 1 — Adding a Modbus network

Open the modbusAsync palette.

Drag and drop a ModbusAsyncNetwork into the Drivers section of your station.

Add Modbus Network

Right-click on the ModbusAsyncNetwork and select Views > Property Sheet.

Expand the Serial Port Config property.

Enter COM2 as the Port Name (the default RS485 connection is COM2). Depending on your Modbus equipment you may need to change the other properties here (see manufactures website).

Modbus Network Settings

Step 2 — Adding a Modbus device

Drag and drop a ModbusAsyncDevice into the ModbusAsyncNetwork.

Enter the Modbus address into the Device Address field.

Add Modbus Device

Right-click on the ModbusAsyncDevice and select Actions > Ping.

Ping Modbus Device

As Modbus does not have a Ping protocol, if any data is received from the device (even if its an Modbus error) the Health property will read OK.

You can specify a Ping Address which is a Modbus register address, but it is not necessary.

Ping failure

If the Ping fails this means no data has been received from the device. Possible failures:

  • Wires not connected in the right order
  • Terminating resisters might be needed at the end of the bus
  • Incorrect COM port selected

Step 3 — Adding a Modbus point

Expand the Client Points folder in the modbusAsync palette and drag and drop a point into the Points object.

Add Modbus Points

Expand the Data Address property and enter the address of the Modbus register you want to get data from.

NB: Some Modbus registers are writable and some are not (see above) use the correct point type from the palette.

The Address Format specifies how the address will be interpreted. Modbus addresses are quoted in the manufacturers data sheet, addresses are usually in hexadecimal or integer formats.

HAWK data points

A HAWK has the following numeric data types:

Name, Data size, Fractional Part, Signed

Integer
16 Bits
No
No

Signed Integer
16 Bits
No
Yes

Long
32 Bits
No
Yes

Floating point
32 Bits
Yes
Yes

As Modbus data points are only 16 bits, a HAWK will automatically read more than one register in a row and combine the data.

The following points can be added to a ModbusAsyncDevice:

ModbusClientRegisterBitPoint***
Single Bit
Read

ModbusClientRegisterBitWritable***
Single Bit
Read and Write

ModbusClientBooleanPoint
Single Bit
Read

ModbusClientBooleanWritable
Single Bit
Read and Write

ModbusClientNumericPoint*
32/64 Bits
Read

ModbusClientNumericWritable*
32/64 Bits
Read and Write

ModbusClientNumericBitsPoint**
1–16 Bits (Variable)
Read

ModbusClientNumericBitsWritable**
1–16 Bits (Variable)
Read and Write

* Number of bits depends on numeric type selected (see table above)
** You can select the start bit and the number of bits to read
*** You can select a particular bit of a register to read/write

Reading 8 bit values

If you need to read integers that are 8 bits long use a ModbusClientNumericBitsPoint. Set the Beginning Bit to 0 and the Number Of Bits to 8.

Troubleshooting

If you can connect to a device, but cannot get the addresses correct, try adding or subtracting one from the address. For example if the address in the data sheet is 75, try setting the address to 74 or 76 (some Modbus devices list their registers off by one).

--

--