5v Digital Signal to Solid 12V

Thread Starter

bwilliams60

Joined Nov 18, 2012
1,450
I have this diagram here and want to know if it will work for what I am after. I would like to control solid 12V through a relay using a 5V digital signal on the control side. It would be a Hall Effect signal so square wave.

What I do not understand, is what happens when the wave is low (0). Will the relay momentarily shut off? And if so, is there a way to get it to stay on 100% of the time? If so, how would this be done?

The relay will draw up to 100mA at 12v when it is used in an automotive style circuit.
 

Dodgydave

Joined Jun 22, 2012
11,395
Yes the relay will turn off when the signal goes low. The only way to keep it on momentarily is to put a capacitor across it's coil, or a capacitor feeding the transistor base.
 

Marc Sugrue

Joined Jan 19, 2018
222
The circuit should work for controlling the relay High = On, Low = OFF. Depending on the frequency the relay will certainly chatter. Putting a relatively large capacitor across the 10k with an additional base resistor from the 10k to the NPN base will create a RC filter to smooth your square wave input into more of a DC level. Other, more complex options are possible by creating a monostable with a 555 timer with a time element set to 'ride through' the pulses.

*EDIT

OR as DodgyDave says a Cap across the relay could work but it will depend on the duration of the holdup you need. A large capacitor will take time to charge and may require a larger transistor to deal with the pulse currents.
 

Reloadron

Joined Jan 15, 2015
7,867
As drawn the relay will be energized when the logic level on tha base of the transistor is high symbolized by the logic 1 as drawn. When low logic 0 the relay will be off. I see as I typed quaestio asked and answered. What exactly are you trying to do?

Ron
 

ebp

Joined Feb 8, 2018
2,332
Under what condition is the relay to turn off? I presume you don't mean the relay turns on and stays on "forever."

Unless you can be sure the output of the Hall effect sensor goes the the right level (logic zero, in the circuit shown) when the relay is to turn off, you will need more circuitry. If the sensor were monitoring a motor shaft, for example, and the shaft stopped turning with the magnet near the sensor and that condition resulted in a HIGH from the sensor, the relay would stay on with the shaft not turning. If it is something like monitoring something to determine if it is moving, then you would need to decide what you require in terms of behavior at start up and shut down. You can do things like cause the relay to pull the first time the magnet crosses the sensor at startup. Behavior at stopping can be more tricky because the "re-triggering" events will come more and more slowly - you either wind up responding to them individually (relay clicks on an off repeatedly) or accept that the relay won't drop until perhaps seconds after the motion has finally ceased.
 

Thread Starter

bwilliams60

Joined Nov 18, 2012
1,450
Thank you for the answers so far.
I am looking to have a relay turn on and stay on when it sees a digital signal from a Hall Effect sensor and turn off when it does not.
The signal would control a 12v relay.
The next part would be to control a 1v relay using a pulse generator (sine wave).
Right now, I am happy solving the first part if there is such a solution. I want the relay on 100% once it sees a digital signal.
 

Reloadron

Joined Jan 15, 2015
7,867
Thank you for the answers so far.
I am looking to have a relay turn on and stay on when it sees a digital signal from a Hall Effect sensor and turn off when it does not.
The signal would control a 12v relay.
The next part would be to control a 1v relay using a pulse generator (sine wave).
Right now, I am happy solving the first part if there is such a solution. I want the relay on 100% once it sees a digital signal.
That is what the circuit you posted will do. While the base of the transistor is a logic 1 the relay is on or energized. It works as drawn.

Ron
 

Marc Sugrue

Joined Jan 19, 2018
222
Thank you for the answers so far.
I am looking to have a relay turn on and stay on when it sees a digital signal from a Hall Effect sensor and turn off when it does not.
The signal would control a 12v relay.
The next part would be to control a 1v relay using a pulse generator (sine wave).
Right now, I am happy solving the first part if there is such a solution. I want the relay on 100% once it sees a digital signal.
Thank you for the answers so far.
I am looking to have a relay turn on and stay on when it sees a digital signal from a Hall Effect sensor and turn off when it does not.
The signal would control a 12v relay.
The next part would be to control a 1v relay using a pulse generator (sine wave).
Right now, I am happy solving the first part if there is such a solution. I want the relay on 100% once it sees a digital signal.
Based on this I think you need to look into "window comparitor with hysteresis" to provide a logic signal to the transistor and filter your pulses using a RC filter feeding into the comparitor input

