# RS485  Modbus RTU

{% hint style="info" %}
RS485 is enabled **only in the Main Screen** state. When the device is in a **settings** or **parameter editing** screen, RS485 will not respond to any Modbus commands.
{% endhint %}

## **Specifications**

| Baud Rate                         | 9600, 19200, 38400, 57600 |
| --------------------------------- | ------------------------- |
| Wiring                            | 2-wire                    |
| Maximum Nodes on the Same Network | 256                       |

## RS485 2-Wire Wiring Diagram

* **Black:** RS485 (B−), **Green:** RS485 (A+)

This function operates only when the brown and blue lines of the DC power supply are powered.\
For clarity, the DC power lines are omitted in this diagram. Refer to the **DC Power Wiring Diagram** for details.

{% hint style="danger" %}
Do not confuse RS485 wiring with the power lines; miswiring may damage the device, and repair costs are the user’s responsibility.
{% endhint %}

<div align="left"><figure><img src="https://3404778090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi4ECt41Kyy9211OWazj4%2Fuploads%2F5RkUSUAPuAxc4xbYHVre%2Frs475%20wire.png?alt=media&#x26;token=aaf94015-d6c6-48b2-adb3-e4a50f47c541" alt="" width="563"><figcaption></figcaption></figure></div>

{% hint style="info" %}

## **Wiring Recommendations**

1. Use **24 AWG shielded twisted pair** for RS485, daisy-chaining each device. Avoid ring or star topologies.
2. For long runs, place **termination resistors (typically 120 Ω)** at the master and far-end device; adjust based on cable specs.
3. If communication is unstable, add **bias resistors** near the master to improve signal stability.
4. For 6-core cables, trim to the minimum required length and connect the shield to ground.
5. In areas with heavy interference, implement **multiple query retries** in software to distinguish signal noise from device offline errors.
   {% endhint %}

### RS485 Modbus RTU Parameter Configuration

Follow the steps below to configure RS485 Modbus RTU parameters:

{% stepper %}
{% step %}

### **Set Basic Parameters**

