ARDUINO controlled christmas light display

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
gizmohalo
 
Posts: 40
Joined: Sun Aug 22, 2010 3:26 pm

ARDUINO controlled christmas light display

Post by gizmohalo »

I currently have the arduino running a blink sketch which controls a transistors base which allows the 12v of a relay coil to connect to ground therefore switching lights on and off, my problem is when i do this with a big see through dpdt relay it works fine but when i do this with a small enclosed relay it stays on and only switches off when i turn the 12 v off??????
this is the schematic
http://www.instructables.com/image/FOLE ... C/null.jpg

and yes the relay is rated for 10a 120v ac
here is the relay im using
http://www.mouser.com/Search/ProductDet ... C-F-S12VDC

ericgu
 
Posts: 58
Joined: Mon Oct 18, 2010 11:24 pm

Re: ARDUINO controlled christmas light display

Post by ericgu »

I think you need a pullup resistor on the output from the arduino. Something like a 1K resistor should work pretty well.

Without that, the input will float, and (assuming I remember my transistor stuff well enough) you'll get some current flowing. It's likely enough to trigger the small relay but not the big one, so it works with the big relay but not the small one.

gizmohalo
 
Posts: 40
Joined: Sun Aug 22, 2010 3:26 pm

Re: ARDUINO controlled christmas light display

Post by gizmohalo »

i have a 1k already on the pin 13 of the arduino that connects to the base should i switch it to 10k?
oh and i forgot to tell you when i turn off the arduino the relay still stays on??

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: ARDUINO controlled christmas light display

Post by adafruit_support_bill »

Sounds like maybe a defective relay? Do you have another one to swap out?

User avatar
abqlewis
 
Posts: 71
Joined: Fri Dec 11, 2009 2:19 am

Re: ARDUINO controlled christmas light display

Post by abqlewis »

Just my uneducated guesses,

First thing I would do is disconnect the 120v from the wall and unplug the lights, and use an ohm meter (you have no excuse for not having a meter, since ladyada has had them on sale) to check the relay operation. If you don't have a meter, you could also use an LED and battery to check for continuity. Just take the High voltage out of the equation.

If you can, replace the relay. It could be bad. If it is, it could have just been bad, or what ever caused it to fail (quickly) may still be in your circuit. This is really a 5v circuit design, and you are using 12v, and a fairly cheap relay. You also might need to really derate your relay, especially for something that cycles (blinks) continuously.

You say that turning the Arduino off does not turn off the relay. Can you completely disconnect the Arduino output pin from the circuit?

Lastly (although my first thought), ericgu mentioned a pull-up resistor. Your 1k is not a pull-up resistor, because it is not connected to 5v. But I don't think you need a pull-UP since you have no problem turning the relay on. You may need a pull-DOWN resistor to help turn the relay off. I'm thinking a 1k-10Kohm connected from GND to the Arduino output pin, but I would like input from one of the knowledgeable types (ladyada?) whether it would be better at the transistor base.

Please post when you get this solved, because I see circuits like this in my future.

gizmohalo
 
Posts: 40
Joined: Sun Aug 22, 2010 3:26 pm

Re: ARDUINO controlled christmas light display

Post by gizmohalo »

Ok guys i figured it out!!!!

It turns out the first time i tested the circuit i did it without a fly-back diode so as you know it blew the transistor but i didn't know that so i took my meter and tested the voltages at various points of the circuit and figured out the transistor was bad and i replaced it and just like that it worked!!!!!!!

So lesson learned here always use a fly-back diode when controlling inductive loads :D
thanks for all the help guys

User avatar
stinkbutt
 
Posts: 593
Joined: Wed Feb 17, 2010 2:40 am

Re: ARDUINO controlled christmas light display

Post by stinkbutt »

That's excellent news, since your relay appears to cost ten times as much as your 2N2222, plus shipping, plus the sitting on your ass waiting for mouser to fulfill your order. Yay for you!

gizmohalo
 
