Author Topic: Relay switching circuit...sanity check  (Read 5622 times)

0 Members and 1 Guest are viewing this topic.

Offline ampdoctorTopic starter

  • Frequent Contributor
  • **
  • Posts: 266
  • Country: us
Relay switching circuit...sanity check
« on: December 02, 2014, 06:57:44 pm »
Below I've attached a schematic of a very simple relay driver circuit. Problem is that it seems almost too simple. While I haven't physically built it, the thing simulates just fine and with very few modifications should mate up with micro's, latches, etc. Anything that produces logic high or low.
It seems simple, low cost, robust and easily modifiable to work with different loads, switching methods, or rail voltages. So after all that wordiness, the question comes down to...where is the brain fart, and what am I missing? It just can't be this simple.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19494
  • Country: gb
  • 0999
Re: Relay switching circuit...sanity check
« Reply #1 on: December 02, 2014, 09:00:02 pm »
It looks fine to me. The only thing which could be a problem is Q1 may need more base current, try omitting R1.
 

Offline Mr Smiley

  • Frequent Contributor
  • **
  • Posts: 324
  • Country: gb
Re: Relay switching circuit...sanity check
« Reply #2 on: December 02, 2014, 09:16:08 pm »
If you omit R1 you will be shorting Vcc to ground through the switch or logic low of any driving circuit  :palm:

 :)
There is enough on this planet to sustain mans needs. There will never be enough on this planet to sustain mans greed.
 

Offline jlmoon

  • Supporter
  • ****
  • Posts: 609
  • Country: us
  • If you fail the first time, keep trying!
Re: Relay switching circuit...sanity check
« Reply #3 on: December 02, 2014, 09:30:55 pm »
Remove R2 and make R1 ... 2200 ohms and you should be good.  Even 1k ohms as R1 and R3  would work.
« Last Edit: December 02, 2014, 09:32:38 pm by jlmoon »
Recharged Volt-Nut
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 19470
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Relay switching circuit...sanity check
« Reply #4 on: December 02, 2014, 09:33:49 pm »
Below I've attached a schematic of a very simple relay driver circuit. Problem is that it seems almost too simple. While I haven't physically built it, the thing simulates just fine and with very few modifications should mate up with micro's, latches, etc. Anything that produces logic high or low.
It seems simple, low cost, robust and easily modifiable to work with different loads, switching methods, or rail voltages. So after all that wordiness, the question comes down to...where is the brain fart, and what am I missing? It just can't be this simple.

Why don't you simulate it with an inductor? Simulating only the relay's resistance is rather missing the point!
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline Mr Smiley

  • Frequent Contributor
  • **
  • Posts: 324
  • Country: gb
Re: Relay switching circuit...sanity check
« Reply #5 on: December 02, 2014, 10:04:33 pm »
To guarantee full saturation of the transistor, use the Ib = 1/10 of Ic rule. Using the Min hfe from the specs for the transistor being used.

Remember if Ib is high for your first transistor, that might exceed any logic/micro output currents, so you might need a Darlington on the first stage.

Or you could just use mosfets  :o

What is the load current of your relays  :-/O

 :)

There is enough on this planet to sustain mans needs. There will never be enough on this planet to sustain mans greed.
 

Offline ampdoctorTopic starter

  • Frequent Contributor
  • **
  • Posts: 266
  • Country: us
Re: Relay switching circuit...sanity check
« Reply #6 on: December 02, 2014, 11:38:44 pm »
Why don't you simulate it with an inductor? Simulating only the relay's resistance is rather missing the point!
Using a resistive equivalent is just being lazy for the sake of proof of concept simulation. I also don't want to lock myself into just using relays. At some point I may want to use LDR's or something else.

I'm trying to come up with a very simple generic switching circuit that can be substituted into a number of different applications.

To guarantee full saturation of the transistor, use the Ib = 1/10 of Ic rule. Using the Min hfe from the specs for the transistor being used.

Remember if Ib is high for your first transistor, that might exceed any logic/micro output currents, so you might need a Darlington on the first stage.

Or you could just use mosfets  :o

What is the load current of your relays  :-/O

 :)

relay 1(R6) is going to draw 200mA and the other(R7) draws 100mA. Component values aren't exactly optimized but they're close enough as a general solution. As I mentioned higher up in the comment, I'd like to be able to use this circuit under any number of different conditions with the fewest topological changes as I can get away with.
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 19470
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Relay switching circuit...sanity check
« Reply #7 on: December 03, 2014, 12:39:13 am »
Why don't you simulate it with an inductor? Simulating only the relay's resistance is rather missing the point!
Using a resistive equivalent is just being lazy for the sake of proof of concept simulation.

So lazy that you haven't actually proved anything about using a relay coil - only about using a resistor. Hmm.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline ampdoctorTopic starter

  • Frequent Contributor
  • **
  • Posts: 266
  • Country: us
