StickOS and CPUStick - Build a Simple Toaster Oven Temperature Profile Controller 2/2
Schematic
The schematic for the Toaster Oven Temperature Profile Controller is shown in Figure 3.

Figure 3
Configuration
Once the Toaster Oven Temperature Profile Controller is built, the next step is to install StickOS BASIC on the UBW32 Board. This is achieved as follows:
-
1.hold down the PRG switch on the UBW32 and connect the UBW32 to the host computer USB port; you should see alternating blinking white and green LEDs indicating the UBW32 is ready to download a firmware file
2.run the HIDBootLoader.exe application from the zip archive on the UBW32 homepage: http://www.schmalzhaus.com/UBW32/FW/HIDBoot/HIDBoot.zip
3.click “Open Hex File” and browse to StickOS.UBW32.v1.50g.elf.hex
4.click “Program/Verify”
5.press the RESET switch on the UBW32 to start StickOS running; you should see a slowly blinking orange LED indicating StickOS is idle (this LED will blink quickly when StickOS is running a BASIC program)
CPUStick - BUY IT NOW! (24/48h delivery)
The next step is to install the USB Virtual COM Port driver on the USB host computer, if it is not there already.
When the MCU is connected to a USB host computer, it will present an FTDI Serial Port function to the host computer. An appropriate signed driver will be loaded automatically from microsoft.com, if needed (and if you are connected to the Internet), or you can manually install the VCP driver from http://www.ftdichip.com/FTDrivers.htm.
Once the driver is loaded, a new virtual COM port (VCP) will be present on your system. This virtual COM port will be visible in Device Manager:
At this point you can use Hyper Terminal to connect to the new virtual COM port. Specify a new connection name, such as “ubw32”, and then select the new virtual COM port under Connect Using; the baud rate and data characteristics in Port Settings are ignored when using the USB Virtual COM Port.
Press
You are now ready to enter StickOS commands and/or BASIC program statements. Alternatively, you can use an RS232 port on the host computer and a RS232 Shifter Board Kit (such as http://www.sparkfun.com/commerce/product_info.php?products_id=133) to connect the host computer to pins “rf8” (transmit data) and “rf2” (receive data) of the MCU, using 9600 baud, 8 data bits, no parity, 2 stop bits, and xon/xoff flow control.
The BASIC Control Program
Enter the following BASIC control program at the StickOS command prompt to control the Toaster Oven Temperature Profile Controller:
10 dim phase, target, secs 20 dim thermocouple as pin an4 for analog input debounced 30 dim relay as pin ra7 for digital output 40 dim red_led as pin re1 for digital output inverted 50 dim white_led as pin re2 for digital output inverted 60 data 512, 90, 746, 105, 894, 20 70 configure timer 0 for 1000 ms 80 on timer 0 do let relay = thermocoupleLine 10 declares three simple RAM variables. Line 20 declares a “pin variable” named “thermocouple”, then configures I/O pin “an4” (synonymous with “rb4” on the UBW32 silkscreen) for analog input thru a low-pass filter, and finally binds the pin variable to the corresponding pin. From then on, examination of the pin variables results in the current ADC values being read, in millivolts (mV). Lines 30 thru 50 declare digital output pin variables to manipulate the MCU pins attached to the relay and LEDs. Line 60 contains the temperature profile ramp target and time information:
- 90 seconds at up to 512 millivolts (125 Celsius)
- 105 seconds at up to 746 millivolts (183 Celsius)
- 20 seconds at up to 894 millivolts (220 Celsius)
Line 70 configures a periodic timer to run every second, and line 80 indicates that when the timer expires, the (digital output) value of the relay should be updated to reflect the result of a comparison between the (analog input) value of the thermocouple and the current target of the temperature profile ramp. Lines 90 thru 130 simply cycle thru the temperature profile ramp and update the white and red UBW32 LEDs to indicate the progress. Line 140 unconfigures the periodic timer. And finally, line 150 turns off the relay and LEDs. Then the program ends.
To save the program to the flash filesystem, type:
saveTo run the program, type:
runTo set the program to autorun on MCU power-up, type:
autorun onDiagnostics
What if your program doesn’t work? What if you have a bug in your op-amp or relay circuitry? StickOS supports fully interactive control of the MCU. You can start running the program by typing “run” and then pressto stop it after a minute or two and you will see: > runSTOP at line 120! At that point you can print the current value of the thermocouple, in millivolts, with:
> print thermocouple 609You can turn on the MCU output connected to the relay with:
> let relay = 1You can then watch the thermocouple voltage increase:
> print thermocouple 644And turn off the MCU output connected to the relay:
> let relay = 0And watch the thermocouple decrease:
> print thermocouple 570You can even continue the program from where it left off:
> contYou can use breakpoints, assertions, watchpoints, single-stepping, execution tracing, live variable and pin examination and manipulation, and even edit-and-continue as part of the StickOS interactive debugging experience.
More Information
Full StickOS documentation and downloads for various supported MCUs can be found at: http://www.cpustick.com/index.htmThere is also a skeleton source code project with all of the StickOS initialization and pin and peripheral manipulation routines, for those wanting to port their finished BASIC programs to C.
Future Directions
When coupled with an optional Freescale MC13201 ZigFlea Wireless Transceiver, the MCU may be remotely controlled by another MCU, via a telnet/rlogin-like interface, eliminating the need for a direct connection to the host computer altogether. And BASIC programs may trivially remotely access variables on other MCUs, enabling the use of “remote pin variables” or other forms of inter-MCU communication. Wireless embedded systems are made just as easy as wired ones.You can also download plans for a ZigFlea-enabled “CPUStick” based on the 80 MHz Freescale MCF52252 MCU here:
user’s guide: http://www.cpustick.com/downloads/cpustick.v2.00.2p.pdf
schematic and BOM: http://www.cpustick.com/downloads/cpustick.pdf
Gerber files: http://www.cpustick.com/downloads/cpustick.zip
firmware: http://www.cpustick.com/downloads/StickOS.MCF52252.v1.50g.elf.S19Note that you will need some way to flash the CPUStick initially, either with a QSPI programmer or with an M52259DEMOKIT board from Freescale, loaded with the StickOS bits and using the “clone” command to copy them to the new board.
Toaster Oven Tips
Fine pitched SMT reflow soldering can be an intimidating task to the newcomer, but I have found that I can reliably reflow “CPUSticks”, including 0.5mm pitch QFP’s and even 0.5mm QFN’s with just a few tricks:To mount a QFN (leadless) package, I first flux the component pins and then tin them with my soldering iron; each pin ends up with a little bump of solder on it. I then flux the board pads and tin them, with a similar and opposing bump (it definitely helps to have a solder mask on the board, but I have done it without). Then I flux everything again and align the bumps on the QFN pads with the opposing bumps on the board, and prepare for reflow using your new Toaster Oven Temperature Profile Controller. To mount the QFP (leaded) packages, I use a similar procedure but do not tin the delicate component pins.
After reflow, if touchup is needed (the typical problem will be “opens”, not “shorts”), I use a generous amount of flux at the pin/pad interface and then drag the ever slightest amount of solder across it with my soldering iron. Note that the flux is critical in this step to avoid any bridging/shorts.
I used a Weller WES51 soldering iron with an ETP (1/32" screwdriver) tip, 62/36/2 silver solder from Radio Shack (in a convenient 1.5 oz spool), a Kester #2331-ZX water soluble flux pen, and a PanaVise PV Jr. Model 201 (to hold things).
CPUStick - BUY IT NOW! (24/48h delivery)
About the Author
Rich Testardi lives in Boulder, Colorado, with his wife and daughter and thinks microcontrollers are the coolest thing; his dream is to make them easy enough to use to introduce into high-school curriculums, since that was where his initial exposure was. Since that time long ago, many forces, notably SMT and ever-increasing MCU integration (and 500+ page reference manuals), have conspired to make these projects less accessible to high-school students; he hopes to reverse that trend with StickOS and CPUStick!
- rtestardi's blog
- 658 reads





Post new comment