Skip to content

DevHeadsCommunity/modbusSlave

MODBUS RTU SLAVE Firmware Implementation on STM32 MCU

Watch the full implementation on Devhead's YouTube channel and see it in action:
🔗 live Demo


Table of Contents


🔍 OVERVIEW

  • Modbus is an open standard
  • Simple data representation, works in request-response command structure
  • Standard transport, Modbus RTU commands are simple
  • It uses RS485, a differential communication (support 32 nodes in multi-drop configuration)
  • RS485 provides noise immunity better than RS232 electrical standard
  • It requires very little code space, with that developing automation app possible

image


📐 AVAILABLE STANDARDS

image


🧠 MODBUS MEMORY AREAS

Memory Area Type Address Range Description
Coils Discrete output 00001–09999 Valves, actuators on/off
Inputs Discrete input 10001–19999 Switches
Input Registers Analog input 30001–39999 Connect sensor temp, etc.
Holding Registers Analog output 40001–49999 Control devices, VFD

🧰 CONNECTION DETAILS

image


🧾 RTU FRAME FORMAT

MODBUS SERIAL LINE PROTOCOL DATA UNIT (PDU)

SLAVE ADDRESS | FUNCTION CODE | DATA | CRC
1 Byte        | 1 Byte        | 0–252 Bytes | 2 Bytes (CRC low | CRC high)

🔢 FUNCTION CODES

Function Code Action Table Name
01 (0x01) Read Discrete Output Coils
05 (0x05) Write single Discrete Output Coils
15 (0x0F) Write multiple Discrete Output Coils
02 (0x02) Read Discrete Input Contacts
04 (0x04) Read Analog Input Register
03 (0x03) Read Analog Output Holding Registers
06 (0x06) Write single Analog Output Holding Registers
16 (0x10) Write multiple Analog Output Holding Registers

live DEMO

Watch the full implementation on Devhead's YouTube channel and see it in action:
🔗 live Demo


🤝 THANK YOU

Thanks for being a DevHead!
Join our community: https://discord.gg/DevHeads

About

This project demonstrate how to make STM32F303K8 Nucleo board as Modbus RTU Slave Device

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages