This is a ANSI-C portable, small-footprint, serial-line (RTU) client implementation of Modbus for the 8-bit PIC16 family of Microchip microcontrollers, with application limited to holding registries reads/writes.
On a PIC16F1827 device, (with ~7Kb of program memory and 384 bytes of data memory), the library built with the free version of Microchip XC8 compiler, takes roughly 1/4 of the total resources.
- Implements Modbus functions 0x3 and 0x10 (Read/Write Holding Registries) via custom handlers
- Minimal memory, code and stack footprint to cope with lowest specs 8-bit MCUs
- Direct connection to MAX485/MAX3485 level translator, via RX/TX/OE pins
- Leverage hardware USART and timers for accurate protocol timing
- Implement system register (check reset/error codes, CRC errors, etc...)
- Optimized for free XC8 compiler
In addition to the bare library, the folder samples
contains some sample code for simple applications.
More details can be found here.
My current prototype is a small board, made to fit in wall switches, with power regulator (3.3V or 5V), RS-485 adapter, and a micro-switch and LED.
It sports a PIC16F1827
with nine general-purpose I/O ports and bus/supply pins available through a 0.1” header.
More details can be found here.