Page 1 of 1

NEWBIE Relay's and Microcontrollers

Posted: Sun Jun 20, 2004 1:39 pm
by Leddy
Hello,<p>I have a +12v 20amp source(automotive) that I need to switch between 1 of 6 contacts using a microcontroller. I've decided on the BasicX BX-24 chip. Unfortunately I am new to all of this so I was hoping for some help as I stumbled across this website in my travels. I have also purchased "Physical Computing" to get me started in my adventure. From my understanding the microcontroller will set X pin high(+5v)/low(0v). Since my relay needs to control a +12v source the difference in voltage is too great for the chip to be able to do this. I want to mount these relays onto a PCB as well.<p>Can anyone help me out with some information that I can use? I'm at a loss currently and getting more and more confused. If you have any part numbers that would be most excellent!<p>Thanks for your time

Re: NEWBIE Relay's and Microcontrollers

Posted: Sun Jun 20, 2004 3:26 pm
by Chris Smith
What you need when switching a 5 volt signal, that needs to boost up and turn on a 12 volt relay, is some logic convertors called “A Transistor”. You use the 5 volt logic to turn on a simple transistor like a 123 ap or equivalent, and in turn the transistor base and emitter [or two in cascade] are fed off the 12 volt supply and go to the relay base or feed, and when the small signal turns it on from the 5volt logic, the transistor passes the larger current to the relay which is also fed from the 12 volt portion of your multiple supplies, and is turned on. <p>A reverse diode in the relay coil will clamp the spikes when the relay collapses, and protect the transistor[s] circuit from excess beatings. <p>Think of it as a small relay, controlling a large relay.

Re: NEWBIE Relay's and Microcontrollers

Posted: Sun Jun 20, 2004 9:56 pm
by Leddy
Thanks for the info, I've been attempting to do some research on relay's and transistors. I'm just wondering if I even need a relay. I have a turn dial with the +12vdc 20amp previously mentioned. Depending on where that dial is turned to it passes it to that wire. This in turn set's a series of events in motion. My choices are Off,1,2,3,4,5. I don't need any fast switching because this is for a fan control. The bes way I see it is to hookup a transistor to the i/o pin with the in/out and call it a day. It's something that seems so simple I'm sure there is something I'm missing. I figured I would need to purchase 12vdc 20a SPST NO relays but I can't find any that aren't the cost of a new car. So if I can avoid this I'm all for it! Am I seeing all of this clearly or is there something I am overlooking?<p>[ June 20, 2004: Message edited by: Leddy ]</p>

Re: NEWBIE Relay's and Microcontrollers

Posted: Tue Jun 22, 2004 1:59 pm
by wd5gnr
You might find this pageof interest.

Re: NEWBIE Relay's and Microcontrollers

Posted: Tue Jun 22, 2004 2:13 pm
by Chris Smith
Bosch ice cube auto relays are under 5 bucks. 30 amp max?

Re: NEWBIE Relay's and Microcontrollers

Posted: Tue Jun 22, 2004 8:53 pm
by dyarker
20A is a hefty amount of current to switch. Power transistors that can handle that will cost $4 - $10. And, they tend to have low gain, like 15. So for a collecter of 20A, the required base current is:<p>20A / 15 = 1.34A<p>A BASIC Stamp I/O pin can only sink 25mA or source 20mA; but the total of all pins must be less than sink 50mA, source 40mA; per I/O group or whole IC depending on if you're using interal or external +5V regulator. So add a 2A transistor to drive the big one. Let's say this one has a min gain of 60. It's base current is:<p>1.34A / 60 = 0.0224A = 22.4mA<p>That fits within the Stamp's spec for one I/O pin ON at a time. But 5V to 12V translation needs doing, and the less current on an I/O pin the better. Put a resistor from supply to base of 2A transistor that will pass the 22.4mA. The collector of a low power transistor goes to that junction. It's emitter to common. The base is connected to an I/O pin through a resistor. The current here is:<p>22.4mA / 100 = 0.224mA = 224uA<p>Many low power transistors have a minimum gain of 100. The Stamp won't be working hard at all.<p>The problem is now you need 15 transistors for the 5 ON choises. Also, the 20A transistors can drop 2 of the 12V when fully loaded.<p>(A question: the source can supply 20A, but does the fan(s) really use that much?)<p>I haven't mentioned any part numbers because I don't know if you're switching the voltage supply side or the common return side (easier for translation).<p>A relay that can handle 20A may (repeat may) need upto 500mA though a 12V coil depending on model. Each relay could be driven by a single 2N2222 (cheap). Min gain for a 2N2222 is 100, so load on the I/O pin would be:<p>500mA / 100 = 5mA or less.<p>A big advantage of a relay is the large spikes when turning off the fan are isolated from the transistor and Stamp. A 1N4001 protects against the relay coil spikes.<p>Another way to do it, is control the fan(s) with power FETs. If you're switching the supply side, then a low power transistor (or FET) translates the voltage for the power FET. If switching the return, then only the power FET is needed. A power FET with low "on" resistance would drop less voltage than a power transistor.<p>If this was mine to decide (which it ain't, it's yours), I would drive 5 relays with medium power FETs.<p>Did I discover what you thought you were missing?
Cheers,<p>[ June 22, 2004: Message edited by: Dale Y ]</p>

Re: NEWBIE Relay's and Microcontrollers

Posted: Wed Jun 23, 2004 2:06 pm
by Leddy
Holy COW! What a novel! Great ideas! I've actually ordered all the parts and microcontroller last night. Both shipped today. This is what I came up with with the help of some other great electronics whizzes(unlike myself)<p>http://www.artica.net/~leddy/NPN_Relay.jpg
(Replace the 680 with a 270(5v))<p>I will be switching the + side to different outputs. Here's the original
http://www.artica.net/~leddy/Blower_Motor_Controls.pdf<p>I ordered all the parts last night.
7805 5v regulator(for controller)
Transistor (Digikey PN 2N3704-ND)
12vdc 20amp relay (Digikey PN Z954-ND)
4.7k Resistor (Digikey PN 47KQBK)
270 Resistor (Digikey PN 270QBK-ND)
Diode (Digikey PN1N4001GITR-ND)