Skip to content
Thomas edited this page May 2, 2020 · 6 revisions

stm8ef-modbus

The Wiki documents properties and application of a lightweight MODBUS implementation in STM8 eForth. A binary for the C0135 4-Relay-Board is provided. For using this firmware no knowledge of Forth is required. Instead it provides powerful features that can be used to jump-start Forth programming!

The MODBUS implementation covers basic FCs and implements a subset of MODBUS V1.1b that can be used to create simple MODBUS servers (e.g. 2-chip sensor nodes, I/O boards etc).

Using STM8 Forth for MODBUS has many advantages: while the implementation is extraordinarily compact it gives applications access to features like independent I/O-logic execution in the background, an on-line interpreter, interactive debugging or on-line compilation of control logic.

Supported MODBUS Function Codes

MBSERVER contains MODBUS function plug-ins with the following function codes (FC):

FC Description Support
1 Read Coils implemented
2 Read Discrete Inputs implemented
3 Read Holding Registers implemented
4 Read Input Registers implemented
5 Write Single Coil implemented
6 Write Single (Holding) Register implemented
15 Write Multiple Coils implemented
16 Write Multiple Registers implemented

Architecture

The architecture is "layered" and very simple:

Layer Source file Description
5 C0135/board.fs or main.fs configuration and application layer
4 MBSERVER MODBUS FC plug-ins
3 MBPROTO MODBUS protocol layer with FC plug-ins and action hooks (mbpre, mbact)
2 UARTISR buffered UART communication
1 BUSCTRL bus access (i.e. RS485 direction control)
0 STM8 eForth lightweight interactive multi-tasking OS with interpreter and compiler
Clone this wiki locally