https://www.analog.com/en/analog-di...g-comparator-instability-with-hysteresis.html

http://rohmfs.rohm.com/en/products/...mp_linear/comparator/gpl_cmp_hysteresis-e.pdf
 

sghioto

Joined Dec 31, 2017
8,634
Adding a couple of capacitors should handle the problem. The values shown on the edited schematic are a starting point. The 10uf may need to be higher depending on the frequency of the pulse from the sensor.
SG
EEE relay hall effect.PNG
 

ebeowulf17

Joined Aug 12, 2014
3,307
Adding a couple of capacitors should handle the problem. The values shown on the edited schematic are a starting point. The 10uf may need to be higher depending on the frequency of the pulse from the sensor.
SG
View attachment 162209
Don't you need a current limiting base resistor between the 10uF and the transistor? Otherwise I'd think it will discharge more or less instantaneously through the base.

Perhaps also a diode after the input cap. I'd have to think about it some more - l feel like this is on the right track, but not there yet...
 

ebp

Joined Feb 8, 2018
2,332
Don't you need a current limiting base resistor between the 10uF and the transistor? Otherwise I'd think it will discharge more or less instantaneously through the base.

Perhaps also a diode after the input cap. I'd have to think about it some more - l feel like this is on the right track, but not there yet...
Sounds right to me. I"d move the "filter" cap to the left side of the 1k resistor, add a series diode between that cap and the input cap and another diode from the inboard end of the input cap to ground (anode to ground). This would allow "pumping up" the bigger cap. The extra diode is needed as a discharge path for the input cap. This might be a bit cruel to the output of the Hall sensor, so a small resistor in series with the input might be prudent. The input cap may need to be higher in value. Too many things are unknown.

Alternatively, the input cap and diode could be arranged to make a voltage doubler, but I'm not sure there is any particular merit to that.

This is not a good way to run a relay that has to handle much current because both opening and closing will be slow, which fosters extended arcing time. A second transistor (PNP) to provide some positive feedback (hysteresis) would be an improvement.
 

ebeowulf17

Joined Aug 12, 2014
3,307
add a series diode between that cap and the input cap and another diode from the inboard end of the input cap to ground (anode to ground). This would allow "pumping up" the bigger cap. The extra diode is needed as a discharge path for the input cap.
I knew I was missing something critical in there! That's the missing ingredient.
 

Thread Starter

bwilliams60

Joined Nov 18, 2012
1,450
Has anyone come up with a viable working diagram of the finished circuit? Sorry I am following the conversation but I am unsure of the finished product and the values used.
Thanks sgain for everyones input so far.
 

ebeowulf17

Joined Aug 12, 2014
3,307
Has anyone come up with a viable working diagram of the finished circuit? Sorry I am following the conversation but I am unsure of the finished product and the values used.
Thanks sgain for everyones input so far.
I'd be happy to try drawing it up, but two questions first:

How much current does the relay coil draw? If you're not sure, share a datasheet, or at the very least a part number, and we can help figure that out.

What is the longest pulse gap that needs to register a continuous relay output? Should the relay turn off after a tenth of a second, half a second, ten seconds?
 

Thread Starter

bwilliams60

Joined Nov 18, 2012
1,450
Okay the relay will draw between 150 and 200 mA. I would like the relay to be on constantly once it sees a vehicle in motion. It would be working off of the VSS so not sure what you are asking me in the second question??
 

Reloadron

Joined Jan 15, 2015
7,867
I am looking to have a relay turn on and stay on when it sees a digital signal from a Hall Effect sensor and turn off when it does not.
A Hall effect sensor is a transducer that varies its output voltage in response to a magnetic field. Hall effect sensors are used for proximity switching, positioning, speed detection, and current sensing applications.

Okay the relay will draw between 150 and 200 mA. I would like the relay to be on constantly once it sees a vehicle in motion. It would be working off of the VSS so not sure what you are asking me in the second question??
That doesn't sound like a Hall Effect sensor. You are describing what sounds more like a motion detector, A passive infrared sensor (PIR sensor) is an electronic sensor that measures infrared (IR) light radiating from objects in its field of view. They are most often used in PIR-based motion detectors.

