Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Detecting DC voltage threshold and firing a relay or switch (Automotive)

Status
Not open for further replies.

danny_b

New Member
Hi everyone. I am junior level electronics hobbyist and I'm hoping to get some help designing some kind of voltage switch for an automotive application.

Precisely what I am trying to do
Detect if the DC voltage on a circuit is above or below a certain threshold (say 1.0V) with reasonable accuracy and toggle a switch or relay if the condition is met WITHOUT influencing the voltage on the circuit.

Background
  • I'm installing automotive gauges that measure engine oil pressure
  • In order to do this, I've had to remove the factory oil pressure switch that goes into the engine block and replace it with an AEM oil pressure sensor that outputs a 0-5V signal corresponding to oil pressure
  • Whilst this works great for the new gauge, the removal of the OEM oil pressure switch means the "low pressure" red light in the vehicle dash is permanently OFF.
  • The OEM oil pressure switch has a single wire that pulls to ground on the engine block when pressure is low.
  • As this sensor is now removed and unplugged, the dash light is permanently off.
  • What I'm trying to do is simulate the output of the factory OEM pressure switch using the signal from the new and improved oil pressure sensor I have installed.
  • i.e. If the output from the new sensor is below 1.0V (indicating low oil pressure) I need to physically connect the now disconnected OEM sensor harness plug in the engine bay to GND, presumably via a relay or switch.
The problem I'm trying to solve
Emulate the output from an OEM oil pressure switch using a new generation oil pressure sensor in a simple, low cost, reliable and elegant way.

Why go to all this effort?
  • I have already explored using Tpieces (to dual mount sensors) and other spare oil gallery port locations in the engine bay, but there is no viable alternative to have both sensors mounted at the same time (i.e. I have to ditch the OEM switch)
  • I've already designed and built a custom harness to run the gauges and new pressure sensor, this is the final piece that would make it perfect and give an OEM feel.
What avenues have I explored
  1. Voltage switch with Zener diodes and similar. I've done some research into diodes and it seems like these could be a cool way to have an electrical switch. I'm not sure if this would be an appropriate pathway to try as they look like they would influence the base circuit Im trying to measure. i.e. I don't want to disrupt the signal voltage from the sensor to the gauge, but somehow measure it and do something.
Diagram Attached
I've attached a simple schematic showing what I'm trying to achieve. I don't want to use anything like an Arduino, Rhaspberry Pi or any advanced circuitry, but I'm happy to build a breadboard and solder a bunch of components if someone can help me design a viable circuit.

Thanks all


Dan
Screenshot 2023-05-03 at 8.00.17 PM.png
 
Last edited:
Yes but your circuit has issues.

You use 12V auto supply and a divider to generate the Vref, but 12V varies significantly, eg
it makes for a poor Vref. Range of "normal" auto V is 11 - 15 volts. Thats roughly a 50%
error in your Vref implmentation.

It shows a 5V regulator feeding the reference???


The post #4 concept would work fine with a two resistor (or resistor & preset, or single preset pot) divider for the comparator reference.

Using eg. an LM311 with that powered from the sender unit 5V supply rather than a separate regulator, with the output from the 311 switching a small MOSFET to drive the lamp should work fine.

The 5V supply is already protected, the only connection to the "raw" 12V power is via the lamp.
 

rjenkinsgb, thanks for picking up on my error.


The 5V regulator of course still has to be protected for load dump.


This seems excessive, but interesting :


Maybe a case could be made for a simple Vz style regulator for comparator to get around
HV transient problems....available in sub 1% tolerance if deemed necessary.

1683372203073.png



Regards, Dana.
 
Last edited:
The 5V regulator of course still has to be protected for load dump.

The new instrument system has the 5V supply included, for the pressure sensor - no new regulators are required, as the 311 would draw only around 5mA at most.

Any proper vehicle instrument will (or should...) already include full protection from spikes and load dump etc.
 
