Date : September 08, 2021
Hey, this is Shaunak !
In this blog, I will demonstrate and explain the Modbus RTU Function Subset Implementation in Texas Instruments (TI) Stellaris Launchpad. It has LM4F120H5QR Arm Cortex M Microcontroller.
Click/Tap Here to get the resources like SDK, IDE for the Development Kit. Kindly download the "StellarisWare and Code Composer Studio for the Stellaris LM4F120 LaunchPad" from the list given in the link.
Click/Tap Here to download the LM Flash Programmer.
The motive to accomplish this project was to test the generic Modbus Function Subset C Library that I have created. I had already tested it on Cypress PSoC5. Click/Tap Here to go through the blog.
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 LM4F120H5QR 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 LM4F120H5QR which can be taken as reference.
I have used the Code Composer Studio v5 IDE for the development of the project.
Click/Tap Here to download the entire project.
Here is video explaining how the system works :