Modbus Protocol
The Modbus communication protocol is a serial communication protocol. The Modbus protocol does not define the physical layer. Instead it uses RS-232C compatible serial interfaces, which are very common on microcontrollers.
Check out the Mobicon Modbus Protocol Reference Guide for detailed info. Another good tutorial is Lammert Bies’ Modbus interface.
Terminology
- Coil: Discrete output (e.g. digital GPIO output pin on microcontroller)
 - Holding register: Internal, two-byte wide digital register that are used for storing values
 
ASCII Framing
Messages start with a colon (:) and end with a carriage return-line feed pair (CR-LF). Each byte of data between is sent as ASCII-encoded HEX (0-9, A-F).
Function Codes
The common function codes are shown in the below table.
| Code | Description | 
|---|---|
| 01 | Read coil status | 
| 02 | Read input status | 
| 03 | Read holding registers | 
| 04 | Read input registers | 
| 05 | Force single coil | 
| 06 | Preset single register | 
| 07 | Read exception status | 
| 15 | Force multiple coils | 
| 16 | Preset multiple registers | 
| 17 | Report slave ID | 
Software
FreeMODBUS - A Modbus ASCII/RTU and TCP implementation: Software targeted at embedded platforms.
free-dotnet-modbus: A free .NET implementation of the Modbus protocol.
ModNet: Free Windows-based Modbus protocol client, which checks Modbus RTU compliance.