Posts: 40
Joined: Sun Aug 22, 2010 3:26 pm

Re: ARDUINO controlled christmas light display

Post by gizmohalo »

OK sorry to bother again but i wired up a second circuit the EXACT same way and I'm having the same problem with the relay staying on again?????
i have a 10k resistor connected to arduino ground, but only the first circuit works. what i think is wrong is the first time i run the circuit the transistor burns out and then i replace it and everything is just fine, i have not replaced the transistor on the second circuit yet but I'm pretty sure that's what the problem is so my question is what is causing the transistor to burn out????, if that is what is causing the second circuit to not work.
by the way i have to make this circuit 10 times :D

i will update once i try replacing the transistor but i don't want to have to replace every transistor i put in :(
i also get mouser shipments next day because I'm 3 hours away from them :D

User avatar
stinkbutt
 
Posts: 593
Joined: Wed Feb 17, 2010 2:40 am

Re: ARDUINO controlled christmas light display

Post by stinkbutt »

gizmohalo wrote:i also get mouser shipments next day because I'm 3 hours away from them :D
<jealous>Grr</jealous>

Ah, XML-compliant humor - We don't get enough of that.

Anyway, this is the way you implement a flyback diode to protect your transistor:

Image

Your transistor can be above or below it, it's not a big deal, but the important part is that the diode points opposite to the normal direction of current flow. That way it does nothing normally, but when the switch (transistor) turns off, it allows the current to flow in a big clockwise circle around the diode & the relay.

Strictly speaking you're supposed to have a (tiny) resistor in there as well to dissipate the current, but the internal resistance of your relay is always enough for that.

gizmohalo
 
Posts: 40
Joined: Sun Aug 22, 2010 3:26 pm

Re: ARDUINO controlled christmas light display

Post by gizmohalo »

i have a flyback already but i think it is still burning out but i haven't confirmed that yet i will tomorrow

User avatar
stinkbutt
 
Posts: 593
Joined: Wed Feb 17, 2010 2:40 am

Re: ARDUINO controlled christmas light display

Post by stinkbutt »

All I can tell you is make sure it's pointing in the right direction. I don't really know what else it could be. Could you possibly be using the old burned out transistor by accident?

gizmohalo
 
Posts: 40
Joined: Sun Aug 22, 2010 3:26 pm

Re: ARDUINO controlled christmas light display

Post by gizmohalo »

no i'm positive i'm not using the old one but tomorrow i will find out if the transistor is bad or not i don't have time tonight.
i will update when i test the transistor

ericgu
 
Posts: 58
Joined: Mon Oct 18, 2010 11:24 pm

Re: ARDUINO controlled christmas light display

Post by ericgu »

I was off-base on the pullup resistor - that would only make sense if the arduino was open-collector and you were using a PNP transistor.

My advice is to start without the relay. Put an LED in with an appropriate resistor (1K should work with most LEDs) in place of the relay and verify that things work the way that you expect them. You should measure something close to 5V on the arduino output when the LED is on and close to 0V when it is off.

I think your base resistor is probably fine - if it were the wrong size the relay wouldn't turn on at all.

If you are still having issues, please measure the voltage at each spot (the base of the transistor, the collector, etc.) and let us know.

And make sure you have the flyback diode in correctly. It could easily be that you are blowing transistors because you don't have the relay.

I prefer solid state relays for this sort of thing. They are a bit pricier if you want to switch large currents, but you can always use an SSR to switch a larger relay with a 120VAC coil. And they are very easy to drive from electronics.

gizmohalo
 
Posts: 40
Joined: Sun Aug 22, 2010 3:26 pm

Re: ARDUINO controlled christmas light display

Post by gizmohalo »

the white or gray line on the diode should be facing 12v right?

gizmohalo
 
Posts: 40
Joined: Sun Aug 22, 2010 3:26 pm

Re: ARDUINO controlled christmas light display

Post by gizmohalo »

Ok the transistor did indeed go bad on the second circuit im about to replace it

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”