Kind of OT: relay switching question

Started by axg20202, May 08, 2010, 03:54:02 AM

Previous topic - Next topic

axg20202

Hi all,

I have a theoretical switching question that hopefully someone can help me with.  Not having used much in the way of relays before in circuit design, I'm treading new ground so need some pointers. Let's say I have a low voltage signal that I want to use to switch on and off a higher voltage device, say a 9v battery powered device as an example. How would I go about doing this?  [EDIT: I should add that I know how relays work and have read RG's stuff at GeoFX on the subject]

R.G.

I'm a little confused by the question. A relay is a magnetically isolated switch. The switch does whatever you wire it up to do, and the only requirement to get this to work is that you give the relay coil enough on current when you want it on, and not so much that you burn it out.

If you mean how do you pick a relay and pointers about wiring it up, I'll just list a few.
- relay coils are really current-operated devices. A relay coil is rated in volts because the relay designer has cleverly picked a wire size so that the total resistance of the winding limits the relay current to the right value when the rated voltage is on the coil. If you have a nominally 12V relay, the relay winding lets through X amount of current when there is 12V across the coil. This is enough to pull the relay in, plus a little safety factor for the "slow" relays. It also keeps the relay coil from burning out. If you want to run a 12V relay from 5V, it won't work because the coil resistance is designed to let the right amount of current from 12v, and not enough gets through at 5V.

- you can run a relay from a higher voltage than its rating. A 5V relay can be operated from 12V if you put a resistor in series with it so the additional 7V is dropped across the resistor.

- relay coils are inductors; they charge up with current when the relay is on, and they have an inductor kickback when you try to turn them off. This is what that reverse-connected diode is for in almost all relay circuits.

- the contacts are really isolated from the coil. You can, for instance, with the right relay, switch 240VAC power line stuff from low voltages. In fact, this is one of the big applications of relays.

- for normal relays, you have to keep the coil current on all the time to keep the relay pulled in. Latching relays let you use pulses to turn it on and off, but they require special circuitry to make it turn on, then off.

- the coil current needed all the time for a normal relay will eat up a 9V battery FAST.

- if you're trying to switch AC power line stuff with relays, be !#@%@!#% sure you know how to wire AC power line wiring safely , observing the right insulation, grounding, and creepage/clearance distances, or you could be building an electrocution machine. Or a house-burning device. This has nothing much to do with the relay, but everything to do with staying alive.

What else were you looking for?
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

axg20202

Thanks RG, I was hoping you'd respond to this rather vague question! As ever you have been most helpful. The last time I touched a relay was when replacing the noisy unit in my Leslie - scary stuff, but the visible flash those units give out serves as a clear signal to even the most dim-witted tinkerers to leave well alone.  :icon_wink:   No worries re high voltages this time - I'll be working with low voltage DC throughout.

The point you raise about having to keep a typical non-latching relay energised, thereby constantly drawing power, is an important one for me and has prompted me to rethink my strategy. I am now thinking about whether I could achieve what I want using a transistor as the switch instead... Sorry for not elaborating on my application but it is not really stompbox related.

axg20202

Actually RG, I'm really hoping you can help me with the transistor switch I'm tying to put together. I'm using a PNP. At rest my base voltage is 3.2V and I'm trying to set up the transistor so that the 'switch' is tripped when this voltage drops to 0V. The emitter is connected to 1.6V, which I want to drive the load (an LED) connected to the collector. I want the LED to be as bright as possible. I've tried rigging this up using a 80R current limiting resistor after the diode (resistor goes to ground). The LED isn't lighting. The transistor I am trying to use is a 2N3906 (Hfe of about 220). Any idea where I'm going wrong?

R.G.

Quote from: axg20202 on May 22, 2010, 12:30:46 PM
Actually RG, I'm really hoping you can help me with the transistor switch I'm tying to put together. I'm using a PNP. At rest my base voltage is 3.2V and I'm trying to set up the transistor so that the 'switch' is tripped when this voltage drops to 0V. The emitter is connected to 1.6V, which I want to drive the load (an LED) connected to the collector. I want the LED to be as bright as possible. I've tried rigging this up using a 80R current limiting resistor after the diode (resistor goes to ground). The LED isn't lighting. The transistor I am trying to use is a 2N3906 (Hfe of about 220). Any idea where I'm going wrong?
You probably don't have enough voltage left to forward bias the LED. With the emitter connected to 1.6V, the collector can not possibly pull higher than that, no matter what you do the base. So the LED is not getting more than 1.6V, probably less. Some LEDs will conduct at 1.2V, but these are kind of old school designs. Most modern LEDs don't start putting out current til 1.8V, and maybe as much as 3-4V for some of them.

And remember that for bipolar switches, you have to limit the base current to something safe for the transistor (check the datasheet) and if you really use it as a switch, you have to somehow limit the current into the load, an LED in this case. Not doing both of them will sometimes kill the transistor, or possibly the LED if your power supply doesn't refuse to play at some current that's safe for the devices.

I'd have to see  your schematic to tell what to change to get it working.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

axg20202

#5
Thanks RG, I hadn't considered the minimum voltage required to light the LED. Below is a schemo. When working with a 1.6v supply, I was using an R1 of 4k7 and R2 was 80R. I can double the supply voltage if needs be. Given that 1.6V is not enough to forward bias modern LEDs, it makes me wonder how those single LED flashlights are powered from a single AA battery. EDIT. in my image my triggering voltage looks like 32V. Its not, it's 3.2V and this I definitely can't change. I'm working with a 2n3906 tranny.


R.G.

Quote from: axg20202 on May 22, 2010, 02:22:09 PM
Thanks RG, I hadn't considered the minimum voltage required to light the LED. Below is a schemo. When working with a 1.6v supply, I was using an R1 of 4k7 and R2 was 80R. I can double the supply voltage if needs be. Given that 1.6V is not enough to forward bias modern LEDs, it makes me wonder how those single LED flashlights are powered from a single AA battery. EDIT. in my image my triggering voltage looks like 32V. Its not, it's 3.2V and this I definitely can't change. I'm working with a 2n3906 tranny.

OK. Here's what to do. First, you're absolutely going to have to double the power supply. 3.2V is tight, but maybe we can work with it.

We have to know the parts first. Here's the datasheet on Fairchild's 2N3906. http://www.fairchildsemi.com/ds/2N%2F2N3906.pdf
Some pertinent bit are
- Collector-emitter saturation voltage at 10ma and a gain of 10 is 0.25V, requiring a base current of 1ma (page 2)
- Base-emitter voltage with gain of ten and 1ma base current is about 0.75 at 25C, dropping to 0.6 at 125C. I'm guessing you won't use this at 125C...  :icon_biggrin:

If the base current can be pulled down by 1ma, then we can get 10ma through the collector and only drop 0.25V across the transistor. Out of our 3.2V, that means we have 2.95V left. A quick scan through Mouser's catalog turns up LEDs with Vf of 1.85 to 4V and even higher. Obviously, we can't use LEDs over 2.95V because we can't turn them on. In fact, we can't even use those, because they would eat up all the available voltage, and we'd have no voltage left to drop across the current limiting resistor. This is the hidden dilemma - how to control the current. A resistor will have some tolerance. So will the saturation voltage on the transistor. So will the forward voltage of the LED. The tolerances can quickly add up so you may not have the LED bright enough, or it may burn out.

Let's say we play conservative, and get that 1.85V red LED.

Out of our 3.2V, we've now given 0.25 to the transistor saturation voltage and another 1.85 to the LED to run on. That leaves 3.2-0.25-1.85 = 1.1V for the resistor. Let's pick a desired current of 10ma, just for a starting place, and so the resistor is .... tada! 1.1V/0.01A =110 ohms.

But it's actually 110 +/- 5%. How bad is that? Well, the current changes by +/-5%. No biggie. But the saturation voltage of the transistor is not constant at 0.25V. Get a high gain transistor and that may go down to under 0.1V or up to half a volt with a low gain one. The saturation voltages they tell you are "typical".  So that would change the voltage acroso the resistor to 1.1+0.15 or 1.25V or down to 1.1-0.25 or 0.85. Now even the nominal 110 ohm resistor gives a current of 1.25/110 = 11.36ma or as little as 0.85/110 = 7.7ma.

It gets worse. The LED data sheet http://www.us.kingbright.com/images/catalog/SPEC/WP7113SRD-D.pdf shows that 1.85V is actually typical at 20ma. They specify that it can go to 2.5V at 20ma maximum. If it is really 2.5V, then the resistor has left 3.2-0.25-2.5 = .45V across it, and the current is 4.1ma. And we still don't know what it will really do because the max LED voltage is for a 20ma current, which we won't get.

It will probably work, but figuring out exactly how it works is very hard.

What's really going on is that the ratio of the voltage dropped across the resistor to the voltage dropped across everything else is what sets the stability of that current. If the resistor voltage is at least as big as the other voltages, then the variation is small. But when it's noticeably smaller than everything else, the "everything else" makes the current unpredictable.

Here's something else you can do, though. Change the circuit. Convert it to a transistor current source. Hook your emitter to +3.2V through a resistor. Hook two silicon diodes from +3.2 to the base, and a resistor to the switch voltage. When the switch voltage goes to 3.2V, the resistor pulls the base up and no base current flows, so no collector current to speak of flows. When the base is pulled down, the base is held no more than two diode drops below the 3.2V supply by the diodes. The emitter is one base-emitter diode higher than that, which leaves one diode drop across the resistor. Now we can set the resistor, knowing that it will always have about 0.6V across it. 10ma in the LED? OK, 0.6V/0.01A = 60 ohms. Let's pick 62 ohms. The transistor lets through enough current to always make that true. It ignores the LED.

The voltage across the LED is still our 1.85 to 2.5V, but there's always 3.2-2.5 = 0.7V left for the emitter resistor plus transistor. Butbutbut that only leaves 0.1V across the transistor. Yep. But if you give enough base current to it, maybe 10ma, it will saturate even harder, and you'll get correct operation. The datasheet parameter that lets this happen is the upper right hand chart on page three, collector-emitter saturation voltage versus collector current at a gain of ten. This chart shows you can get below 0.25V at 10ma if you give it enough base current. So we make the base current maximum be big. We can do that by making the resistor from the base plus diodes let, say, 5ma flow. Now the base has plenty of current available and can run with Vce less than 0.25V, and the variation is all inside the transistor and diode diode voltages. A resistor of (3.2V - 1.2V)/0.005 = 400 ohms should do it. Use 390.

It's a little trickier to set up, but moving the precision from a resistor voltage to diode voltages removes a lot of variation.

You still can't use those high Vf LEDs though.  :icon_cry:
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

axg20202

Wow RG, I'm gonna need some time to digest this, but thanks a million for taking the time to post this. Really appreciate it. I did wonder if my predicament is related to my choice of IC? Perhaps a different PNP would be more suitable and get around this whole problem using my very simple circuit? For example, I think I have some BC557. Also, I still don't understand why I need to increase the supply voltage - I've seen flashlights with a single LED run on a single AA 1.5v battery without any problems, which is why I had assumed my 1.6v would be sufficient. I've just read your post and my brain melted, but in in my defence I have had several glasses of wine. :-)

R.G.

Quote from: axg20202 on May 22, 2010, 06:38:27 PM
I did wonder if my predicament is related to my choice of IC?
Can't tell from here. Which IC are you using?

QuotePerhaps a different PNP would be more suitable and get around this whole problem using my very simple circuit? For example, I think I have some BC557.
Maybe - but then, the 2N3906 is rated as a low current switch. It may be hard to find a silicon bipolar that's a whole lot better than the 3906.
Quote
Also, I still don't understand why I need to increase the supply voltage - I've seen flashlights with a single LED run on a single AA 1.5v battery without any problems, which is why I had assumed my 1.6v would be sufficient.
There are any number of LED driver ICs intended to do just that - drive an LED with a current from a low and variable source of DC. I don't know that this is what's in an LED flashlight, but I do know that LEDs won't run on too low a voltage.

There's a quick way to tell. Just hook up a test circuit on a breadboard. Take your LED, transistor, and resistors, if any, and try to make the thing work. That'll be a very graphic way of telling whether it will work or not. It'll only take a couple of minutes.

QuoteI've just read your post and my brain melted, but in in my defence I have had several glasses of wine. :-)
'S'OK. I'm well into my evening Guinness.

Did you know that the nutritionists have recently found that beer, particularly the darker beers have more antioxidants than red wine?  :icon_biggrin:

