3.Modbus RTU Protocol

3.1Introduction to Modbus

Model 3810A Addressable In-Place Inclinometers use the industry standard Modbus Remote Terminal Unit (RTU) protocol to communicate with the chosen readout method. Modbus was designed to work on what is known as a bus network, meaning that every device receives every message that passes across the network. The Modbus standard does not specify a physical layer (connection type), but it will work with any interface that can communicate asynchronously with multiple devices (e.g., RS-485, RS-422, optical, radio, etc.). Model 3810A strings use RS-485 as the electrical interface because of its prevalence, simplicity, and success as a robust, industrial physical layer.

3.2Modbus RTU Overview

The Modbus RTU protocol uses packets (multiple sections that together compose a message) to communicate and transfer data between devices on the network. The general format of these packets is as follows:

1.Modbus Address (one byte) – the address of the specific device on the bus. (Labeled on the sensors as #1, #2, #3, etc.)

2.Function Code (one byte) – the action to be carried out by the slave device.

3.Data (multi-byte) – the payload of the function code being sent.

4.CRC (two bytes) – cyclic redundancy check; a 16-bit data integrity check calculated over the other byes in the packet.

3.3Modbus Tables

The most recent sensor reading is stored in a table. The reading is presented in different formats in different sections of the table. The register location and size of these variables are described in the table below.

Variable

Type (Modbus Message)

HEX

Decimal

Description

ADC

uint16

0x0100

256

Raw 16-bit thermistor reading

IC Temp.

int16

0x0101

257

Low-quality 10-bit temperature reading

Resistance

float32

0x0102

0x0103

258

259

Decimal thermistor reading (Ohms)

Trigger

uint16

0x0118

280

Write nonzero value to initiate measurement

table 1: RAM Storage

3.4Reading 3810A Sensors

While Modbus RTU supports roughly 20 different function codes, the simple functionality of a bused temperature sensor, such as the geokon 3810A, eliminates the need for all but two of them. Only the Write Holding Register (0x06) function code and Read Holding Registers (0x03) and are needed to read the sensors.

First, use the Write Holding Register function to refresh the temperature measurement. The command initiates multiple analog-to-digital (ADC) conversions that are averaged to optimize precision and resolution. The updated measurements will be ready approximately 0.25 seconds after the request. An example request is shown in the table below.   

 

Device Address

Function Code

Data Address

Register Value

CRC

HEX16

02

06

0118

0001

C9C2

DEC10

2

6

280

1

51,650

table 2: Example Query - Trigger Measurement

Use device address 0 to “broadcast” the trigger command to all drops simultaneously. Measurements between successive address are staggered by 50 milliseconds to prevent excess current draw from simultaneous activation.

The Read Holding Registers function can be used to read one or more 16-bit registers (two bytes each), starting at the Data Address that was sent in the command packet. Temperatures can be retrieved in two alternate formats; one as a raw 16-bit ADC value, the other as a 32-bit floating point (decimal) number that is the computed resistance of the on-board thermistor. For ease of use and program simplicity, the 32-bit floating-point reading is recommended. An example of this query and response is shown in the tables below.

 

Device Address

Function Code

Data Address

Number of Registers

CRC

HEX16

02

03

0102

0002

6404

DEC10

2

3

258

2

25,604

table 3: Example Query - Floating Point Resistance Reading   

          

Device Address

Function Code

Byte Count

Lower 16-bits

Upper 16-bits

CRC

HEX16

02

03

04

C87C               

4628               

04F5

DEC10

2

3

4

floating point result

1,269

table 4: Example Response - Floating Point Resistance Reading

PC Terminal Program Screen Capture

6:    

green_and_red_text.png

The above shows the IEEE-754 floating-point response as two parts—each one is composed of two bytes. Because of how this information is stored in memory, the two parts are received in reverse order; the complete floating-point number in HEX is 0x4628C87C (10,802.12 ohms).