Dec282006

Microcontroller-controlled Relays (Partylights)

The prototypeObjective:

Control high voltage, high current devices using a microcontroller

Background:

Inspired by the guys on YouTube who control their Christmas lights and synchronize them with music, I set out to learn how to attach relays to my Freescale 9SS12C32 microcontroller. I did some research into the parts I would need and ordered them without any specific task to accomplish once the microcontroller controlled the relays. I started with a setup just using one relay and got that to work. I later added 3 more relays so I could control 4 sets of Christmas lights and sync them to the tempo of music for our party They’re The Most Wonderful Times of The Year (the video shows the lights).

The relays usedParts Used:

Microcontroller w/ Technical Arts docking module (Technological Arts part: NC12C32SP-SB)
4x Relay (L90-5W)
4x PNP Transistor (2N4403)
4×200ohm Resistor
4×10Kohm Resistor
Open Collector Hex inverter (7406) (open collector can receive up to 40mA current)
4x LEDs (functionally just diodes, but the light helps debug)
Power Strip

Hardware:

The relays have an impedence of 27Ohms and the prototyping board UT students get from Technical Arts has a +5V port that can supply up to .5A of current. Going slightly over this amount does not damage the microcontroller, but instead resets it. Instead of drawing voltage straight from the microcontroller, I used an open collector inverter. This provides a buffer between the microcontroller and the circuitry so I fry the $.30 inverter before the $10 microcontroller.

The prototype

The 7406 (Open Collector Inverter) can only accept 40mA and it takes around 185mA (I = V / R where V = 5V and R = 27Ohms) to switch the relays so I was not able to connect the relays directly into the 7406. So I did a little learning and came up with a circuit based on a PNP transistor that would allow me to supply 185mA to the relay while still using the 7406 as a buffer between the microcontroller and the relay. That schematic is below.

The LED is used as a protection diode which dissipates the remaining energy stored in the magnetic field of the relay’s coil.

The schematic

I implemented the above schematic 4 times in order to control 4 relays.

Software:

I built this setup to set a dancing mood for a party; I needed software to synchronize the switching of 4 relays with music.

I didn’t have the experience / time to build something that would detect peaks, so I decided to write a program that would allow me to set the tempo manually. The program I wrote in assembly, executed a simple state machine that switched on one relay, then then next, then the next, etc. When input was detected from the serial port (SCI Receive Interrupt), the software executed a function that waited for three more key presses, averaged the interval between them, and set the state machine to switch at that interval. With this I could tap a key four times to set the tempo. Get the code

I then connected my ATI Remote Wonder so that I could set the tempo from a remote in my pocket.

Check out our party They’re the Most Wonderful Times of the Year to see this in action.

References / Thanks to:

The Electronics Club – has information about transistors
Dr. Jonathan W. Valvano – my Introduction to Microcontrollers professor

Write a comment


Showing comments 1 to 10 of 1960 | Next | Last
Comment beeveamophepe on : Sat July 31, 2010, 04:00:15
All good health!
http://forkliftes.myownfreeweb.com/06/index.html - enduro nissan forklift 28 http://forkliftes.myownfreeweb.com/12/index.html - r2030 forklift nissan D http://forkliifts.luservice.com/11/index.html - r2030 forklift nissan A http://ferklist.my-webs.org/18/map.html - hyster 25k forklift map 266 http://forkliifte.my-place.us/10/index.html - ontario forklift license K
We will not miss you
Comment beeveamophepe on : Fri July 30, 2010, 05:35:08
You like it here
http://mercedes.20ehost.com/65/map.html - cobridge mercedes map w http://mercedes.20ehost.com/11/index.html - white mercedes calcite j http://mercedess.5khost.com/70/index.html - mercedes class e y http://mercedess.5khost.com/95/index.html - sprinter tyre mercedes j http://mercedes.20ehost.com/103/index.html - mercedesem 742
Before connection
Comment beeveamophepe on : Fri July 30, 2010, 04:00:30
Web sites websites
http://mercedes.20ehost.com/11/index.html - white mercedes calcite e http://mercedess.5khost.com/62/map.html - mercedes caravello map 326 http://mercedes.20ehost.com/70/index.html - alternator mercedes e320 P http://mercedess.5khost.com/118/index.html - yanase mercedes s http://mercedess.5khost.com/19/index.html - john mercedes weir v
Bye
Comment louis vitton on : Thu July 29, 2010, 02:28:03
Hi, I enjoy your article. This is a good site and I wanted to post a little note to tell you, great job!
Chao,
Louis

<a href=http://www.luxurygiftsbags.com>Louis Vuitton Luggage</a>
<a href="http://www.luxurygiftsbags.com">authentic louis vuitton</a>
Comment beeveamophepe on : Wed July 28, 2010, 06:24:05
Good day
http://mercedese.4sql.net/70/index.html - e class mercedes m http://mercedese.4sql.net/52/index.html - mercedes benz slr 536 http://mercedese.4sql.net/94/map.html - drawing mercedes sprinter map B http://mercedese.4sql.net/29/map.html - festgeld mercedes bank map V http://bmws.5khost.com/03/index.html - bmw cog pga v
Good luck
Comment Louis Vuitton Mens belts on : Mon July 26, 2010, 18:36:15
Great quality <a href="http://louisvuittonbelts.net/">Louis Vuitton belt</a>, <a href="http://louisvuittonbelts.net/">Louis Vuitton Mens belts</a>, Five stars <a href="http://louisvuittonbelts.net/">Louis Vuitton belts</a>, <a href="http://louisvuittonbelts.net/">Louis Vuitton belts For men</a>.<br>
Comment beeveamophepe on : Mon July 26, 2010, 10:10:21
Best of the Web world
http://merse.4sql.net/111/map.html - sexymercedes w http://mersic.5khost.com/25/index.html - mercedes specifications a140 c http://merse.4sql.net/52/map.html - benz ssk mercedes map s http://merse.4sql.net/45/index.html - mycommand mercedes benz J http://merse.4sql.net/103/index.html - mercedesem e
Go to the guests
Comment beeveamophepe on : Mon July 26, 2010, 08:36:39
Web sites websites
http://mersic.5khost.com/56/map.html - mercedes bonto map E http://merse.4sql.net/54/map.html - benz willsonville mercedes map p http://merse.4sql.net/31/map.html - benz 1418 mercedes map q http://mersic.5khost.com/35/index.html - c300 mercedes benz T http://merse.4sql.net/42/map.html - g550 mercedes benz map O
Before connection
Comment plbtvkaxu on : Sat July 24, 2010, 14:22:36
7EY83b <a href="http://elwgcdbyaikn.com/">elwgcdbyaikn</a>, [url=http://tvsfvwqilsbh.com/]tvsfvwqilsbh[/url], [link=http://qpbsclglilet.com/]qpbsclglilet[/link], http://ajzvdpxckbjc.com/
Comment otaexkjio on : Sat July 24, 2010, 09:53:18
n0PbEz <a href="http://tdaippurxzow.com/">tdaippurxzow</a>, [url=http://jwuhbwtomnhf.com/]jwuhbwtomnhf[/url], [link=http://jkrgrskpnakk.com/]jkrgrskpnakk[/link], http://hmikdowgzfak.com/
Showing comments 1 to 10 of 1960 | Next | Last