Guinness used to use the slogan "It's good for you!" and stopped. Looks like that was premature.  :icon_lol:
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

PRR

This should work, almost-exact 20mA for any voltage from under 3V to over 15V, slightly declining with temperature (a good thing when pushing the limit). It IS a lot of parts.

  • SUPPORTER

R.G.

Quote from: PRR on May 22, 2010, 08:42:06 PM
This should work, almost-exact 20mA for any voltage from under 3V to over 15V, slightly declining with temperature (a good thing when pushing the limit). It IS a lot of parts.
Yeah. I didn't want to go to the fancier current sources. I figured the two-diode one was complicated enough.  :icon_lol:
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

Rob Strand

#11
If the supply doesn't vary much there's not a lot gained using a constant current source.
Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

R.G.

Quote from: Rob Strand on May 22, 2010, 10:29:53 PM
If the supply doesn't vary much there's not a lot gained using a constant current source.
That's true.

Constant voltage circuits (i.e. regulators) and constant current circuits accept the variation within them to produce a more constant something else. They are, in effect, duals of one another. So it's correct to say that if the voltage doesn't vary much, you don't need a constant current source. That means, usually, that the voltage is regulated, so there's one constant X circuit there to start with. It's equally valid to say that if you use a constant current source, you don't gain much by using a constant voltage source.That's one reason I went through that long harangue on the variations in the transistor's saturation voltage and base-emitter voltage, the resistor tolerance, and the variation in the LED voltage. And that's without the power supply variation. I assumed a rock solid power supply in all the calculations.

If nothing changes, you don't need to regulate to a constant voltage or current. And it is possible to adjust on test; put in whatever transistor, LED, etc. that you have, diddle the current by adjusting the resistor, when you get it right, set it. And the next one you put together will have to be individually adjusted too. And the next.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.