MODBUS Slave Protocol: Difference between revisions
mNo edit summary |
|||
| Line 3: | Line 3: | ||
== Basic == | == Basic == | ||
=== | === MODBUS Communication === | ||
The | The MODBUS is a protocol, which is used to communicate between a host and one or multiple slave devices. Over the Modbus the host is able to communicate with up to 254 slaves. It can read or write data areas on these devices. The SMART LCD is operated as such a slave device. There are mainly two modes of communication: The binary RTU Mode and the ASCII Mode. The SMART LCD is operating in RTU Mode. Therefore, we only describe the RTU mode within this document. | ||
The host issues a package, which consists of: | The host issues a package, which consists of: | ||
| Line 31: | Line 31: | ||
When the host receives the previous frame reply from the slave device, the host needs an interval of 5ms before it can continue to send the next frame command. Since the SMART LCD is a Modbus slave device, a device address must be assigned to it. This address will be defined while designing the GUI with TOPWAY’s SGTools. | When the host receives the previous frame reply from the slave device, the host needs an interval of 5ms before it can continue to send the next frame command. Since the SMART LCD is a Modbus slave device, a device address must be assigned to it. This address will be defined while designing the GUI with TOPWAY’s SGTools. | ||
=== | === MODBUS Function Codes === | ||
{| class="wikitable" | {| class="wikitable" | ||
|'''Function Code''' | |'''MODBUS Function Code''' | ||
|'''Function Definition''' | |'''Function Definition''' | ||
|'''Address Range''' | |'''Address Range''' | ||
| Line 122: | Line 122: | ||
|} | |} | ||
=== | === Accessing the Smart LCD === | ||
To access data the host should do following steps using the Modbus protocol: | To access data the host should do following steps using the Modbus protocol: | ||
| Line 136: | Line 136: | ||
* Bitmap, one access can manipulate 16 pixels of a bitmap variable. Multiple pixels might be accessed with a single Modbus command. | * Bitmap, one access can manipulate 16 pixels of a bitmap variable. Multiple pixels might be accessed with a single Modbus command. | ||
* Graph, one access can manipulate one data point of a graph. Multiple data points might be accessed with a single Modbus command. | * Graph, one access can manipulate one data point of a graph. Multiple data points might be accessed with a single Modbus command. | ||
Revision as of 19:03, 13 June 2025
Smart LCD MODBUS Salve Product can be accessed by MODBUS Master devices for real-time control and access.
Basic
MODBUS Communication
The MODBUS is a protocol, which is used to communicate between a host and one or multiple slave devices. Over the Modbus the host is able to communicate with up to 254 slaves. It can read or write data areas on these devices. The SMART LCD is operated as such a slave device. There are mainly two modes of communication: The binary RTU Mode and the ASCII Mode. The SMART LCD is operating in RTU Mode. Therefore, we only describe the RTU mode within this document.
The host issues a package, which consists of:
- An 8 Bit Device Address, to indicate which slave device shall be addressed
- An 8 Bit Function Code, to tell the addressed slave which data area is read or written
- Specific data, like addresses and data values
- A 2-Byte Error Check CRC to determine, whether the previous data are correct
| < - - - - - - - - - - - - - - - - - - - - MODBUS Package - - - - - - - - - - - - - - - - - - - - > | |||
|---|---|---|---|
Device Address (1byte) |
Function (1byte) |
Data (252bytes(max.)) |
Error Check (2bytes) |
| < - - - - - - - - - - MODBUS Frame - - - - - - - - - - > | |||
When the host receives the previous frame reply from the slave device, the host needs an interval of 5ms before it can continue to send the next frame command. Since the SMART LCD is a Modbus slave device, a device address must be assigned to it. This address will be defined while designing the GUI with TOPWAY’s SGTools.
MODBUS Function Codes
| MODBUS Function Code | Function Definition | Address Range | Object Type |
| 0x03 | Read Multiple Holding Registers | 0x0000 ~ 0xFFFF | 2 Bytes |
| 0x06 | Write Single Holding Register | 0x0000 ~ 0xFFFF | 2 Bytes |
| 0x10 | Write Multiple Holding Registers | 0x0000 ~ 0xFFFF | 2 Bytes |
| 0x11 | Report Slave ID | ||
| 0x14 | Read File Record | 1 File with 2048 Records of 128 Byte | |
Address Mapping
To access memory locations in the SMART LCD the host has to issue a Read or Write function, which includes a specific address. Each Read or Write function accesses a 2-Byte location within an area of up to 64k words. Since the multiple data areas (N16, N32, N64, etc.) are together larger than 64k Words, the different memory areas are separated into pages. To select a specific page the Modbus Page Map Register must be written with the page number. The Page Map Register is located within the set of Special Function Registers. The Special Function Registers (SFR) are accessible on all pages at the same location. They are placed within the final 4k words of all pages.
In SGTools, MENU --> View --> Show Modbus Holding Register Address can show up the VPs corresponding MODBUS ADDRESS for the display UI.
The following table show relationship between Modbus addresses, Modbus Memory Pages and the SMART LCD VP variable
| VP type | SMART LCD VP Address | Modbus PAGE: Address | note |
| VP_STR | 0x000000, 0x000080 - 0x01DF80 | 0:0x0000, 0:0x0040 - 0:0xEFC0 | |
| VP_N32 | 0x020000, 0x020004 - 0x02FFBC | 1:0x0000, 1:0x0002 - 1:0x7FDE | |
| VP_N64 | 0x030000, 0x030008 - 0x03DFF8 | 6:0x8000, 6:0x8004 - 6:0x7FFC | |
| VP_N16 | 0x080000, 0x080002 - 0x08FFFE | 4:0x0000, 4:0x0001 - 4:0x7FFF | |
| -- | -- | 4:0x8000 - 4:0xEFFF | Reserved |
| VP_BMP | 0x040000 - 0x05DFFE | 2:0x0000 - 2:0xEFFF | |
| VP_G16 | 0x060000 - 0x07DFFE | 3:0x0000 - 3:0xEFFF | |
| VP_Flash | 120K Bytes Flash memory | 5:0x0000 - 5:0xEFFF | remain unchanged even after power down |
| VP_REG | 0xFFF000 - 0xFFFFFF | n:0xF000 - n:0xFFFF | Special Function Register can be access with n=0,1,2,3,4,5 |
Accessing the Smart LCD
To access data the host should do following steps using the Modbus protocol:
- Use “Write Single Holding Register” with function code (0x06) to address 0xF001 and the data value of the desired memory page (0x01 … 0x05)
- Write to or read from the desired address within the selected page with: “Read Multiple Holding Registers” with function code (0x03) “Write Single Holding Register” with function code (0x06) "Write Multiple Holding Registers” with function code (0x10)
Each Modbus address holds 16 Bit of data. Therefore, it might be necessary to read multiple address locations:
- STR, up to 64 consecutive accesses might be necessary to read an entire string, One single access will manipulate two characters.
- N16, just one access is necessary to access one N16 variable. Multiple N16 variables might be accessed with a single Modbus command.
- N32, two accesses are necessary to access one N32 variable. Multiple N32 variables might be accessed with a single Modbus command.
- N64, four accesses are necessary to access one N64 variable. Multiple N64 variables might be accessed with a single Modbus command.
- Bitmap, one access can manipulate 16 pixels of a bitmap variable. Multiple pixels might be accessed with a single Modbus command.
- Graph, one access can manipulate one data point of a graph. Multiple data points might be accessed with a single Modbus command.
“Read Multiple Holding Registers” with function code (0x03) allows accessing of up to 125 consecutive address locations at once, with each location holding two Bytes of data.
“Write Multiple Holding Registers” with function code (0x10) allows accessing of up to 123 consecutive address locations at once, with each location holding two Bytes of data.
Access to the Special Function Registers, which are mapped to all pages, should not exceed the required Byte count assigned to each SFR. In such a case the SMART LCD would reply the host with an error message.
Note: Since the Modbus protocol uses a “Big-Endian” representation of data, the first Byte of each 16 Bit word represents the upper 8 Bit of the data word. In contrary the memory organization of the SMART LCD is “Little-Endian” requiring the host to swap upper and lower Byte of each transaction.

