# Voltage sensing switch idea?

Discussion in 'Electronic Basics' started by Glenn Ashmore, Feb 4, 2004.

1. ### Glenn AshmoreGuest

I have two circuits A & B. Circuit "A" comes from a pressure sensor and
varies from 0 to 5VDC. Using a couple of resistors as a voltage divider
I can read the pressure on a cheap 200mV LCD meter. Circuit "B"
operates a 12VDC relay that draws 42mA. I am looking for a way to
switch off circuit "B" when the voltage on circuit "A" gets up to 4.5V.
The solution must be cheap (like a dollar or three) and not effect

--
Glenn Ashmore

I'm building a 45' cutter in strip/composite. Watch my progress (or lack
there of) at: http://www.rutuonline.com

2. ### CHRIS.WELSHGuest

maybe a comparator circuit (lm311) driving a transistor switch for higher
current.

3. ### Robert C MonsenGuest

If you have two voltage sources, one at 5VDC, and one at 12VDC, you can do
this with two bipolar transistors, a mosfet, and a couple of resistors.

Use a PNP transistor, with the emitter connected to 5V. The collector is
grounded through a 100k resistor, and the base is connected to your sensor
through another 100k resistor.

As the sensor gets to someplace near 4.4V, the transistor turns on, causing
the collector voltage to rise (due to the 100k resistor.)

The collector of the first transistor, Q1, is connected to the base of a NPN
transistor through a 1MEG resistor. Call the second one Q2. Q2's emitter is
grounded, and the collector connects to the 13V source through a 100k
resistor. When the collector voltage of Q1 rises, it'll turn on Q2, which
will then let current through. That will cause the 100k resistor to 12V to
develop a voltage across it (ie, the collector voltage of Q2 will drop.)

The final step is to use a power P channel mosfet (a 'high side' mosfet).
Connect the gate up to the collector of Q2. That way, when it drops from 12V
to near 0 (as Q2 turns on) this power mosfet will turn on. Connect the drain
of the P-MOSFET to the relay coil, and the other side of the coil to gnd.
The source is 12V. The relay coil is energized when the input goes to about
4.3V.

Here is the circuit (look at it using courier font:

+------------+- 12V
| |
.-. |
| |100k |
| | |
'-' |
| |
| |
|---------||-+
| ||-> P-MOFSET
| ||-+
| |
5V | |
- | .--------------.
100k | | | |
___ |< NPN | | 12V |
IN --|___|--| | | Relay Coil |
|\ 1M | | |
| ___ |/ | |
-|___|-| '--------------'
| |> |
| | |
.-. | |
| |100k | |
| | | |
'-' | |
| | |
+--------+------------+
===
GND
created by Andy´s ASCII-Circuit v1.24.140803 Beta www.tech-chat.de

Regards,
Bob Monsen

4. ### John FieldsGuest

---
It depends on how the relay's being switched, but basically:

+12v>----------------+-------+
| |
| |
0-5V>--+ +------+ |
| | | |
[R1] [R3] | [R4]
| | | |
| +-----|-\ | ___
| | | >-----+ +---->OUT
+---------+--|+/U1 | |
| | | | | C
| | +-----[R5]--+--[R6]---B 2N4401
| | | E
[R2] [CR1] | |
| | | |
GND>---+------+------+-------------------+

The 0-5V is the output from your pressure transducer circuitry and R1R2
is a voltage divider. CR1 is a shunt voltage reference like an
LM385-2.5V and R3 is its current limiting resistor, U1 is 1/2 of an
LM393 (the remaining 1/2 should have its inputs and output shorted to
GND), R4 is the base current source limiter for the 2N4401 and R5 is to
provide hysteresis around the comparator so its output won't chatter for
slowly varying changes in the )-5V input.

If you use an LM385-2.5V for CR1 it'll work fine with 1mA going through
it, so you'll want to drop (12V-2.5V) across R3 with 1mA going through
it, so that comes out to R3 = (12V-2.5V)/1mA = 9500 ohms, so just stick
10k in there and it'll be fine too. For 10k it'll dissipate 9.5V*0.95mA
~ 9mW, so a 5% 1/4 watter will work just fine as well.

