> 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/modbus-rtu-protocol/du-xie-xing-ji-yi-ti/read-write-memory-read-instruction-03.md).

# 讀寫型記憶體讀取指令(03)

{% hint style="info" %}
當數值較大時，若分別以不同資料格式（例如 float32 或 int64）進行讀取與換算，因內部計算方式不同，可能會出現非常小的差異，通常小於 1/10,000，屬於正常現象。

不同參數大分類不能跨區讀取，讀取指令中register長度必需小於等於 20個 register。超過該長度的指令會被忽略。
{% endhint %}

### Function Code 功能碼 03

讀寫型記憶體 讀取指令，功能碼 (Function Code) 03 ，數據長度為1\~125 個暫存器。可讀取單個或多個保持暫存器，用於讀取設備中定義之保持暫存器（Holding Registers）內的設定參數。

### 讀寫型記憶體-控制端發指令(03)格式

請參考唯讀型記憶體–讀取指令(04)頁面中相同的 TX/RX 訊框格式說明，本指令仅功能碼不同（03）。

### Modbus RTU 讀取讀寫型記憶體保持暫存器 (03) 範例

以主站使用功能碼 03 一起讀取 **A01 三通管（Pipe Type）** 與 **A02 比例係數（Scale Factor）** 為例：

依據讀寫型記憶體列表，起始位址為 **00 00**，暫存器長度為 3（先讀 A01 三通管 — 1 個暫存器，接著讀 A02 比例係數 — 2 個暫存器，Float32），位元組順序為 **Big Endian**。

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

```
TX: 01 03 00 00 00 03 05 CB
```

* 從站地址 = 01
* 功能碼 = 03
* 起始暫存器位址 = 00 00（A01 三通管的起始位址）
* 讀取暫存器數量 = 00 03（從 00 00 開始讀取 3 個暫存器）
* CRC 校驗碼 = 05 CB（依 CRC 算法計算出的糠錯碼）

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

```
RX: 01 03 06 00 00 3F 80 00 00 2C 89
```

* 從站地址 = 01
* 功能碼 = 03
* 回覆的 Byte 數 = 06（3 個暫存器 = 6 bytes）
* 數據內容：
  * `00 00` — A01 三通管 = 選項代碼 0（具體代表的選項請參考下方 A01 頁面）
  * `3F 80 00 00` — A02 比例係數（Float32）= 1.0
* CRC 校驗碼 = 2C 89（依 CRC 算法計算出的糠錯碼）

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

#### **步驟 A** – 排列數據

* 收到的數據：0000
* 資料類型：Int16（16 位整數）

#### **步驟 B – 換算為十進位並對應選項**

* 將十六進位數值 0000 轉換為十進位：\
  十進位計算：(0 × 256) + 0 = 0\
  最終數值：0
* 選項對應：完整選項列表請參考 A01 三通管 頁面。

### 常見問題

* **為什麼「記憶體列表」與「PLC 讀取位置」會有差異？**

使用者可能遇到以下情況：記憶體列表位置為 40005，但在 PLC 端需填入 4（或顯示為 0004）才能讀到需求數值。

這是因為Modbus 位址表示方式的特性，根據Modbus定義，人看的位址（文件/記憶體表）與設備實際讀取的位址（通訊位置）兩者中間會存在一個「偏移量 offset」。

功能碼03的邏輯為：將「40001」作為基底，讀取時，從這裡開始計數，40001 代表第 1 個寄存器，偏移量是0000，讀取位置是0000。

因此當文件標示要讀取 40005 時，對應的 Modbus 功能碼 03 封包中的 實際起始位址為 0004，也就是：**實際通訊位址 = 文件位址 − 40001。**\
\
**較大位址範例：**\
文件位址 40514（C02 清除累積）→ 40514 − 40001 = **513（10 進位）** → 轉換為 Hex：**0x0201** → 報文位址 byte 為 **02 01**。

完整的 10 進位／主站位址對照，請參考已更新的讀寫型記憶體列表。

{% hint style="info" %}
註：Modbus 協定本身規範採 0-based addressing（實際通訊封包會從 0 開始編號），因此理論通則為：「實際通訊位址 = 文件位址−40001」。

不過，若客戶端使用的 PLC 或 HMI 軟體 有特別設定為 1-based addressing（軟體自動將位址加 1），此時就需依照軟體的位址規則來填入起始位址，讀取暫存器數據。
{% endhint %}


---

# 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/modbus-rtu-protocol/du-xie-xing-ji-yi-ti/read-write-memory-read-instruction-03.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.
