PWM for efficient relay circuit: some questions!

Thread Starter

cspwcspw

Joined Nov 8, 2016
78
I'd like to pull in a 5v relay (the ones I am using are 5V 70 ohm, and are safe to put directly over a 5V supply.). Once pulled in, I'd like to decay the hold-in voltage / current to half of pull-in. I don't need fast pull-in or drop-out.

There are numerous postings in various places on how to do that, usually with extra resistive loads or putting the driving transistor into a non-saturated / non-cutoff state. This does reduce overall power consumption, but also means that some of the power is wasted across the resistor or driving transistor, and there is some extra heat to dissipate.

So I went for some PWM to chop the on/off state of the transistor. The default PWM on an Arduino has a slow PWM frequency (500Hz), (it is possible to fiddle with Arduino timers to get a higher frequency PWM, but I didn't). So I put together a small PNP circuit that seems to do what I wanted. (I simply modelled the relay as a resistor R2, no flyback protection, no taking its inductance into account.)

relay_PNP.png

But I'm still trying to wrap my head around three things:

a) If one does use PWM across a relay or solenoid, is there a risk that every time the PWM turns off we'll get some flyback and interaction. (For this reason I wanted the capacitor there).

b) I did this with a PNP. I thought it should be easy (almost symmetrical) to knock up an equivalent one with an NPN driver, but it eluded me. So any suggestions for doing this with an NPN? Or, can someone explain why the one case looks simple but the other isn't.

c) I can't seem to find answers to "what are typical inductances" in the same way as I can for other values. And inductances are not on the datasheets I've seen for relays. I've seen one LTSpice circuit that models a 12v car relay at 4000mH - that seemed huge compared to my attempt to measure my coil inductance by seeing how long it took to reach 63% of Vcc. (I got to 67uH - does that sound ballpark like it might be credible?) https://www.eeweb.com/electronics-forum/calculate-inductance-of-12v-relay-coil/

Thanks for any advice! (Advice to myself ... "Buy or build yourself an inductance meter?")
 

Kermit2

Joined Feb 5, 2010
4,162
PWM is a good way to lower power consumption but 50% is pushing the limit for reliability and contact adhesion needs.

Aim for the high 30s and give yourself a hand for doing a great job.
 

crutschow

Joined Mar 14, 2008
34,285
You shouldn't add a capacitor as you show (C1) since it will generate high peak currents through the transistor. This dissipates power in the transistor comparable to that of a series resistor, so you wouldn't be saving any power.
Just eliminate the capacitor and add a diode across the relay coil (cathode to plus).
That will allow the coil current to flow when the PWM signal is low, and also eliminates any inductive spikes.
This also minimizes power dissipation.

The coil inductance is probably around 100mH (see this).
What time constant did you find for your inductance measurement?

You can use an NPN also, you just need to invert everything.
Connect the relay coil (with parallel diode) in series between the +5V and the transistor collector, with the emitter to ground.
Note that this inverts the signal polarity compared to the PNP circuit.

Below is a simulation of the circuit with an NPN.
Note that I increased the PWM frequency to 2kHz to minimize ripple in the coil current.

upload_2016-11-27_9-42-54.png
 

Thread Starter

cspwcspw

Joined Nov 8, 2016
78
Thanks - most helpful. I'd not fully appreciated the "feed back the inductor's own energy" role played by the diode, (I was thinking of it purely in its "protection-from-nasty-spikes" role).

The circuit seems sensitive to estimates for the coil inductance, so I need to re-do my experiment (especially because of the low PWM frequency). With a 5v supply I measured 4.7ms to reach 44ma - (63% of my full current value of 70ma). I solved T=LR, which gets me to just 67uH which seems very low compared to your 100mH or the data sheet you referenced. (I followed the recipe from https://www.eeweb.com/electronics-forum/calculate-inductance-of-12v-relay-coil/ rather than understanding it from first principles, so I probably need to dig a bit deeper.)
 

Sensacell

Joined Jun 19, 2012
3,432
Note also that the PWM may create some audible acoustic noise, unless the frequency is higher than the range of human hearing.
 

crutschow

Joined Mar 14, 2008
34,285
.............With a 5v supply I measured 4.7ms to reach 44ma - (63% of my full current value of 70ma). I solved T=LR..........
There's your problem.
The time-constant of an inductive circuit is L/R, not LR, so L = T*R.
The correct formula thus gives an L of 4.7ms * 70 = 329mH.
That will reduce the current ripple to about 1/3 the value I simulated.
 

Thread Starter

cspwcspw

Joined Nov 8, 2016
78
Aargh! Thanks, my bad!

And, as I hinted, I shouldn't do these thing by rote, especially if I am going to mis-read someone else's formulas! It's why I need to build a bit of "feel" for what typical values are, so that I can self-correct!

Peter
 

Thread Starter

cspwcspw

Joined Nov 8, 2016
78
Relays have different inductances for their "pick" and "hold" states: the moving armature changes the magnetic characteristics of the field that is energized. We are probably more interested in the "holding" inductance (usually more than unpicked inductance), because that will determine the stored energy that needs to be dissipated when the relay is released. So one reference I found says in order to do the experiment properly, the relay should be mechanically held in its closed state while we measure the time constant of the circuit. My units are sealed - I can't intervene mechanically. There is a distinct sawtooth artifact on the current trace as the relay picks and the inductance increases. So to do a really accurate experiment (which I don't need) would require more work, or a more refined estimate that takes into account an inductance that changes during its charge cycle.

