Remember the times when home computers had only a BASIC interpreter?
You can have this feeling back, combined with the speed of a modern microcontroller by using StickOS.
The link is here:
What is it?
It’s not only a basic interpreter with a serial terminal user interface, it’s an embedded programming environment with editor, transparent BASIC compiler, debugger, profiler, flash filesystem, communication interfaces, USB client and host,
analog I/O, servo control, interrupts, timers, etc.
It has tons of nice features, like direct pin manipulation, I2C and SPI routines, firmware update via terminal, support for ZigBee modules, etc.
Supported micros are Freescale 8, 16 and 32 bit variants and PIC32.
Here you can see my PIC32 board that runs StickOS:
Up to now nothing more than the micro on a converter board, a USB connector for power and communication, a 3.3V regulator, and a heartbeat LED.
The interesting things happen inside.
When you connect it to a computer’s USB, it enumerates as a virtual serial port (CDC).
Linux and MacOS should detect it immediately, Windows needs an .inf file that you can download from the StickOS site.
Once connected, you should see this welcome message (after pressing enter):
Welcome to StickOS for Microchip PIC32MXx-F512L v1.80c!
Copyright (c) 2008-2010; all rights reserved.
The ‘help’ command gives a first overview about the possibilities:
for more information:
Let’s have a look at the ‘pins’ command:
Heartbeat maps the heartbeat LED. When StickOS is in idle mode, it blinks slowly, when a program is running, it blinks faster.
Now lets remap it to something else:
pins heartbeat ra0
The LED on re0 stops blinking. This setting is permanent, The micro remembers it even if power is removed.
Now let’s do some pin manipulation:
> dim led as pin re0 for digital output
> let led = 1
The LED is lit!
> let led = 0
LED is off!
The interesting thing is, if you turn off the terminal prompt (‘modes prompt off’), you can use the StickOS board as a USB I/O board for your PC, just by sending BASIC commands and getting the results back.
Even using the SPI, I2C, driving servos, measuring voltages, manipulating controller registers is possible!
Let’s now write some code. The unavoidable blink program.
> 10 dim led as pin re0 for digital output
> 20 while 1 do
> 30 let led = 1
> 40 sleep 100 ms
> 50 let led = 0
> 60 sleep 600 ms
> 70 endwhile
> save blink
Beautiful, isn’t it? Those were the days…
The “save” command saves the program to the internal flash of the micro.
You can list the saved programs by typing ‘dir’ and load one of them with ‘load ‘.
One word about speed.
One may think that BASIC is necessarily slow.
It isn’t. This is a BASIC compiler that feels like a BASIC interpreter, and the PIC32 is damn fast.
I’m pretty sure that a PIC32 with StickOS outperforms most 8 and 16 bit micros with native code.
Also, PIC32 micros are surprisingly cheap, so there’s no need to buy 8 bit micros anymore, especially not for the hobbyist.
I think that StickOS is a very good thing. It’s easy enough for beginners and it’s powerful enough for pretty things that you would otherwise use an arduino or another 8/16 bit micro for.
BTW: This board is also compatible to Pinguino / Chipkit(TM).