Education is the most powerful weapon you can use to change the world.
Unless you've been living under a rock since the late '70's, you've probably heard about
Modbus, the communications protocol used
for a wide variety of industrial systems, from
programmable logic controllers(PLCs).
Modbus can be found in most factories and automated assembly lines.
Modbus devices can be quite complicated; but what if we used
an embedded Device Tree to describe them?
That would enable the automatic discovery and configuration
of Modbus devices and peripherals, wouldn't it?
ModbusModbus is a communications protocol developed by Schneider Electric (nee Modicon) in the 1970's. Simple to implement, and robust in operation, it is used by a wide variety of manufacturers. Modbus is often associated with supervisory and data acquisition (SCADA) systems for process control. Manufacturing, power generation, refining, waste treatment plants, you name it, and you are likely to find Modbus devices installed there.
Modbus AddressingModbus has four (4) independent address spaces, and utilizes different Function Codes, or commands, to access each one of those address spaces. The age of Modbus starts to show when you look at the name of the first address space, namely "Coils". Yup, "Coils", that's what they used to call bits back in the electromechanical dark ages, when a bit was literally a single coil turning on or off! The second address space is known as the "Discrete Inputs" space, and it is typically used to read to read the state of individual switches on a device. The largest address space is called the "Holding Register" address space, and it is typically used for device control registers. Lastly, is the "Input Register" address space, typically used for reading multibit values, like an Analog-to-Digital converter output. Modbus has decently large address spaces, which is one of the reasons it has survived as a standard for over forty(40) years, it was designed to grow as needed.
Modbus Addressing with Device TreeOne technique that I have successfully used in the past, is locating a Binary Level OBject (i.e. BLOB) within one of the address spaces of the Modbus Device, typically in the Holding Register Address Space starting at address offset zero (0x0000). I have done this many times in the past using an IPMI FRU : (Intelligent Peripheral Management Interface - Field Replaceable Unit) data structure definition, but it is just as simple to implement using the Device Tree data structure definition. At a minimum, the Device Tree data structure can identify the make and model number of the Modbus device. However, using Device Tree Overlays with more detailed device and register descriptions, it is feasible to embed the entire description of the Modbus device within the Binary Level OBject (i.e. BLOB).
In the past Modbus devices have usually required a very specific driver for each different make and model number of device, with little or no automatic discovery and configuration of Modbus devices being possible. Technicians would usually need to add each Modbus device to their supervisory and data acquisition (SCADA) systems manually.
SummaryAdding the Device Tree data structure to Modbus devices is pretty straightforward and simple, and enables the automatic discovery and configuration of Modbus devices and peripherals.
References, Footnotes, and more...
- Modbus Specifications
- Device Tree for Dummies - Thomas Petroni
- BeagleBlack Device Tree Tutorial - Adafruit
- Xilinx Device Tree Tutorial - Xillybus
- Altera Device Tree Tutorial - Xillybus
- ARM Device Tree Support - Ubuntu
- Altera Device Tree Support - Altera
- Index of Device Tree Bindings - kernal.org
- Device Tree Graphing - kernal.org
- libfdt - manipulating FDT Blobs - David Gibson
- Linux Bootloaders - informit.com
- Device Tree PnP - Eli Billauer
- Device Tree Overlay Manager - Pantelis Antoniou
- Device Tree Overlay Proposal - Grant Likely
- BeagleBlack Univeral I/O - cdsteinkuehler
- BeagleBlack Device Tree Overlay Generator - Kilobaser
- GPIOs on the Beaglebone Black using the Device Tree Overlays- derek molloy
- Supporting 200 Different Expansion Boards - elinux.org
- DT, The Disaster so Far - Mark Rutland
- Board File to Device Tree Migration - Pantelis Antoniou
- Device Tree Overlays - Jonathon Corbet