current_picking_relay.jpg

Now a fun fact, only remotely related to this thread: Guitar pickups can have small air gaps between windings, and if the windings have any leeway for movement they can induce some ugly ringing in the sound, and they sometimes produce loud unwanted clicks if one hits the pickup with a plectrum. So one DIY practice is to "wax" the pickups: submerse them on the stove for 20 minutes in a molten mixture of beeswax and paraffin wax. This forces the air out of the gaps, (visible as a stream of tiny bubbles), and the wax impregnates the windings and when cooled, prevents the wires from moving, and it presumably changes some magnetic characteristics too. So there are online videos on how to wax guitar pickups, and people who claim they sound more mellow and sweet after the treatment!
 

dannyf

Joined Sep 13, 2015
2,197
Once pulled in, I'd like to decay the hold-in voltage / current to half of pull-in.
use a r/c network: size the R so to maintain a minimum level of current to just hold the relay in place. Size the C so the close / open the relay initially.

nothing too fancy.
 

KMoffett

Joined Dec 19, 2007
2,918
Seems like I recall a simple circuit to allow full voltage for relay pull-in and a reduced voltage for hold. It consisted of a parallel resistor and electrolytic capacitor placed in series with the relay coil. When power is applied that capacitor appears as a dead short across the resistor, giving full voltage to the relay. The capacitor charges to a voltage based on the voltage divider formed by the resistor and relay coil resistance. This voltage is subtracted from the power supply voltage, leaving enough to across the coil to hold the contacts. The series resistor and coil results in lower current draw. When power is withdrawn, the resistor discharges the capacitor. Never tried it, but if seemed logical.

Ken
 

Thread Starter

cspwcspw

Joined Nov 8, 2016
78
Seems like I recall a simple circuit to allow full voltage for relay pull-in and a reduced voltage for hold. It consisted of a parallel resistor and electrolytic capacitor placed in series with the relay coil. When power is applied that capacitor appears as a dead short across the resistor, giving full voltage to the relay. The capacitor charges to a voltage based on the voltage divider formed by the resistor and relay coil resistance. This voltage is subtracted from the power supply voltage, leaving enough to across the coil to hold the contacts. The series resistor and coil results in lower current draw. When power is withdrawn, the resistor discharges the capacitor. Never tried it, but if seemed logical.

Ken
Yes, I saw this too and it seemed to make sense. But I was keen to avoid an extra resistive load or a half-on transistor to limit current. If Vcc ultimately splits across the load and some "limiting" resistive element, one can realize some power savings, but, in my limited understanding, you can never save more than half your power consumption with this scheme (if I want continuous half of the full current). So in my case the full draw on the battery with nothing at all to assist is 72ma, or with resistors or half-turned-on transistors I could lower it to 36ma continuous.

But Crutschow's circuit draws less than that. From what I see on LTSpice, my simulation draws about 40ma for 60% duty cycle of PWM: that is a 24ma average from the battery that will sustain 35ma in the relay. (Because, almost magically, some of the relay's own energy is arriving through the diode to feed back into the relay during the transistor's "off" period.)

I'm attracted to the general principle that more sophisticated controllers, e.g. using an MCU to provide the PWM, can be traded off for gains elsewhere. (Akin to the electronic ignition systems in motor cars, and the sophistication happening with power systems for solar panels and clever battery charging.) Admittedly the circuits become more complex, so it is not a tradeoff that will work for everyone.
 

crutschow

Joined Mar 14, 2008
34,285
(Because, almost magically, some of the relay's own energy is arriving through the diode to feed back into the relay during the transistor's "off" period.)
Actually the diode doesn't transfer the energy, it just allows the current to keep flowing from the energy stored in the coil inductance (the current in an inductor will always keep flowing until all the inductive energy is dissipated).
 

crutschow

Joined Mar 14, 2008
34,285
So to do a really accurate experiment (which I don't need) would require more work, or a more refined estimate that takes into account an inductance that changes during its charge cycle.
You can make a reasonably good estimate by looking at the exponential curve after the relay pulls in.
Use the point on the curve just after the relay pulls in as the start and then go to 63% of the difference in current (delta) between that point and the final value.
 

Thread Starter

cspwcspw

Joined Nov 8, 2016
78
You can make a reasonably good estimate by looking at the exponential curve after the relay pulls in.
Use the point on the curve just after the relay pulls in as the start and then go to 63% of the difference in current (delta) between that point and the final value.
Ah, great. I had to spend a bit of time convincing myself that this made sense. But it does. (And I guess that is what exponential curves are all about!) Thanks.
 
Top