Generic Library
for
Microcontroller
as
Modbus RTU Slave
Generic Library
for
Microcontroller
as
Modbus RTU Slave
Date : March 30, 2024
Hey, this is Shaunak !
In this blog, I am carrying forward my previous work on the Modbus RTU Function Subset Implementation based on a Generic Library. I had tested this library on Cypress PSoC5 and TI Stellaris Launchpad Kit. This time I have tested it with Arduino Mega and Uno.
Modbus is a data communication protocol widely used in industries. Click/Tap here to know more about it.
For this project, as a reference, I have referred the following document in order to understand its working :
The project implements 8 Modbus RTU Functions with a dedicated C library that can be used in general. The 8 Modbus Functions are as below :
1. 0x01 : Read Coils
2. 0x02 : Read Discrete Inputs
3. 0x03 : Read Holding Registers
4. 0x04 : Read Input Registers
5. 0x05 : Write Single Coil
6. 0x06 : Write Single Register
7. 0x0F : Write Multiple Coils
8. 0x10 : Write Multiple Registers
The working of all the functions has been tested on a Modbus Master Tool called qModbus.
Download qModbus from Here
Here is a document answering some common questions relevant to this project :
Click/Tap Here to get the Project as above from EmbVerse Github
Here is a video explaining the work in detail :
Note
Once this library is tested with qModbus and is ready to be implemented on field, a UART TTL to RS485 Two-way Converter Module is required because most of the microcontrollers do not support Modbus RS485 layer.