Project Update
Ladies and gentlemen. Thank you all for the helpful guidance so far. Last week I had never heard of an Op Amp, this week and 5 hours of youtube videos later, I'm on op amp no.5, a beautiful rail-to-rail LMC6482AIN and I have a working bench tested circuit. No frills. No fancy hysteresis (yet). Photos and current prototype circuit below.

Make and model of car and sensor
This is for a 1997 WRX STI Japanese import and the oil pressure sensor I'm using is an AEM 150PSI brass unit that outputs 0-5V, specs here.

Working prototype and problems encountered
I've tried 2 voltage comparators (LM393N, LM339M)
I've tried 3 opamps (LM1458N, LM741N, and now working with LMC6482AIN)

I'm treating this like agile software development. Start simple as hell, experiment, test, cry, iterate. The main issue that blocked me is of course my child like understanding of electronics and hopeless assumptions. I assumed voltage comparators worked just like Op-amps as comparators, and that you should get a HIGH and LOW output close to supply voltage and ground. Try as I might, the voltage comparators just never really output above 0.02V despite being inputs above and below the ref voltage and a supply voltage of 5 or 12V. I tried pull up resistors and just failed. I have absolutely no idea how you are supposed to use them for logic high/low and I studied the data sheets.

I then switched to op-amps as you have all originally suggested and got partial success. I wanted to sample a reference voltage of 0.45V (which I produced using a voltage divider from a regulated 5V supply LM7805) BUT the first few cheapy regular op-amps I used had an issue I didn't understand: when they pull to LOW this is still 1.9V. I was expecting closer to 0V, and if my sample voltage was below 1.9V, it's like to opamp can't detect it and go into the high or low state, but I could get a proper expected output state if my sample voltage was above the LOW (i.e. above 1.9V).

In complete despair I read something about rail-to-rail amps and found the CMOS op-amp. Thank the lord this is now behaving as I thought all the op-amps will, and dutifully pulls down to 0.02V as LOW and full supply voltage as HIGH. I can now successfully assess against my 0.45V ref voltage, and I have cheekly driven a 12V dill relay directly from the output of the op-amp. It seems to be working fine.

The dill relay simply acts as a switch to GND signal that is fed to the wiring harness in the engine bay where the OEM pressure switch is mounted. In the factory setup, the OEM sensor simply pulls to ground when oil pressure is low, so I am emulating this. I've checked this is low current (just signal) and does not directly drive the dash light. I'm hoping this means my fragile little dill reed relay will be fine to switch.

Testing all in my car this week. No doubt, as you have all noted I'll probably encounter some noise issues and have to do some refinement and cry in the shower a few more times, but I'm happy I have everything working as it should on the bench. :)
20230516_005705.jpg
Screenshot 2023-05-16 at 10.52.56 PM.png


20230516_005656.jpg
 
If you were working with an open collector comparator it needs to have a pullup
on its output to its supply rail. If it had no load connected to it it would never show
any significant V referenced to its GND or negative rail.

LM339 typical comparator with open collector output :

1684237098102.png


1684238499787.png


As you can see its output has no device to the supply rail, so can only pull output
to ground. Note its inputs are PNP, so they can operate to ground, but not to Vcc
by 2 volts, per above spec, over temperature. NPN inputs just the opposite.

With respect to OpAmps what you found is what is called "common mode input" voltage
range, CMR. the range at which the input can have and still function as a OpAmp. Newer OpAmps
have a CMR of its power rails, and most also can do that on outputs, if load on output very very
small. Parts that CM to both input and output rails are called RRIO, rail to rail input output.

Some OpAmps / Comparators had a property called phase reversal, the output would invert its phase
relationship when its CMR violated. Ugh.......


Some OpAmps CMR actually exceeds rails by a few hundred mV. That property useful in some
circuits like measuring current using shunt in power lead, thats for another day.

I dont see on breadboard diode across relay, but its on your schematic. That diode helps to
suppress high V relay L transients when the relay driver transistor turns off. Two main techniques
are diode and/or snubber. Transients can fry other components in your circuit.

Some transient scope captures over here - https://sound-au.com/articles/relays.htm







Regards, Dana.
 
Last edited:
“…test, cry, iterate…”

