In my previous SPARK post, I created a program that sends serial port commands via an XBee transceiver to control lights plugged into a modified power strip. It was nice to see this level of functionality, but since this is my last SPARK post, I wanted to add a little pizzazz to the project. The eBox 2300 computer I am using has audio in and audio out. I thought it would be cool if I had lights flashing in coordination with music. The more lights I have, the cooler the effect. So I grabbed several more of my hacked power strips, added some code to the Windows Embedded program, and had a nice little light show sequenced to flash along to
Herbie Hancock's Chameleon.
The power strips happen to be great project enclosures for my line voltage powered electronics.
The secret to the wireless controlled power strip is the small capacitive power supply. This acts as an AC voltage divider, generating between 8 and 15 volts from a 120VAC input, depending on the load. I strongly warn against working with lethal voltages unless you have extensive experience and are familiar with appropriate safety practices. If you are qualified, you might find this page from the Texas Instruments MSP430 design guide useful:
I based my design off these calculations, and was able to create a power supply that could deliver about 150mA of current. I used a linear regulator to deliver 3.3VDC to my electronics. Trying to design and program electronics running of live line voltage creates many hazards. One way I was able to minimize the risk of electrocution was to completely disconnect the Atmel AVR microcontroller, which is the main system controller, from the development computer by using the XBee as the programming interface.
The full schematic can be downloaded
here. The current revision of the PCB has several design flaws, but the pictures provide a guide for part placement:
The board is designed to handle inductive, capacitive, and resistive loads up to 4A at 120VAC. It's worth noting that the high voltage AC traces are kept a safe distance away from the digital lines. Not only is this good for reducing electrical hazards, it also reduces potential noise for the microcontroller and radio. The Atmel AVR168 microcontroller is programmed on the bench running off a 3.3v supply. I first load in the Arduino bootloader so I can use the XBee for re-programming when the board is running off the capacitive power supply. From there, this is a pretty easy system to use. Each board has a unique address, set in hardware, software, or both. Also, the XBees have an internal address which matches the sticker I've placed on the front of the wireless devices. This gives enormous flexibility with talking to the boards.
Coupled with the iCop eBox, I have a very fun system which can play sounds and sequence turn on/off 120VAC loads. Although my official SPARK projects have come to a close, I'm very interested to see what happens if I use the audio input and some signal processing to automate the light sequencing based on incoming sounds.
That is a project for the future!