Skip to content

ufnalski/modbus_master_fandf_g474re

Repository files navigation

Modbus master demo (STM32G474RE)

An STM32 HAL example of communicating with an energy meter and a display over the Modbus protocol. Both Modbus devices come from F&F. For the relevant datasheets visit LE-01M and MR-LED-T.

Modbus in action

The main goal for this example is to let you get familiar with the Modbus communication protocol. Here the RTU (Remote Terminal Unit) transmission mode and the RS-485 in the physical layer are used. Reading and writing multiple registers is exercised. The example also encourages you to play with the CRC (Cyclic Redundancy Check) peripheral on STM32 microcontrollers - yes, you don't have to bother the main core to calculate it 🙂

Modbus was introduced in 1979 and is still popular in industrial environments - you will find plenty of devices that use it and a rich selection of monitoring/debugging tools to help you make the system run.

Missing files?

Don't worry 🙂 Just hit Alt-K to generate /Drivers/CMCIS/ and /Drivers/STM32G4xx_HAL_Driver/ based on the .ioc file. After a couple of seconds your project will be ready for building.

Libraries

Exemplary hardware

Selection of tools for monitoring/debugging

Hardware

Software I've played with

Software I haven't played with (yet?)

A communication test with the energy meter:

Communication test with the energy meter

A communication test with the display:

Communication test with the display

Displayed value

IMHO useful gadgets

Readings and videos

RS-485

Modbus

Modbus using STM32 (ControllersTech)

CRC

Modbus CRC:

Modbus CRC

CubeMX CRC peripheral configuration:

CubeMX CRC peripheral configuration

Call for action

Create your own home laboratory/workshop/garage! Get inspired by ControllersTech, DroneBot Workshop, Andreas Spiess, GreatScott!, ElectroBOOM, Phil's Lab, atomic14, That Project, Paul McWhorter, and many other professional hobbyists sharing their awesome projects and tutorials! Shout-out/kudos to all of them!

Warning

Automation and control engineering - do try this at home ❗

190+ challenges to start from: Control Engineering for Hobbyists at the Warsaw University of Technology.

Stay tuned!