Also called the successive approximation method. Which is a totally acceptable method as long as one learns from the things that did not work.
Which means understanding what went wrong and how can you avoid it in the future.
 
you should get a HIGH and LOW output close to supply voltage and ground. Try as I might, the voltage comparators just never really output above 0.02V despite being inputs above and below the ref voltage and a supply voltage of 5 or 12V. I tried pull up resistors and just failed.
Did you connect the output pull-up resistor as I showed in my schematic with the comparator?
 
Here's another circuit using the common TL431, 2.5V shunt reference, and LM339 or LM393 comparator:
It uses a power N-MOSFET to connect the dash lamp (red trace current) to ground when the sensor (green trace) is below 1V.
R3 provides about 100mV of hysteresis.

The circuit can be easily modified to be powered by 5V, if that's preferable.

View attachment 141349
If you want an accurate trigger voltage range, I recommend using an LM3914 with its internal ladder comparator layout. Both the upper and lower limit inputs can be preset for your needs. Tying two or three outputs together with common diode anodes joined together - with a pull-up resistor to positive supply - to the MOSFET gate pin allows for the voltage swing generated in a motor vehicle electrical system.
 
Hi everyone. I am junior level electronics hobbyist and I'm hoping to get some help designing some kind of voltage switch for an automotive application.

Precisely what I am trying to do
Detect if the DC voltage on a circuit is above or below a certain threshold (say 1.0V) with reasonable accuracy and toggle a switch or relay if the condition is met WITHOUT influencing the voltage on the circuit.

Background
  • I'm installing automotive gauges that measure engine oil pressure
  • In order to do this, I've had to remove the factory oil pressure switch that goes into the engine block and replace it with an AEM oil pressure sensor that outputs a 0-5V signal corresponding to oil pressure
  • Whilst this works great for the new gauge, the removal of the OEM oil pressure switch means the "low pressure" red light in the vehicle dash is permanently OFF.
  • The OEM oil pressure switch has a single wire that pulls to ground on the engine block when pressure is low.
  • As this sensor is now removed and unplugged, the dash light is permanently off.
  • What I'm trying to do is simulate the output of the factory OEM pressure switch using the signal from the new and improved oil pressure sensor I have installed.
  • i.e. If the output from the new sensor is below 1.0V (indicating low oil pressure) I need to physically connect the now disconnected OEM sensor harness plug in the engine bay to GND, presumably via a relay or switch.
The problem I'm trying to solve
Emulate the output from an OEM oil pressure switch using a new generation oil pressure sensor in a simple, low cost, reliable and elegant way.

Why go to all this effort?
  • I have already explored using Tpieces (to dual mount sensors) and other spare oil gallery port locations in the engine bay, but there is no viable alternative to have both sensors mounted at the same time (i.e. I have to ditch the OEM switch)
  • I've already designed and built a custom harness to run the gauges and new pressure sensor, this is the final piece that would make it perfect and give an OEM feel.
What avenues have I explored
  1. Voltage switch with Zener diodes and similar. I've done some research into diodes and it seems like these could be a cool way to have an electrical switch. I'm not sure if this would be an appropriate pathway to try as they look like they would influence the base circuit Im trying to measure. i.e. I don't want to disrupt the signal voltage from the sensor to the gauge, but somehow measure it and do something.
Diagram Attached
I've attached a simple schematic showing what I'm trying to achieve. I don't want to use anything like an Arduino, Rhaspberry Pi or any advanced circuitry, but I'm happy to build a breadboard and solder a bunch of components if someone can help me design a viable circuit.

Thanks all


DanView attachment 141337

Here is an alternative circuit but hasn't been tested (see below).
This "level detector" circuit provides a high output level if the input level is ABOVE 1v (pressure OK).
The supply voltage is 5v and the detected voltage level is adjustable from 0.7 to ~4.3v.
"OUT" will connect to the driver circuit that operates the relay and/or switch, and can be modified so its output is low.

The graph to the right shows the output transition to 5V when the input exceeds 1V.

1684436075171.png
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top