Re: Relay switching circuit...sanity check
« Reply #8 on: December 03, 2014, 02:25:11 am »
Who gives a damn? I change relays within a series or manufacturers and the data becomes useless because the inductances and/or coil resistances are going to vary substantially. I'm not designing launch vehicles or life support equipment here. It's just a simple switching circuit. All I need is a lumped element model to approximate the load current to see if the transistors will respond roughly as expected. So calm down and don't get your panties in a knot. Unless you can give me a damn good reason to accurately model the coil, your comment makes you sound like a petty internet troll looking to pick a fight while not actually contributing anything of value to the discussion.
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 19470
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Relay switching circuit...sanity check
« Reply #9 on: December 03, 2014, 09:20:41 am »
Who gives a damn?

Clearly you care enough to spend time doing the simulation and then asking us to spend our time critiquing it.

Quote
I change relays within a series or manufacturers and the data becomes useless because the inductances and/or coil resistances are going to vary substantially.

In which case what do you expect to learn from a single simulation, when you could more easily get a better understanding from the simple key equations that define the operation across a whole range of conditions? That suspicion is confirmed by your next statement...

Quote
I'm not designing launch vehicles or life support equipment here. It's just a simple switching circuit. All I need is a lumped element model to approximate the load current to see if the transistors will respond roughly as expected. So calm down and don't get your panties in a knot.

Pot, kettle, black :)

Quote
Unless you can give me a damn good reason to accurately model the coil, your comment makes you sound like a petty internet troll looking to pick a fight while not actually contributing anything of value to the discussion.

Don't waste our time asking for answers you aren't prepared to listen to, nor information that you don't actually want!
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19494
  • Country: gb
  • 0999
Re: Relay switching circuit...sanity check
« Reply #10 on: December 03, 2014, 11:44:46 am »
Remove R2 and make R1 ... 2200 ohms and you should be good.  Even 1k ohms as R1 and R3  would work.
Sorry, that's what I meant to say.
To guarantee full saturation of the transistor, use the Ib = 1/10 of Ic rule. Using the Min hfe from the specs for the transistor being used.

Remember if Ib is high for your first transistor, that might exceed any logic/micro output currents, so you might need a Darlington on the first stage.
It doesn't need to be in full saturation to work, a voltage drop of around 1V or so shouldn't cause any problem, so a forced beta of 100 should be fine.
 

Offline LukeW

  • Frequent Contributor
  • **
  • Posts: 686
Re: Relay switching circuit...sanity check
« Reply #11 on: December 03, 2014, 12:03:00 pm »
Modern LEDs typically don't need current that high to have a good light output. I typically use 1k for LED series resistors in 3-5V systems.
 

Offline extide

  • Regular Contributor
  • *
  • Posts: 95
  • Country: us
    • Rovitracker - Rental management AND Real-Time data!
Re: Relay switching circuit...sanity check
« Reply #12 on: December 03, 2014, 08:52:43 pm »
What is the purpose of the transistors in this circuit? Why not just switch the relays directly with the switch? Can someone explain how this circuit works?

Do the transistors make it so you see less switching current at the switch? How exactly does that work?
Thanks!
 

Offline max_torque

  • Super Contributor
  • ***
  • Posts: 1275
  • Country: gb
    • bitdynamics
Re: Relay switching circuit...sanity check
« Reply #13 on: December 03, 2014, 11:48:49 pm »
TBH, in 2014, i'm not sure why anyone bothers to "roll their own" drivers, unless you are making 10,000 units and trying to save every single last $$.   Just use one of the off the shelf relay/solenoid driver ICs, that can if required drive multiple channels, and also often have diagnostic / safety functions / limitations etc.  For home/hobby use, i've found that soldering a single IC into place is "cheaper" than pretty much any discrete solution due to the faster assembly, and less chance of mistakes creeping in etc.......
 

Offline ampdoctorTopic starter

  • Frequent Contributor
  • **
  • Posts: 266
  • Country: us
Re: Relay switching circuit...sanity check
« Reply #14 on: December 04, 2014, 02:28:47 am »
What is the purpose of the transistors in this circuit? Why not just switch the relays directly with the switch? Can someone explain how this circuit works?

Do the transistors make it so you see less switching current at the switch? How exactly does that work?
Thanks!
Sure, you could switch the relays directly with say a mechanical SPDT switch to ground and it would work just fine and be a lot simpler, IF that's the only way you're changing states. Also mechanical switches are statistically more prone to failure. However, let's say you need the relays activated through a momentary switch(higher reliability), or you're getting a logic signal from some other source to turn on and off some pumps or whatever you're doing, then things get a little more tricky. That's why I drew it up using a rather generic switch...for ease of illustration and proof of concept.

In terms of general circuit operation, when the switch is open or logic high, the junction of R1 and R2 sees roughly 5 volts and the amount of current flowing through the base of Q1  is set by the value of R2.

