What is it good for?
The project delivers configurable board support code for selected targets, and docs. Besides its modest size, the TG9541/STM8EF code has a long feature list. Using the code for embedded control applications is subject to new projects.
The code on GitHub can be used in many ways:
- for writing alternative firmware Chinese commodity boards (e.g. thermostats, DCDC converters, or relay boards)
- for embedded systems with an interactive shell (scriptable and extensible)
- for creating smart SPI, I2C, or RS232 smart sensors with 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 :-)
Right now, the W1209 is my favorite 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 for communicating, or for sensing. What if you need sensing and communication at the same time? Maybe the "update connector" can be used as a home brew field bus interface? A lot is possible with the right idea, and the right software!
Which target boards are supported?
Besides generic CORE target for STM8S003F3P6, there is currently support for the following boards:
- MINDEV STM8S103F3P6 Breakout Board or similar
- W1209 Thermostat Board (3 7S-LED, 3 keys, relay)
- W1401 Thermostat Board (3x2 7S-LED, 4 keys, relay, buzzer)
- C0135 Relay Board-4 (4 inputs, 1 key, 1 LED, 4 relays)
Read more about likely future targets below.
Again, because it's fun!
- compared to other programming environments the core of Forth is easy to fully understand
- 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 (you can literally program the compiler!)
- the stack-centered "factoring" approach provides implicit data flow which leads to maintainable code
- Interpreter-compiler, basic OS functions fit in just 4K code :-)
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.
A Forth programmer is in control of all levels of problem
abstraction, a unique advantage in a world where layer on layer of 2nd
hand solutions leads to ever growing complexity (compilers, libraries, operating systems,
drivers,frameworks, IDEs... ). I'm convinced that "Thinking Forth" will make anybody a better programmer, not just in the
domain of embedded control!
Why STM8S003F3 or STM8S103F3?
Low-end "STM8S Value Line" STM8 µCs are very cheap (less than $0.25 in hobby quantities, $0.20@100pcs)....Read more »