The very first circuit you posted will hold the relay on (energized) as long as your sensor outputs a logic level high. What exactly is your sensor you plan to use? Vague descriptions are not going to get you a solution. A Hall Effect sensor is not used to detect a vehicle in motion. Assuming the vehicle emits heat a PIR sensor would. You need to be a little specific here with the sensor.

Also a BC337 or 2N2222 will do fine for the relay you mention. Any NPN common switching transistor will work as long as the collector current well enough exceeds what your relay coil needs.

Ron
 

ebeowulf17

Joined Aug 12, 2014
3,307
Okay the relay will draw between 150 and 200 mA. I would like the relay to be on constantly once it sees a vehicle in motion. It would be working off of the VSS so not sure what you are asking me in the second question??
The hall effect "signal" isn't continuously broadcasting that it exists. It's either a high or a low voltage. Assuming we're dealing with a Hall effect sensor on a rotating shaft, when the shaft turns far enough, it changes states from high to low or vice versa. We can make a circuit respond to those state changes, but there will always be periods of dead time in between state changes. The faster the shaft is spinning, the shorter the dead time. As the shaft slows down, the dead time between state changes gets longer and longer, even if the shaft is still turning. So, at what speed do we no longer consider the shaft to be turning? The answer can't be zero RPM / infinite pulse length or else the circuit never turns off until you disconnect power.

You have to choose some minimum speed that counts as stopped, even if it's not totally stopped. The flip side of this is that the lower your minimum detection speed, the longer it takes for the circuit to deactivate after you have actually stopped. If you consider 1 pulse per second to still be moving, then the circuit must wait at least one second after the last pulse it detects before it turns off. If you consider 1/minute still moving, then it takes 1 minute after last pulse to turn off. See the problem?

You've got to pick a minimum speed/maximum pulse duration.
 
Last edited:

Thread Starter

bwilliams60

Joined Nov 18, 2012
1,450
Okay lets back up the bus a moment and see if we can all get on the same page. First of all, I know the difference between a PIR sensor and a Hall Effect sensor. A vehicle can use either a 3 wire Hall effect or 2 wire pulse generator to produce a speed signal (movement) and send that signal to an ECU where is gets cleaned up, digitalized etc. Whether the signal is digital from the HE sensor or analog from the VR sensor, I need it to be able to somehow control a 12V signal. I would like it to provide 12V when the vehicle is in motion and 0V when the vehicle is stopped. Hence the relay. I figured this was the only way to even come close to being able to provide constant 12V output.
Okay, as for speed, I need it to do this as soon as it starts to move (as close as possible), and I need it to shut off when it has stopped moving (as soon as possible). Sorry, does that make more sense? I am not trying to be vague, maybe just not explaining it correctly. Hope this helps.
 

ebeowulf17

Joined Aug 12, 2014
3,307
Okay, as for speed, I need it to do this as soon as it starts to move (as close as possible), and I need it to shut off when it has stopped moving (as soon as possible). Sorry, does that make more sense? I am not trying to be vague, maybe just not explaining it correctly. Hope this helps.
I get it, but I have literally no idea what kind of pulse rates we're talking about, having not messed with any of these signals in a car before. So, I need a ball park relationship between vehicle speed and pulse rate. If you're messing around with automotive wiring and tapping into ECU Hall effect signals, you must know more of these things than l do.

If you have any idea of the relationship between pulse rate and vehicle speed, let me know. Otherwise, I'll just guess pulse transitions must be faster than 1Hz for 1mph speed, and design accordingly, with a one second delay after stopping before relay opens.

I got a rough conceptual simulation done this morning, but hadn't picked good component values for timing yet. Can't work on it for the next several hours at least, but I'll try to get something presentable tonight or tomorrow morning.
 

Reloadron

Joined Jan 15, 2015
7,867
OK, now it all makes sense. This likely depends on vehicle but on one of my old trucks they used a speed pick up on the transmission. It was only a two wire sensor with no external excitation. Anyway, knowing things now I would just run your pulses into a re triggerable one shot or missing pulse detector with a slow enough RC time constant. The trick is knowing what you actually have for pulses. I do know that pulse rate will vary from vehicle to vehicle.

Sorry I was slow on the uptake. :(

Ron
 
Top