HMI Connection overview · Arduino IDE setup
In Modbus RTU, the HMI sends requests as the Master and the product answers as the Slave. In this SDK, M bits map to Coils and D words map to Holding Registers. Check whether your HMI driver expects 0-based or 1-based numbers before entering an address.
The example on this page uses MPINO-8A4R-S · RS-232 Serial1 · station 1 · 9600 bps · 8N1. See Wiring the HMI for channels and wiring, and Arduino IDE setup for the development environment.
| Screen element | SDK memory | 0-based address in the Modbus request | Operation |
|---|---|---|---|
| Communication check number | D0 | Holding Register 0 | Read with FC03, repeats 0~99 |
| Number input | D1 | Holding Register 1 | Write 0~9999 with FC06/FC16 |
| Returned value | D2 | Holding Register 2 | Read with FC03, same as D1 |
| Test switch and lamp | M0 | Coil 0 | Toggle write with FC05/FC15, read with FC01 |
If your HMI editor uses 1-based or 4xxxx numbers, check the address conversion table. Number format, switch, and lamp settings are covered together in Building the HMI Screen.
This simple example exchanges internal memory values at the addresses above. It does not use any real input or relay output pins.
#include <Arduino.h> unsigned long lastTick = 0; void setup() { ImodbusRTUMem(16, 16); // Communication memory, including M0 and D0~D2 ImodbusRTUAdr(0, 0); // External addresses also start at 0 ImodbusRTUInit(Serial1, 1, 9600); lastTick = millis(); } void loop() { if (M == nullptr || D == nullptr) return; ImodbusRTU(); unsigned long now = millis(); if (now - lastTick >= 1000UL) { lastTick = now; D[0] = (D[0] >= 99) ? 0 : D[0] + 1; } if (D[1] > 9999) D[1] = 9999; D[2] = D[1]; }
ImodbusRTUMem() allocates the memory at startup, and ImodbusRTU() handles HMI requests on every loop.
After uploading the sketch, place the HMI elements using the screen example below and the address table above.
0~2 and Coil 0 to external device elements, then transfer the HMI project.Expected results and where to look for each symptom are listed in Checking Operation and Troubleshooting.