What is it?
STM8 eForth is among the smallest user friendly Forth systems for µCs: it brings the simplicity of a 1980s style Forth to today's low-cost controllers. The project provides code for STM8 variants, board support for selected low cost targets, and docs. STM8 eForth has a long feature list but it uses very little memory. Innovative solutions, steady support, and an active community makes using it for new projects easy!
The code and binaries on GitHub can be used in many ways:
- as an alternative firmware for Chinese commodity boards (e.g. thermostats, DCDC converters, and relay boards)
- build embedded systems with an interactive shell (scriptable and extensible)
- for creating smart sensors with SPI, I2C, or RS232 and a scripting shell, e.g. for RaspberryPi, Arduino, or ESP8266
- as an interactive environment for exploring the STM8 architecture
- for learning Forth - it's easy and fun (find out why in the text below!)
Why a Forth for Cheap Chinese boards?
Because it's fun: cheap mass-produced imperfection is a playground for creativity :-)
The W1209 has long been my favourite target: it's a rather complete embedded control board with a UI at a very good price. It's as cheap as it looks, and the challenge is in it's imperfections: the guy who designed the board clearly didn't have a connected application in mind, and I had a lot of fun making it do things it was never intended to do.
There are challenges, like the lack of communication ports. The "sensor connector" can either be used as a a 2-wire RS232 "bus" or for sensing. If you need sensing and communication at the same time the project also provides a full-duplex 3-wire RS232 interface through the key pins (while keeping the keys functional). A plug-in system makes it easy to test new ideas, like using the "update connector" as a home brew field bus interface!
Which target boards are supported?
Besides generic targets for STM8S001, STM8S103, STM8S105, STM8S207 and STM8L051, there is currently support for the following boards:
- MINDEV STM8S103F3P6 Breakout Board
- XH-W1219 (2x3 7S-LED, 3 keys, relay)
- W1209 Thermostat Board (3 7S-LED, 3 keys, relay)
- W1401 Thermostat Board (3x2 7S-LED, 4 keys, relay, buzzer)
- C0135 STM8S103 4 Relay Board for MODBUS
- XH-M194 STM8S105S4 Timer with 6 Relays
- CN2596 DC/DC converter with voltmeter hack
- XH-M188 Linear power supply
Some more boards can be supported on request, e.g.
Read more about possible future targets below.
Again, because it's fun!
Forth starts out as a stack machine with a tiny instruction set and minimal hardware requirements. It fits in a few KiB, and the target, even a lowly µC, can even be used as the development system. The Forth stack machine is a minimalistic VM on a standard CPU, but there are also hardware implementations (e.g. for FPGAs, or a 144 core Forth processor). The VM is ideal for fast context switching and Forth easily meets hard-real-time requirements. It's no surprise that Forth was used in many NASA projects.
- compared to other programming environments Forth is easy to understand fully
- like Lisp, Forth has a REPL (Read-Evaluate-Print-Loop) which enables software testing in a way impossible with "Edit-Compile-Run-Debug" (e.g. Arduino)
- it's easy to build Domain Specific Languages (one can literally program the compiler!)
- the stack-oriented "factoring" method results in implicit data flow and modular code
- Interpreter-compiler, basic OS functions fit in just 4K code :-)
A Forth programmer is in control of all levels of problem abstraction, a unique advantage in a...Read more »