Looking at the input divider, R1R2, what we want it to do is to generate
a voltage at the junction of R1 and R2 which, when the input voltage
gets to 4.5V is going to make the comparator switch. Since the - input
of the comparator is sitting at the reference's 2.5V, that means the
voltage at the R1R2 junction needs to be 2.5V when the output of the
transducer circuitry is 4.5V. Not knowing how much current the
circuitry can supply is a little bit of a problem, but if we assume
100µA we can figure out R1 and R2. If we can have 100µA flowing through
R1 and R2, then to make the hot end of R2 sit at 2.5V we can say R = E/I
= 2.5V/100µA = 25k ohms. Assuming that you want to get pretty close to
that 2.5V and that your reference is spot on, the closest standard 1%
resistor is 24.9k, which is only 100 ohms (+/- the tolerance of the
resistor, 250 ohms) off. Now, we can do the same for R1, and since we
want to drop 2V across it at 100µA, that works out to 20k ohms, a
standard 1% value!

Next, I'm assuming that your relay switching circuitry looks something
like this:

+12V
|
+-------+
|K |
[DIODE] [COIL]
| |
+-------+
|
C
ON>---[R]----B NPN
E
|
GND

And that by doing this:

+12V
|
+-------+
|K |
[DIODE] [COIL]
| |
+-------+
|
C
ON>---[R]--+---B NPN
| E
___ | |
OUT>-------+ GND

We can pull down the base of the transistor turning the relay on,
forcing the relay to open, no matter what.

Combining the two circuits, we'll have:

+12V
|
+-------+
|K |
[DIODE] [COIL]
| |
+-------+
|
C
ON>--------------------------------[R]--+---B NPN
| E
| |
| GND
|
|
+12v>----------------+-------+ |
| | |
| | |
0-5V>--+ +------+ | |
| | | | |
[20k] [10k] | [12k] |
| | | | |
| +-----|-\ | |
| | | >-----+ |
+---------+--|+/U1 | |
| | | | | C
| | +-----[R5]--+--[91k]--B 2N4401
| |K | E
[24.9k] [CR1] | |
| | | |
GND>---+------+------+------------------+

What we'll want to do is divert the base current of your relay driver to
GND, and to do that properly we'll need to saturate the CE juncton of
the 2N4401, which will cause about 0.3V to appear across it, which
would surely cut off the relay driver. Since the relay draws 42mA, if
we assume a forced beta of 10 for its driver, that leaves us with 4.2mA
to divert to GND. If we force the 2N4401's beta to 10 and it has to
sink 4.2ma, then that means all we have to do to turn it on is force
420µA into its base and we'll be done. But... there _is_ still R5 to
figure out. It's there for hysteresis, and it serves to keep the
comparator's output from chattering when its + input goes through the
switching point slowly. The 2N4401 will only be required to sink the
relay driver transistor's base current to turn it off, so if we set it
up to sink 1mA and force its beta to 10, it'll only need 100µA of base
current to turn on, so if we make the sum of R4 and R6 drop 1.3V with
100µA flowing through them that'll do it. We need R6 because with the
2N4401 fully turned on, its base to emitter voltage will only be about
1.3V, which would never allow the comparator's + input to get to the
2.5V switching point! So, R4+R6 needs to be (12V-1.3V)/100µA = 107k
ohms. 100k is close enough, and R4 needs to be large enough to make
sure the comparator's output transistor never comes out of saturation
when it's on. It can handle 4mA, but if we keep it down around 1mA
that'll make sure we have no problems, so R4 needs to drop 12V at 1mA,
which makes it 12k. Then, since R4+R6 needs to be 100k, R6 needs to be
88k. 91k is a standard 5% value, and it's close enough, so R6 will then
be 91k, and 1/4 watt resistors will be plenty big for both R4 and R6.

Now, the purpose of R5 is to source and sink a tiny bit of current into
and out of the junction of R1 and R2 so that when the comparator turns
off and on it forces the voltage on the + input to quickly rise and fall
past the 2.5V switching threshold, helping to avoid any noise problems
which would tend to make the comparator's output chatter. If we assume
that 10mV of hysteresis would be enough, then we have to make the
voltage across R2 rise by 10mV, and since R2 is 24.9k, that means we
have to force an extra I = E/R = (2.51V-2.5V)/24.9K = 402nA through it.
Since, when the comparator turns off, the base to emitter voltage of the
2N4401 will rise to 1.3V, R4 and R6 will form a voltage divider with one
end at 12V and the other at 1.3V, and the voltage at the junction of R4
and R6 will go to:

12V*R4
E = -------- + 1.3V = 7.95V ~ 8V
R4+R6

Which is going to cause a problem in that it will cause the hysteresis
to be asymmetrical about the switching point. Since the switching point
is at 2.5V and the comparator's output goes to 0V when it turns on,
pulling one end of R5 to 0V, we would like for that end of R5 to go to
+5V when the comparator turns off, making the input to R5 symmetrical
about 2.5V. That way, the hysteresis will also be symmetrical around
the switching point.

