> For the complete documentation index, see [llms.txt](https://docs.lorric.com/qr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.lorric.com/qr/fp-as510-paddle-wheel-flowmeter-manual-chinese-v2/communication/rs485-setup.md).

# RS485 與 Modbus RTU 設定

{% hint style="info" %}
RS485 通訊僅在「主畫面」狀態下才會啟用。\
當設備停留在設定畫面或參數編輯畫面時，RS485 將不回應任何 Modbus 指令。
{% endhint %}

## 規格

| 鮑率 Baud    | 9600, 19200, 38400 及 57600     |
| ---------- | ------------------------------ |
| 接線         | 二線式                            |
| 同一網絡中最多節點數 | 32 台（標準單位負載條件下，每台裝置計為 1 個單位負載） |

## 接線

### RS485 二線式配線圖

黑色線：RS485 (B-)、綠色線：RS485 (A+)

本功能必須在DC 電源的棕藍色有供電的情形下，才能工作。為維持圖面易讀性，本圖省略DC供電圖，詳情形見 DC 電源配線圖。

{% hint style="danger" %}
請注意RS485的配線請勿和電源配線接錯，若因誤接導致線路或產品受損，請聯繫 LORRIC 原廠安排機器更換，相關維修費用需由使用者承擔。
{% endhint %}

![](https://2086194569-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LxeY3bBEflHg4JOGyfX%2F-Lxea_AJoFWovC7hLY6w%2F-LxefUpjBvk05qTV5eas%2FRS485.png?alt=media\&token=fc0b9cf7-3c61-4198-aa48-e32956828022)

{% hint style="info" %}

## 配線建議

1. 一般建議使用帶屏蔽 24awg 雙絞線，以串接方式連線每台設備，不要使用環狀或放射狀線路。
2. 連線長時，請在 master 及線路最遠端使用終端電阻，終端電阻業界常使用 120Ω，實際數值請參照線材規格計算。
3. 若通訊訊號不穩定，可於總線上的適當位置（通常靠近主站）加裝偵壓電阻，以提升訊號穩定性。
4. 隨貧8芯線，如果使用在 RS485 通訊，請修剪線材長度，盡量使用最短必要線長，以降低雜訊干擾。並將隔離網與主要通訊線屏蔽相連後接地。
5. 在訊號干擾多的地方，軟體可能需要多次詢問才能得到回應，請在通訊程式內建立多次詢問機制，以區別訊號干擾與設備異常離線兩種情形。
   {% endhint %}

## RS485 Modbus RTU參數設定

{% stepper %}
{% step %}

### 設定基本參數

請先完成推薦[參數設定](https://docs.lorric.com/qr/fp-as510-paddle-wheel-flowmeter-manual-chinese-v2/installation-and-setup/parameter-setup.md)流程（[H04 語言設定](https://docs.lorric.com/qr/fp-as510-paddle-wheel-flowmeter-manual-chinese-v2/parameters/h-xi-tong-xiang-guan-she-ding/h04-yu-yan.md)、[A01 三通管](https://docs.lorric.com/qr/fp-as510-paddle-wheel-flowmeter-manual-chinese-v2/parameters/a-liang-ce-xiang-guan-she-ding/a01-san-tong-guan.md)）。
{% endstep %}

{% step %}

### 設置接線

依照本頁指示將RS485 Modbus RTU配線設置妥當。
{% endstep %}

{% step %}

### E04 Modbus ID 應用傳輸協定

請設定 **E04** 以指定流量計於 **RS485 / Modbus** 網路中的從站位址（Modbus Slave ID）。請確認同一通訊線路上各設備之位址皮為唯一，避免地址重複造成通訊衝突。

本參數不支援使用 RS485 修改。
{% endstep %}

{% step %}

### E05 Baud 鮑率

請設定 **E05 Baud 鮑率** 以指定流量計之 **Modbus 通訊速率（Baud Rate）**。\
主站（Master）與流量計（Slave）必須設定為**完全相同的鮑率**，方可建立正常通訊。

本參數不支援使用 RS485 修改。
{% endstep %}

{% step %}

### 返回到主畫面

請回到主畫面（綠燈），必須在主畫面下，RS485 才會工作。
{% endstep %}

{% step %}

### 如需要，可使用模擬模式測試

請使用參數 F01 及 F02 將主機設定為模擬模式以方便測試。
{% endstep %}

{% step %}

### 測試要讀寫的記憶體

請參考[ Modbus RTU Protocol ](https://docs.lorric.com/qr/fp-as510-paddle-wheel-flowmeter-manual-chinese-v2/communication/modbus-rtu-protocol.md)頁面測試要讀寫的記憶體。

|          |                                                                                                                                                                                                                                                |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 通訊格式     | <p>bit order: lsb first</p><p>byte order: big endian</p><p>Data bits:8</p><p>Parity: None</p><p>Stop bits: 1</p><p>Floating point number follows IEEE754-1985. The float32 below stands for 32bits Single precision floating point number.</p> |
| 記憶體定義及功能 | <p>modbus 可操作的記憶體分為兩大類，唯讀型及讀寫型。</p><p>唯讀型主要是流量計狀態相關的記憶體，例如即時流量。這部分也是最常使用的記憶體。唯讀型的記憶體只能使用指令04 來讀取。</p><p>讀寫型主要是流量計設定參數記憶體，寫入操作一次只能改變一個參數，如果目標參數的記憶體長度是 1個 register，使用指令 06，如果目標參數的記憶體長度是 2 register，使用 30。</p>                                  |

{% hint style="info" %}
在 Modbus RTU 通訊中，Register（暫存器）是記憶體通訊的基本單位，其長度為 **2 Byte（16 bit）**；而 Byte（位元組）則是資料傳輸的基本單位，長度為 **8 bit**。
{% endhint %}
{% endstep %}

{% step %}

### 關閉模擬模式

確認測試完成後，請將 F02 關閉，並回到主畫面。完成。
{% endstep %}
{% endstepper %}

<details>

<summary><strong>Modbus RTU 讀取 Float32 數據範例</strong> <em>（點擊展開）</em></summary>

以唯讀型記憶體讀取指令 (04) 為例，說明當累積流量為 5,000.0 公升時，如何發送指令並將回傳數據解析為十進位數值。詳細指令格式請參考 唯讀型記憶體–讀取指令(04) 頁面。

</details>

<details>

<summary><strong>唯讀型記憶體讀取指令</strong> <em>（點擊展開）</em></summary>

**主站發送讀取指令 (TX 訊框)**

依設備規格，累積流量以 **Float32** 格式儲存，佔用 **2 個暫存器 (4 bytes)**，因此讀取數量應設定為 **00 02**。主站需發送 Modbus 功能碼 04（讀取輸入暫存器），從位址 0000 開始讀取 2 個暫存器。

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

* 從站地址 = 01
* 功能碼 = 04
* 起始暫存器位址 = 00 00
* 讀取數量 = 00 02（2 個暫存器）
* CRC 校驗碼 = 71 CB

**從站回覆數據 (RX 訊框)**

從站收到讀取請求後，依 **Modbus 暫存器 Big Endian**（高位元組在前）及 **IEEE 754 Float32** 格式，將內部儲存的 **5,000.0 公升 (Float32)** 數據，包裝為 **4 bytes** 回傳。

```
RX: 01 04 04 45 9C 40 00 1F 66
```

* 從站地址 = 01
* 功能碼 = 04
* 位元組數 = 04（4 bytes）
* 數據內容 = 45 9C 40 00
* CRC 校驗碼 = 1F 66

**數據解析與換算（還原為十進位）**

**步驟 A：排列數據**\
由於設備採用 **Big Endian** 格式，最高位元組在前，因此 4 個 bytes 依收到順序組合為：\
`459C4000₁₆`

**步驟 B：解析 Float32 結構（S=符號、E=指數、M=尾數）**\
將 `459C4000₁₆` 轉換為 32-bit 二進位數，以進行 IEEE 754 Float32 解析。

* **S（符號位元）** = 0（1 bit）→ 0 代表正數
* **E（指數位元）** = `10001011`（8 bit）→ 139₁₀\
  實際指數 = 139 − 127 = **12**
* **M（尾數位元）** = `001110001...`（23 bit）→ 有效位為 **1.M**

**步驟 C：計算數值**

依 IEEE 754 Float32 格式計算如下。\
指數位元 `10001011₂` 等於 139₁₀，故實際指數為 139 − 127 = 12。

* 尾數位元為 00111000100000000000000，有效位為 1.001110001...

將二進位小數點右移 12 位後換算為十進位：

數值 = 2¹²+2⁹+2⁸+2⁷+2³\
\= 4096+512+256+128+8\
\= 5000.0

因此，Modbus 回覆數據 `01 04 04 45 9C 40 00 1F 66` 代表累積流量為 **5000.0 公升**。

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.lorric.com/qr/fp-as510-paddle-wheel-flowmeter-manual-chinese-v2/communication/rs485-setup.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
