Modbus Server Demo
Overview
RAPIDSEA supports Modbus protocol as explained in the Modbus protocol page. This stack will be used by the customer according to their custom logic. This stack contains serial configuration and IP configuration.
The below diagram captures the high level flow of Modbus server

Function |
Description |
---|---|
Read Coil Status (0x01) response |
The coil status response message packed as one bit for one coil ( 1 -on and 0- off) of the digital outputs according to the client starting address |
Read Input Status (0x02) response |
The input status response message packed as one bit for one register ( 1 -on and 0- off) of the digital inputs according to the client starting address. |
Read Holding Register (0x03) response |
The Holding register response message packed as two bytes (high and low bytes ) for one register of the analog outputs according to the client starting address. |
Read Input Register (0x04) response |
The input register response message packed as two bytes (high and low bytes ) for one register of the analog inputs according to the client starting address |
Write Single Coil (0x05) response |
The single coil response message is simply as the echo of the request. If the request has FF00H forces the coil to be turned on and 0000H forces the coil to be turned off. |
Write Single Holding (0x06) response |
The single holding register response message is packed as simply as the echo of the request. The value to be written is packed as two bytes (high and low). |
Write Multiple Coil (0x0F) response |
The multiple coils message response is packed as no of coils to be written ( high and low bytes) of the digital output. |
Write Multiple Holding (0x10) response |
The multiple holding message response is packed as no of registers to be written ( high and low bytes) of the analog output. |
Modbus Running Example
Refer to the Supported Platforms page to setup your environmental setup and follow further.
Modbus smart meter demo running example in modbus server application
Register Address |
Size |
R/W |
Variable name |
Data type |
Value/range |
Functionality |
---|---|---|---|---|---|---|
03001 |
1 bit |
RW |
Cut-off Phase 1 |
uint8 |
0 to 1 |
I1 stops incrementing |
03002 |
1 bit |
RW |
Cut-off Phase 2 |
uint8 |
0 to 1 |
I2 stops incrementing |
03003 |
1 bit |
RW |
Cut-off Phase 3 |
uint8 |
0 to 1 |
I3 stops incrementing |
03004 |
1 bit |
RW |
Reset Monthly Consumption |
uint8 |
0 to 1 |
Reset the monthly consumption to 0 |
14001 |
1 bit |
R |
Current1 Alarm Level |
uint8 |
0 to 1 |
Indicate current1 alarm level status |
14002 |
1 bit |
R |
Current2 Alarm Level |
uint8 |
0 to 1 |
Indicate current2 alarm level status |
14003 |
1 bit |
R |
Current3 Alarm Level |
uint8 |
0 to 1 |
Indicate current3 alarm level status |
31001-31008 |
16 |
R |
Meter Name |
UTF8 |
“RAPIDSEA EM” |
Manufacturer Name |
31009-31010 |
4 |
R |
Serial Number |
uint32 |
0x10203199 |
Serial number of the meter |
31011 |
2 |
R |
Number of Phases |
uint16 |
0x3 |
Number of Phases |
31012-31013 |
4 |
R |
I1 Current |
float32 |
0 to 5.5 |
Rolls from 0 to 5.5 at a rate of 0.1 per second |
31014-31015 |
4 |
R |
I2 Current |
float32 |
0 to 5.5 |
Rolls from 0 to 5.5 at a rate of 0.23 per second |
31016-31017 |
4 |
R |
I3 Current |
float32 |
0 to 5.5 |
Rolls from 0 to 5.5 at a rate of 0.08 per second |
42001-42002 |
4 |
RW |
I1 Alarm Level |
float32 |
0.0 to 5.5 |
Raises alarm in Current1 Alarm level register |
42003-42004 |
4 |
RW |
I2 Alarm Level |
float32 |
0.0 to 5.5 |
Raises alarm in Current2 Alarm level register. |
42005-42006 |
4 |
RW |
I3 Alarm Level |
float32 |
0.0 to 5.5 |
Raises alarm in Current3 Alarm level register. |
42007-42008 |
4 |
RW |
Baud Rate |
uint32 |
9600/14400/19200/38400/57600/115200 |
Serial Configuration of Baud-rate |
42009 |
2 |
RW |
Parity |
int16 |
N(0)/O(-1) /E(1) |
Serial Configuration of parity |
42010 |
2 |
RW |
Slave Address |
uint16 |
1 to 255 |
Modbus Slave Address |
42011-42018 |
16 |
RW |
Phase Name |
UTF8 |
Default value : “RAPIDSEA PHASE1” |
Phase1 Name |
42019-42022 |
8 |
RW |
Tariff Rate |
double |
0.0 to 5.5 |
Cost Per Energy Unit |
42023-42024 |
4 |
RW |
Monthly Consumption |
int32 |
Default value : -10. Range -10 to 10 |
Net Energy consumption. Increments 1 per 10 seconds |
42025-42028 |
8 |
R |
Cost |
uint64 |
eg: ( 1.1(Tariff rate) * -10 (Consumption)) |
Product of Tariff rate and Monthly Consumption |
The above table can be accessed by following registers with address ranges.
- Note:
In the Modbus server demo application (Energy Meter Demo), 500 registers were added from starting address of 2100 to 2600 to confirm the maximum register test validity for read-holding registers.An Exception occurs (Invalid data address) when try to write to the holding register of the specified address (2100 to 2600)
In the Modbus server demo application (Energy Meter Demo), 2500 registers were added from starting address of 2100 to 4600 to confirm the maximum register test validity for read-coil registers.An Exception occurs (Invalid data address) when try to write to the coil register of the specified address (2100 to 4600)
In Modbus Server Demo, if you read or write any register value (e.g., the I2 Alarm Level value), it must be read or written in the whole register set (e.g., 42003–42004). (Don’t read or write separately.)
Register Type |
Address Range |
---|---|
Coil Registers |
(03001 to 03004) |
Discrete Registers |
(14001 to 14003) |
Input Registers |
(31001 to 31017) |
Holding Registers |
(42001 to 42028) |
Error Name |
Error Code |
---|---|
Invalid Function Code |
1 |
Invalid Data Address |
2 |
Invalid Data Value |
3 |
User Configuration of server in RTU
Serial Configuration |
Values |
---|---|
COM PORT (Windows) USB PORT(Linux) |
COM1 , COM5 …(Windows) /dev/ttyUSB1 (Linux) |
BAUDRATE |
9600 , 115200, …. |
User Configuration of server in TCP
socket Configuration |
Values |
---|---|
IP (windows /Linux) |
192.168.29.39 ,… |
Port |
10,502, …. |
