Using a highly-integrated microcontroller running “StickOS BASIC”, it is possible to quickly build a toaster oven temperature profile controller for performing surface mount (SMT) printed circuit board reflow soldering at home. It is also possible to program a large variety of other general-purpose embedded system projects with minimal software effort, using only a terminal emulator and high-level BASIC algorithmic statements to manipulate the microcontroller (MCU) pins and peripherals.
1. StickOS Basic
StickOS BASIC is an entirely MCU-resident interactive programming environment, which includes an easy-to-use editor, transparent line-by-line compiler, interactive debugger, performance profiler, and flash filesystem, all controlled thru an interactive command-line user interface. In StickOS, external MCU pins may be mapped to BASIC “pin variables” for manipulation or examination, and internal MCU peripherals may be managed by BASIC control statements and interrupt handlers. A StickOS-capable MCU may be connected to a host computer via a variety of transports and may then be controlled by any terminal emulator program, with no additional software or hardware required on the host computer. Once program development is complete, the MCU may be disconnected from the host computer and configured to autorun its resident BASIC program autonomously.
StickOS runs on a wide variety of highly-integrated MCUs, including BASIC program support for:
- digital input/output
- analog to digital converters
- pulse width modulators (for analog output or servo motor control)
- output compare timers (i.e., frequency generators)
- UARTs and SPI master serial interfaces
- periodic timers
- flash memory (i.e., self-programming)
By its very nature, StickOS supports in-circuit emulation — all you need is a transport connecting the MCU to a host computer, and you have full interactive control over the target embedded system, just as if you were using an in-circuit emulator; alternatively, you can use the 2.4GHz ZigFlea wireless transport and have full control over the target embedded system with no wires at all. With StickOS, it is no longer necessary to install a software development environment on the host computer; likewise, it is no longer necessary to connect any kind of flash programmer or debug hardware to the host computer. More importantly, though, with StickOS it is no longer necessary to study a 500+ page MCU Reference Manual in order to use the MCU external pins and internal peripherals — StickOS manages them all for you.
2. Hello World!
So what does the “Hello world!” program look like in StickOS BASIC? Well, if the baseline goal for an embedded system is to configure an I/O pin and get an LED to blink, such as LED1 on pin “re2” of the PIC32 on the UBW32 Board, then the “Hello world!” program looks like this (entered text is in bold):
> 10 dim led as pin re2 for digital output inverted > 20 while 1 do > 30 let led = !led > 40 sleep 500 ms > 50 endwhile > run STOP at line 40! > _
Line 10 declares a “pin variable” named “led”, then configures the general purpose I/O pin “re2” for inverted (i.e., active-low) digital output, and finally binds the pin variable to the corresponding pin (in traditional BASIC, the “dim” statement is used to “dimension” the shape of a variable prior to use). From then on, any modification of the pin variable is immediately reflected at the I/O pin. Line 20 starts an infinite loop. Line 30 inverts the state of the “re2″ digital output pin to blink the LED. Line 40 delays the program for 500 ms. And finally line 50 ends the infinite loop. Type “run” to start the program; press to stop the program. Of course, if you really just wanted to print “Hello world!” to the terminal, you could just do:
> 10 print "Hello world!" > run Hello world! > _
3. Hello User!
If you want to use a switch, such as the USER switch on pin “re6” of the PIC32 on the UBW32 Board, to condition the blinking of the LED, so that you can push the switch to stop the blinking, in StickOS BASIC it’s nearly as easy:
> 10 dim led as pin re2 for digital output inverted > 20 dim switch as pin re6 for digital input debounced inverted > 30 while 1 do > 40 if !switch then > 50 let led = !led > 60 endif > 70 sleep 500 ms > 80 endwhile > run STOP at line 70! > _
For more Details: Build a Simple Toaster Oven Temperature Profile Controller