Normally, Papydoo is asleep. The enclosure sits on top of a vibration sensor. Papydoo is waken up by a sufficiently strong vibration. Two eyes are then displayed on the LED matrix, wandering randomly around. After a few seconds with no vibration detected, the eyes close and Papydoo goes back to sleep. Also once in a while (odds: 1/5), a parade of "Space Invaders" is displayed, which bounces up with vibrations. There is a button at the back to manually switch through different modes: Eyes, Space Invaders, Vibration bar graph and batteries voltage. The project runs from 4 AA batteries and draws around 150uA when sleeping, and around 150mA when awake.
1. Vibration Sensor
The vibration sensor is piezoelectric. I've salvaged a crystal element from a 75W plastic "horn" type tweeter (pictured above). These tweeters can be found for around $5-$10 at electronic parts stores. I've cut out the paper cone glued to one side of the crystal, leaving only a flat disc around 1" in diameter, with two braid wires coming out. This disc then became one of the pad underneath the box. I've put 2 rubber pad on each side at the back, and the crystal at the centre on the front, where most of the weight of the display is.
The trick is to "sandwitch" the piezo crystal between the enclosure and the sitting surface. Any vibration is transmitted through the crystal and mechanical pressure is transformed into voltage.
2. LED Matrix Display
The front display is a red LED 32 columns by 8 rows matrix. The module was bought from SureElectronics on Ebay for around $11 shipped (!). Its based on a Holtek HT1632 which contains a frame buffer and does all the multiplexing work. Communication is done in a serial, SPI like fashion. The module works at 5V. A rectangle was cut out from the front of the wood enclosure to fit the display. The balsa wood is quite thin, so simple scoring and cutting with a utility knife did the trick.
3. The Microcontroller
The Zilog Z8F083A is an 8 bits microcontroller:
- 8K flash ROM
- 256 bytes RAM
- 20MHz internal oscillator
- Fast 2.8us 10 bits ADC
- 20DIP package available
- 2 uA sleep current with watchdog timer running.
- 2.7-3.6V operation, with 5V tolerant I/O
- Single pin in-circuit debugging (ICD) and programming
The Zilog eZ8 series MCUs are almost completely absent from the DIY / hacker / maker scene. I've been working with Zilog eZ8 microcontrollers in "work" related projects and already had the in-circuit debugger / programmer USB cable, a few eZ8 ICs and an extensive C codebase done over the years for it. I've worked with Microchip PIC also, but didn't have any suitable candidates on hand (PIC18F?). I did have a few PIC16F819, but didn't want to "bend over backward" trying to carefully "craft" the code in a 2K ROM MCU. I've also had a few Parallax Propellers, but it would have been overkill, and the Prop doesn't have any sleep / power-down mode nor 5V tolerant I/O. Too bad.
The Zilog ANSI C compiler and IDE (Zilog Developpement Studio II) are freely available to use and download on Zilog's website (www.zilog.com). The toolchain is very simple to use and would deserve to be better known. More about the code in part 2.
4 - Circuit
This project operates from 4 AA batteries and is "on" all the time. So very low current draw (in the uA range) is essential for multi-months battery life.
When sleeping, 3.3V is generated through an ultra-low power MCP1700 LDO voltage regulator (1.6uA quiescent typ.). The MCU draws almost no current in sleep mode (about 2uA). The bulk is drawn by the MCP601 op-amp (150uA measured) always running and interfacing the piezo sensor to the MCU's ADC. Specialized op-amps exist with much lower current draw, but all I had was MCP601 "jelly beans" op amps, and 150uA was acceptable for this project.
The analog block is a non-inverting voltage gain / half wave rectifier / peak detector with bleed. All in one unit:
The watchdog timer wakes the MCU every 1 second. During this brief wake-up, the MCU turns on the on-chip ADC, performs a conversion and goes back to sleep if a determined voltage threshold is not reached. This sequence lasts about 170us, every 1 second. If the threshold is reached, full wake-up follows. The 5V supply is turned-on (through an IRF7343 MOSFET pair) and the display matrix is initialized.
5. Circuit board
The circuit was first put together on a breadboard and when everything was working as desired, a permanent version was done using a generic PCB with copper traces like this one:
This PCB is very common and can even be found at Radio-Shack. The IRF7343 dual MOSFET chip is an 8 pins SOIC SMT package and required to have "leads" soldered to it. An SOIC to DIP adapter could also be used for the less adventurous:
Here is a finished version of the board, assembled in the box with a battery holder:
A ribbon cable connects the led matrix to the main board. Separate power wires were used for the 5V supply:
There is a pushbutton at the back for manually switching the display mode:
6. Full Schematic