MicroTBX-Modbus 0.9.0 release notes

Towards the end of last week, I created the first public release of the Modbus communication stack, build on top of the MicroTBX microcontroller toolbox. Wait..Modbus? Isn’t that that old communication protocol, the one that nobody uses anymore? Well, that’s what I thought too. Turns out I was wrong.

Brief overview of the MicroTBX-Modbus release version 0.9.0 including download link.

True, the first version of the Modbus communication protocol dates back all the way to the late 70s. Yet it’s still updated and actively used. Not just for connecting industrial devices. It’s also a great protocol for internal communication on PCBs with more than one microcontroller, to name just one alternative use case.

Why another Modbus stack

Over the past decade I completed numerous OpenBLT based bootloader projects for clients in a wide variety of industries. All these years shared a common thread: The request for firmware updates via Modbus, specifically RTU. Consequently, I created several customized bootloader solutions for specifically that. It works quite well. To the point that I plan on merging this functionality in the publicly available OpenBLT bootloader in the not too distant future.

As a part of this effort, I plan on including demo programs for at least one microcontroller board, to show-case how to perform firmware updates via Modbus-RTU. My intention is to add a fully functional Modbus communication stack to the demo user program. That way you yourself have everything you need to use it as a foundation or reference for your firmware development effort. Looking at available Modbus stacks, I ran into a roadblock. It turns out the existing ones all seem to be limiting on at least one front:

  • No multi-channel support.
  • Not including both client and server functionality.
  • Not being able to add support for additional and custom function codes.
  • Skipping features needed for protocol compliance.
  • No open source option.
  • Not actively maintained.

With this in mind, the idea was born to develop MicroTBX-Modbus: a Modbus communication stack, which addresses all the above mentioned shortcomings.

What is it

MicroTBX-Modbus is a modern Modbus communication stack, targeting microcontroller based embedded systems. Its aim is to be: easy to use, easy to port, high quality, well maintained, stable and flexible.

Feature overview

  • Carefully crafted application programming interface (API), focusing on ease of use.
  • Written in the C programming language (C99) with high MISRA compliance.
  • Supports both Modbus client and Modbus server functionality.
  • Supports multi channel for both the Modbus client and server.
  • Open source with a flexible dual licensing model.
  • Designed such that it can be used with and without and RTOS.
  • Easy to integrate into existing software projects, especially when using CMake.
  • Includes C++ wrappers for those preferring to develop in an object-oriented manner.
  • Quick and simple to adjust to your microcontroller system.
  • No compile-time configuration needed.
  • Option to implement additional and custom Modbus function codes.

Supported function codes

MicroTBX-Modbus currently supports the following Modbus function codes:

Function CodeName
1Read Coils
2Read Discrete Inputs
3Read Holding Registers
4Read Input Registers
5Write Single Coil
6Write Single Register
8Diagnostics (sub codes: 0, 10, 11, 12, 13, 14, 15)
15Write Multiple Coils
16Write Multiple Registers

Note that MicroTBX-Modbus includes functionality, enabling you to extend it by adding support for additional and custom function codes.

Who is it for

Any embedded software engineer tasked with adding Modbus communication support to their microcontroller based product. Thanks to the flexible dual licensing model, you can start out right away with the open source GPLv3 version. Perfect for testing, evaluation and prototyping purposes. Once you’re satisfied with it and would like to include MicroTBX-Modbus in your proprietary closed sourced product, you can move on to the commercial license.

Where can it be used

MicroTBX-Modbus is easy to port and runs on pretty much any microcontroller with at least 10 KiB of flash and 1.5 KiB of RAM. Although then you run out of storage space quickly, when adding your own firmware’s functionality. Taking this into consideration, the recommended system requirement is a microcontroller with at least 32 KiB of flash and 4 KiB of RAM. While developing, I tested with a 32-bit STM32 Cortex-M based microcontroller as well as with a classic 8-bit ATmega328P based Arduino Uno board.

Where to get it

For those who want to dive in right-away, you can download MicroTBX-Modbus release version 0.9.0 from here:

Alternatively, you can clone it directly from the MicroTBX-Modbus GitHub repository. Note that its layout is such that you can conveniently add it as a Git submodule to your own Git repository. It also includes a CMakelists.txt file for convenient integration as a CMake interface library. You could even make use of FetchContent for automatic downloading and inclusion in your CMake based embedded project.

How to get started

You can find instructions on integrating MicroTBX-Modbus in your own firmware, in the online user manual:

The online user manual features a detailed API reference as well:

You can find demo applications in a separate GitHub repository:

What’s next

By making this first public release, my intention is to start building a user base and collect valuable feedback on what to improve and which features to add. In the mean-time I intend to add unit tests, add more demo programs and process issues and feedback reported by the community. Note that the only real limitation right now is that MicroTBX-Modbus only supports Modbus RTU communication. With enough interest, ASCII and TCP communication support can be added in the future.

Hopefully, reading through this article sparked your interest to take MicroTBX-Modbus for a spin. As with the OpenBLT bootloader, your feedback is always welcome.

This entry was posted in MicroTBX and tagged , , . Bookmark the permalink.