What we need to do to make that happen is to change the values of R4 and
R6 so that the voltage at their junction will be 5V when the comparator
is off. If, when the comparator is off, we allow 1mA of current to
flow through R4 and R6 then, to make the voltage at their junction be
5V, we need to drop 7V across R4. That means R4 needs to be 7k. The
two 5% choices available are 6.8k and 7.5k, so let's choose 6.8k and see
what happens. First off, if we want to drop 7V across 6.8k, the current
through it has to be 1.03mA, which means that current is also going to
be flowing through R6 and into the B-E junction of the 2N4401. The base
is going to be sitting at about 1.3V, so that means R6 will have to drop
5V-1.3V = 3.7V at 1.03mA, so it will need to be 3.7V/1.03mA = 2.98k. 3k
is a standard 5% so, since that 1.3V is only approximate, 6.8K for R4
and 3k for R6 should be OK.

Now, looking at R5 again, we'll need to drop about 2.5V across it at
400nA, so it'll need to be 2.5V/400nA = 6.25M. 6.2M is a standard 5%
value, so that's pretty close, and here's your final(?) circuit

+12V
|
+-------+
|K |
[DIODE] [COIL]
| |
+-------+
|
C
ON>---------------------------------[R]--+---B NPN
| E
| |
| GND
|
|
+12v>----------------+--------+ |
| | |
| | |
0-5V>--+ +------+ | |
| | | | |
[20k] [10k] | [6k8] |
| | | | |
| +-----|-\ | |
| | | >------+ |
+---------+--|+/U1 | |
| | | | | C
| | +-----[6M2]--+--[3k]---B 2N4401
| |K | E
[24.9k] [CR1] | |
| | | |
GND>---+------+------+-------------------+

Interesting how something simple can turn out not to be huh?

BTW, if your relay driver configuration is different from what I
assumed, post back and we'll make everything match up.

5. ### John FieldsGuest

On Thu, 05 Feb 2004 06:29:12 -0600, John Fields

Errors, sorry...

7. ### Glenn AshmoreGuest

Now you got me thinking about the overall plan. This is one part of an
interlock circuit consisting of 3 transistors and 2 switches in series
on the low side of a relay. The relay is latched on by routing the
ground of the coil through one pole of the relay and then through the
interlock circuit. If the circuit is broken the relay unlatches.

+-------------+
|/ | +12V
Pressure Switch -| | |
|> | +-----+
| o | |
| / _|_ -
| / |_/_|- ^
| o/ o | |
|/ | | +-----+
Low RPM -| GND |
|> |
| |
| |-------o |
|/ | |=| ON Button
High RPM -| | o |
|> | |
| | GND
o |
Oil Pressure '\ |
o \ o |
| | |=| Off Button (NC)

Would it be better to have one "master" transistor at the relay which is
held on and have the sensor output transistors drain its base like this
when something gets out of spec?

VDD
| OIL STOP
+-----+--------+
| | | T T
|/ | --- --- ---
Pressure -| | GND -v \----o o----o o-+
|> | |
| | | T
GND | _/ | ---
| +-o/ o-------+--o o-GND
+-----+ | _
|/ | | | |
Low RPM -| | +--|\|- +12V
|> | |_|
| | |
GND |
+-----+
|
|/
High RPM -|
|>
|
GND

Also, what are the implications of having transistors and mechanical
switches in series like this?

--
Glenn Ashmore

I'm building a 45' cutter in strip/composite. Watch my progress (or lack
there of) at: http://www.rutuonline.com

8. ### John FieldsGuest

---
Yes, but it looks like the transistors are wired backwards unless, for
some reason, they're supposed to be PNP's.
---
---
I don't know about 'better', but I like this way much better than the
other because each transistor's emitter is being independently referred
to ground and is being switched independently of the others without
being daisy-chained emitter to collector to emitter to collector to...
---
---
AFAIK, just force the transistor into saturation so it won't dissipate
much power with the relay switched ON, and make sure the mechanical
switch contacts have enough current flowing through them so that you
won't wind up with high resistance contact crud problems. Also, if
you're going to be doing this at sea, MAKE SURE any relays you use are
sealed. Not just with a plasic cover over them, but _hermetically_
sealed.

9. ### Glenn AshmoreGuest

This was my first attempt at this ASCII schematic program. I was lucky
to get anything much less get it wired correctly.
Thanks. I will adjust my schematic.

The relays are sealed Omrons, the switches are waterproof membranes and
I have a big can of conformal coating for the board.

--
Glenn Ashmore

I'm building a 45' cutter in strip/composite. Watch my progress (or lack
there of) at: http://www.rutuonline.com