Date : August 26, 2021
Hey, this is Shaunak !
In this blog, I will demonstrate and explain the Modbus RTU Function Subset Implementation in Cypress PSoC5. I have used the
CY8CKIT-059 PSoC® 5LP Prototyping Kit With Onboard Programmer and Debugger for the project.
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
I have taken 8 bytes of data as coils (total 64), 8 bytes for discrete inputs (total 64), 64 input registers and 64 holding registers. Every input register and holding register occupies 2 bytes of memory.
EEPROM to store the values over power cycle.
A generic Modbus RTU Function subset C Library that can work on other microcontrollers than PSoC5 provided the functionalities of the main.c file are understood and implemented targetting the other microcontroller. For that EEPROM, UART and Timer components of the microcontroller have to be implemented for the project to work. I have given the implementations of these components for PSoC5 which can be taken as reference.
I have used the PSoC Creator 4.4 IDE for the development of the project.
Click/Tap Here to download the entire PSoC5 project.
Here is video explaining how the system works :