* Refer to the [**Parameter Settings**](https://docs.lorric.com/qr/fu-lt-english-v1/installation-and-setup/parameter-settings) page and complete the following steps: **Language Setting, Pipe Settings:A02:** Pipe Standard, **A04:** Pipe Outer Diameter, **A06:** Pipe Wall Thickness, **A08:** Pipe Material
* Execute **Z03 (Automatic Initialization)**.
  {% endstep %}

{% step %}

### **Wiring Setup**

Connect the RS485 Modbus RTU wiring according to the instructions on this page.
{% endstep %}

{% step %}

### **E04 Modbus ID (Communication Protocol Application)**

Set **E04** to assign the flowmeter’s **Modbus Slave ID** on the RS485/Modbus network.

* Ensure that each device on the same bus has a **unique ID** to avoid communication conflicts.
* This parameter **cannot be modified via RS485**.
  {% endstep %}

{% step %}

### **E05 Baud Rate**

Set **E05 Baud** to specify the flowmeter’s **Modbus communication speed** (Baud Rate).

* The **Master** and **Slave** devices must be set to the **same Baud Rate** for proper communication.
* This parameter **cannot be modified via RS485**.
  {% endstep %}

{% step %}

### **Return to Main Screen**

Return to the **Main Screen** (green LED). RS485 communication is enabled **only on the Main Screen**.
{% endstep %}

{% step %}

### Test Read/Write Memory

Refer to the [**Modbus RTU Protocol**](https://docs.lorric.com/qr/fu-lt-english-v1/communication/modbus-rtu-protocol) to test the memory for reading and writing.

<table><thead><tr><th width="262.0087890625"></th><th></th></tr></thead><tbody><tr><td><p></p><p>Communication Format</p></td><td><p>bit order: lsb first<br>byte order: big endian<br>Data bits: 8<br>Parity: None<br>Stop bits: 1</p><p>Floating point number follows IEEE754-1985. The float32 below stands for 32bits Single precision floating point number.</p></td></tr><tr><td><strong>Memory Definition and Function</strong></td><td><p>Modbus-accessible memory is divided into <strong>two types</strong>: <strong>Read-Only (RO)</strong> and <strong>Read/Write (RW)</strong>.</p><ol><li><p><strong>Read-Only Memory (RO):</strong></p><ul><li>Primarily stores flowmeter status information, such as real-time flow.</li><li>This type is the most commonly used memory.</li><li>Can <strong>only be read</strong> using function code <strong>04</strong>.</li></ul></li><li><p><strong>Read/Write Memory (RW):</strong></p><ul><li>Primarily stores flowmeter configuration parameters.</li><li><p>Each write operation can <strong>only modify one parameter at a time</strong>.</p><ul><li>If the parameter occupies <strong>1 register</strong>, use function code <strong>06</strong>.</li><li>If the parameter occupies <strong>2 registers</strong>, use function code <strong>30</strong>.</li></ul></li></ul></li></ol></td></tr></tbody></table>

{% hint style="info" %}
In Modbus RTU communication, a Register is the basic unit for memory communication, with a length of 2 bytes (16 bits).\
A Byte is the basic unit for data transmission, with a length of 8 bits.
{% endhint %}
{% endstep %}
{% endstepper %}

### Modbus RTU Example – Reading Float32 Data

Using a Read-Only memory read command (04) as an example, this section explains how to send a command and parse the returned data into a decimal value when the accumulated flow is 20,000.5 liters.

**Read-Only Memory – Read Command (04) Format**

<figure><img src="https://3404778090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi4ECt41Kyy9211OWazj4%2Fuploads%2Freb9w1HVRJuNuDjmVmj9%2Fmodbus-04-TX-diagram-en.png?alt=media&#x26;token=990793a9-39e3-4390-82e6-e153c0d4fbfe" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3404778090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi4ECt41Kyy9211OWazj4%2Fuploads%2FkaGb5vxZZjH3jzwiqW89%2Fmodbus-04-RX-diagram-en.png?alt=media&#x26;token=be73b64d-df05-4d34-9385-0a43a1ba998d" alt=""><figcaption></figcaption></figure>

#### **Modbus RTU Example – Read-Only Memory Read Command (04)**

**Master Sends Read Command (TX Frame)**

According to device specifications, the accumulated flow is stored in **Float32 format**, occupying **2 registers (4 bytes)**; therefore, the quantity to read should be set to **00 02**. The master must send Modbus function code 04 (Read Input Registers) to read 2 registers starting from address 0000.

```
TX: 01 04 00 00 00 02 71 CB
```

* Slave Address = 01
* Function Code = 04
* Starting Register Address = 00 00
* Quantity to Read = 00 02 (2 registers)
* CRC Checksum = 71 CB

**Slave Response Data (RX Frame)**

After receiving the read request, the slave returns the internally stored **20,000.5 liters (Float32)** data, packaged as **4 bytes** according to **Modbus Register Big Endian** (high byte first) and **IEEE 754 Float32** format.

```
RX: 01 04 04 45 9C 40 00 E2 56
```

* Slave Address = 01
* Function Code = 04
* Byte Count (Number of Data Bytes) = 04 (4 Bytes)
* Data (Data Field) = 45 9C 40 00
* CRC Checksum = E2 56

**Data Parsing and Conversion (Back to Decimal)**

**Step A: Arrange the Data**\
Since the device uses **Big Endian** format, the most significant byte comes first. Therefore, the 4 bytes are kept in the received order and combined as:\
`459C4000₁₆`

**Step B: Decode the Float32 Structure (SEM: S = Sign, E = Exponent, M = Mantissa)**\
Convert `459C4000₁₆` into a 32-bit binary number for IEEE 754 Float32 interpretation.

![](https://content.gitbook.com/content/i4ECt41Kyy9211OWazj4/blobs/0xkomQ8TDrwjQi11vUhZ/image)

**Partial Binary Value Explanation**

* **S (Sign bit)** = 0 (1 bit) → 0 means a positive number
* **E (Exponent bits)** = `10001011` (8 bits) → 139₁₀\
  Actual exponent = 139 − 127 = **12**
* **M (Mantissa bits)** = `001110001...` (23 bits) → the significand is **1.M**

**Step C: Calculate the Value**

According to the IEEE 754 Float32 format, the calculation is as follows.\
The exponent bits `10001011₂` equal 139₁₀, so the actual exponent is 139 − 127 = 12.

* The mantissa bits are 0011100100000000000000，, giving a significand of 1.001110001...

After shifting the binary point 12 places to the right and converting to decimal:

Value = 2¹⁴ + 2¹¹ + 2¹⁰ + 2⁹ + 2⁵ + 2⁻¹\
\= 16384 + 2048 + 1024 + 512 + 32 + 0.5\
\= 20000.5

Therefore, the Modbus RX response data `01 04 04 45 9C 40 00 E2 56` represents a cumulative flow value of **20000.5 liters**.

### **Modbus Data Format Converter**

Below is a sample **HTML/CSS/JS (CodePen example)** of a simple converter used to convert an **8-digit hexadecimal value** into a **Float32** number.

{% embed url="<https://codepen.io/philo_lorric/pen/BagqoRj>" %}