When Ib(Q1) is high enough to turn the transistor on you see a current flow from collector to emitter of Ic = hfe(or beta)*Ib. This looks a lot like a short to the relay and its turned on. In this state the voltage seen at the collector of Q1 is low, around 300mV give or take and is lower than the pn diode drop across the base emitter junction of Q2 which keeps that transistor turned off. In other words, the be junction is reverse biased, therefore no significant current flows from collector to emitter in Q2 and relay 2 is turned off because it looks like an open.

Now, when the switch is closed or low, Q1 is turned off and no current flows from its collector to emitter so the collector voltage is close to the rail voltage. This is high enough to get a small amount of current flowing though the base of Q2 and is calculated the same way we did for Q1. Now that we have base current flowing Q2 turns on and current flows across its collector emitter junction and relay 2 activates. End result is that we've got one switch or signal toggling the state of two transistors.

R4 and R5 are just current limiting resistors for the LED's and are calculated using Ohm's Law and the max allowable current of whatever diode you decide to use.

Having said that, the circuit is NOT perfect. The one primary issue is that Q1 and Q2 are beta dependent biased. This means that if beta drifts over time or through junction temperature changes the circuit's operating points will change so you need to allow for that in the design process or use independent beta biasing. You could do that by creating a voltage divider by putting R2 to ground and attaching the base to the junction. Then calculate the base current using Ohm's Law. You can do something similar with R3 and Q2.

And yes, I left out a lot of details for the sake of clarity to conceptually understand the basic operation of the circuit.

TBH, in 2014, i'm not sure why anyone bothers to "roll their own" drivers, unless you are making 10,000 units and trying to save every single last $$.   Just use one of the off the shelf relay/solenoid driver ICs, that can if required drive multiple channels, and also often have diagnostic / safety functions / limitations etc.  For home/hobby use, i've found that soldering a single IC into place is "cheaper" than pretty much any discrete solution due to the faster assembly, and less chance of mistakes creeping in etc.......
Generally I can agree with this. However, in this particular case these relays will be operated continuously and I'd be right at the margin of what I can get away with using something like a uln2x03 or similar chip. If you know of a chip that can sink 300mA/channel all day long in an enclosure with no airflow then I'm all ears brother! Can I get away with it using a ULN2803? Probably, but I don't like to push my luck and I like lots of design margin. Also, when I do custom work for people I lose track of the chain of custody and have no clue who will service these things or what resources they have available so I would prefer to use jelly bean parts and rather generic switching transistors, diodes, etc that Joe Schmoe can get hold of in the middle of BFE nowhere. So it's less of an engineering decision and more of a customer service decision. Saves me headaches down the road.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19494
  • Country: gb
  • 0999
Re: Relay switching circuit...sanity check
« Reply #15 on: December 04, 2014, 11:15:26 am »
Quote
Having said that, the circuit is NOT perfect. The one primary issue is that Q1 and Q2 are beta dependent biased. This means that if beta drifts over time or through junction temperature changes the circuit's operating points will change so you need to allow for that in the design process or use independent beta biasing. You could do that by creating a voltage divider by putting R2 to ground and attaching the base to the junction. Then calculate the base current using Ohm's Law. You can do something similar with R3 and Q2.

Providing the base current is high enough, that shouldn't be a problem. Just ensure the base current is more than high enough to give sufficient collector current at a low collector-emitter voltage.
Quote
Generally I can agree with this. However, in this particular case these relays will be operated continuously and I'd be right at the margin of what I can get away with using something like a uln2x03 or similar chip. If you know of a chip that can sink 300mA/channel all day long in an enclosure with no airflow then I'm all ears brother! Can I get away with it using a ULN2803
The ULN2803 should do but just for two channels, it's not really worth it.
 

Offline Richard Crowley

  • Super Contributor
  • ***
  • Posts: 4317
  • Country: us
  • KJ7YLK
Re: Relay switching circuit...sanity check
« Reply #16 on: December 04, 2014, 12:37:23 pm »
Does the 1K value of R1 represent some limit to the drive power available?
The reason for the question is because in some cases you may be running into limits of switching current vs. drive current vs. the hfe (current gain) of the switching transistors.  That is why people are asking questions about the resistance value of R1 and R2/R3.  You can't expect to pick the value of R2/R3 without taking into account the gain of the particular transistor, and the current requirement of the load (the relay coil + LED) In cases of limited drive current and heavy load current, you may need something with much more current gain such as a Darlington pair or MOSFET

What kind of switch is S1?  Can it be a SPDT (so that you don't need to pull against R1)?  Does it require de-bouncing?

I don't see much point in simulating the inductance of the relay coils. Except that you can simply assume that they have some significant inductance (unless they are solid-state relays, etc.)  So providing a reverse diode across the relay coil (to absorb the current generated by the collapsing magnetic field) seems like a hard requirement to prevent early failure of the switching transistors.

Remember that most relay switches are available in "form-C" (double-throw) with varying number of poles. So alternately driving two relays may be overkill in many applications where you could just take advantage of the switch contacts on a single relay.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf