Home
What if?
Features
MCUs
Examples
Wireless!
Pictures
Downloads
Purchase!
News
Contact Us

StickOS User's Guide

CPUStick User's Guide

Copyright © 2008-2009 CPUStick.com;
all rights reserved.
Patent pending.

  webmaster@cpustick.com

CPUStick™ and StickOS™ -- Examples

A simple embedded system, like a toaster oven temperature profile controller, can be brought online in record time!

It’s as easy as...

  1. wire the MCU I/O pins to the embedded circuit
    1. wire MCU pin an0 to thermocouple op-amp output (I use an LM358)
    2. wire MCU pin an1 to solid state relay control input (I use a Teledyne STH24D25)
  2. connect a host computer to the USB interface on the MCU
  3. let the host computer automatically install the FTDI Serial Port transport drivers
  4. open a Hyper Terminal console window and connect to the MCU; press <Enter> for a command prompt
  5. configure the MCU I/O pins as appropriate
    1. configure pin an0 as an analog input
    2. configure pin an1 as a digital output
  6. write and debug your BASIC control program, live on the MCU (see below)
  7. type “save”
  8. type “autorun on”
  9. turn the toaster oven full on (so that the relay can control it)
  10. type “reset”
  11. disconnect the host computer from the USB interface on the MCU

The entire toaster oven temperature profile controller BASIC control program is shown below:


(see the examples in text format)
  • Line 10 declares two simple RAM variables named “target” and “secs” for use in the program, and initializes them to 0.
  • Line 20 declares an analog input "pin variable" named “thermocouple” that is bound to pin an0, to read the thermocouple voltage, in millivolts
  • Line 30 declares a digital output "pin variable" named “relay” that is bound to pin an1, to control the solid state relay.
  • Line 40 declares the temperature target and delay time pairs for our temperature profile ramp.
  • Lines 50 and 60 configure a timer interrupt to call the "adjust" subroutine asynchronously, every second, while the program runs.
  • Lines 70 thru 100 set the target temperature profile while the program runs.
  • Lines 110 and 120 end the program with the solid state relay control turned off.
  • Lines 130 thru 190 use the declared pin variables to simply turn the solid state relay control off if the target temperature has been achieved, or on otherwise.

Then:

  • “save” saves the program to non-volatile flash memory.
  • “autorun on” sets the program to run automatically when the MCU is powered up.
  • Finally, “reset” resets the MCU as if it was just powered up.

Note that if terse code were our goal, lines 60 and 130 thru 190 could have all been replaced with the single statement:

> 60 on timer 0 do let relay = thermocouple<target


This simple example reads and displays the x, y, and z axis millivolt (mV) values of the accelerometer built in to the M52221DEMO board on the an4, an5, and an6 analog input pins, using the analog-to-digital converters:


(see the examples in text format)

Press <Ctrl-C> to stop the program.


This example generates a series of major audio scales starting at A-440 hertz (Hz) on the dtin0 frequency output pin, using a DMA timer:


(see the examples in text format)


keywords: rich testardi microcontroller hobby rapid prototype breadboard high-school