Author Topic: Thoughts on driving solenoids and relays  (Read 17039 times)

0 Members and 1 Guest are viewing this topic.

Offline naxxfishTopic starter

  • Contributor
  • Posts: 22
  • Country: 00
Thoughts on driving solenoids and relays
« on: August 19, 2010, 11:56:25 pm »
Hi, forum!

Ever since I started tinkering, doing hobby electronics, and aiming in the direction of mechatronics, I am persistently plagued by the problem of driving inductive loads of various sorts. I managed to get my head around driving standard hobby level DC motors ( http://tinkersoc.org/wiki/reference:motordriver ), and built a motor driver board with an IC designed for the job, which does the job excellently.

However I am doing a bit of freelance stuff during my vacation from my degree - and I will be working with solenoids.  They're for a museum exhibit that has broken.  As I've not yet actually seen the kit, I can't tell what exactly is broken - but it made me wonder about the practicalities of driving relays and solenoids and the like. 

For a previous project, I designed a (probably over complicated) relay module to connect to a micro to set off fireworks. It had an optocoupler (which didn't work), darlington pair amplifier, flyback diode, as well as some dampening to prevent chattering. Ended up bypassing the optocoupler, and in the end the darlington pair, and driving it with a nail on a stick touching against a battery terminal. 

Anyway - my question is this: what are the major things that need to be considered when designing a circuit to drive an inductive load like a large-ish solenoid.  How much protection is required, really?  Should I bother with an optocoupler, or would I get away with going straight into a FET?

I also found this:
http://electronicdesign.com/article/power/smart-solenoid-driver-reduces-power-loss11162.aspx

Which is very nice and economical, but my op-amp skillz are somewhat lacking (I did a module in my course on opamps about 3 years ago now, and my degree is more oriented towards the digital side of things so haven't come back to them since) and I don't really understand it, so am hesitant to pick it up and run with it. 
 

Offline DJPhil

  • Frequent Contributor
  • **
  • Posts: 511
  • Country: 00
Re: Thoughts on driving solenoids and relays
« Reply #1 on: August 20, 2010, 01:54:32 am »
How much protection is required, really?  Should I bother with an optocoupler, or would I get away with going straight into a FET?

I'm not a pro, but I believe the flyback diode should be adequate unless you need high speed (see this EDN article on bootstraping). Remember to use a beefy one, not a signal diode. You can always test a given rig 'dead bug' style if it's just a few parts to see how it's behaving without cooking a micro. Optos are very useful, but probably not necessary unless you have intractable noise problems or need the extra isolation for safety, i.e. working with a mains relay.

I also found this:
http://electronicdesign.com/article/power/smart-solenoid-driver-reduces-power-loss11162.aspx

Which is very nice and economical, but my op-amp skillz are somewhat lacking (I did a module in my course on opamps about 3 years ago now, and my degree is more oriented towards the digital side of things so haven't come back to them since) and I don't really understand it, so am hesitant to pick it up and run with it. 

That's a pretty slick circuit, but it might be overkill unless you need the power savings. Still . . . Looks like a good reason to brush up!

Opamps aren't too difficult as analog goes, just don't get bogged down in high performance details too early. The best treatise on opamps I know of is Opamps for Everyone, and it's free! Don't be intimidated by the size, a quick spin through chapter 3 will get you refreshed on the ideal model. Opamps are just way too useful to skip!

Hope that helps. :)
 

Offline Zad

  • Super Contributor
  • ***
  • Posts: 1013
  • Country: gb
    • Digital Wizardry, Analogue Alchemy, Software Sorcery
Re: Thoughts on driving solenoids and relays
« Reply #2 on: August 20, 2010, 04:47:03 am »
Off the top of my head (and realising that at this hour I should be asleep in bed) how about putting an electrolytic capacitor on the base of the transistor to reduce the speed at which the current is turned on and off through the solenoid? It is the speed of this current change (di/dt) that dictates how high the reverse EMF is that it generates. It would mean that the transistor dissipated more power whilst not fully saturated, but it should be quite a short duration.

Offline Simon

  • Global Moderator
  • *****
  • Posts: 17881
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Thoughts on driving solenoids and relays
« Reply #3 on: August 20, 2010, 05:38:57 am »
really all you need is a mosfet like a IRF540 or 9540 and a back EMF diode, simple (not looked at your diagram yet as on my way to work)
 

Offline Time

  • Frequent Contributor
  • **
  • Posts: 725
  • Country: us
Re: Thoughts on driving solenoids and relays
« Reply #4 on: August 20, 2010, 06:10:15 am »
You just need an appropriate diode to handle the back emf.  If the solenoid/relay isn't being switched often enough power consumption might be negligible.
-Time
 

Offline tecman

  • Frequent Contributor
  • **
  • Posts: 444
  • Country: us
Re: Thoughts on driving solenoids and relays
« Reply #5 on: August 20, 2010, 01:20:56 pm »
The circuit shown will save power but limit holding force.  So it really depends on what the application will be and what the force will be.  As for a flyback diode, you always need one.  A standard diode will slow the drop out time.  Other schemes such as a diode plus a zener can speed drop out.  The diode rating should be the solenoid current as a current rating, minimum.  As for power in the diode, the cycle rate of the solenoid will determine that.  Other schemes, such as using an additional zener for faster switching, will require a more in-depth power calculation.

paul
 

Offline TechGuy

  • Regular Contributor
  • *
  • Posts: 79
Re: Thoughts on driving solenoids and relays
« Reply #6 on: August 20, 2010, 08:59:24 pm »
FWIW: When energizing a "DC" Solenoid for low power consumption, its more efficient to drive the solenoid using a square wave output instead of steady DC. Once the core magnetization is saturated all of the extra energy dumped into the coil winding is disappated as heat. For better efficienct driver you want to start off with a duty cycle at near 100% and drop it to about 10% (depending on how big the core is). This can be done with a small microcontroller (ie 8 pin PIC microcontroller). Imagine a pulse train with a duty cycle like 100, 80, 60, 40, 30, 20, 10, 10, 10... If thats too complex than just driving it with a 50-30% duty cycle using a 555 Timer might also work.

Another low energy option is to use latching relays. These have a latching mechanism that retains the relay switch state after you turn off the coil power. Some latching relays use two separate coils (one turns on the relay and the other turns it off). Other switch by the polarity of the power applied to the coil. To operate a latching relay you apply a current pulse for about 1/2 sec which latches the relay into a new state.

For driving the soleniod, virtually any transistor will do (MOSFET, IGBT, BJT, etc). Even an SCR or Traic can be use if your power source is AC. For DC Solenoids, the Solenoid must be connected to the High Side of an NPN\N-Channel transistor ie Vdd = Solenoid = N-Channel Transisor = GND. It is recommend to use NPN, or N-Channel Transistors since they are more efficient then PNP\P-Channel Transistors. Its a good idea to connect a reverse recover diode in parallel with the "DC" Soleniod to prevent inductanct leakage spikes from damaging the transistor. When you turn off energy to the Solenoid coil it will create voltage spike . The reverse recovery diode will dispate the voltage spike. The reverse recovery Diode, is connected so that the diode cathode is connect to the VDD side solenoid connection and the Anode to the transistor side of the solenoid.

If you choose to power your Solenoid with steady DC current, be sure to measure the DC resistance of the Solenoid coil, then calculate how much current will flow  ie ( I = V/R). Impediance of the Soleniod will fall to the DC resistance after the Solenoid core saturates. Either make sure that your switching transistor can handle that current load or increase the resistance by adding a resistor in series between the soleniod and the transistor to reduce the current flow. Although dropping the current too low, may prevent the solenoid from working. You can put a cap in parallel with the resistor so that the solenoid gets an extra start up kick. using the resistor with the parallel can is also another what to reduce current flow, but its not as efficient as using a PWM type I discussed above.

The EDN article is more efficient but its not as efficent as using a PWM control. This is because its running the switching transisor in linear mode, which the transistor is not fully on, and works like an adjustable resistor. While increasing the resistance in the transistor reduces the current supplied to the solenoid its still disappating energy in the transistor. By using a PWM drive control we are driving the solenoid to at or near its magnetic saturation power. and no or little current is wasted. The switching transistor also operates in an efficent state, becaus it quickly switches from off to its lowest resistance state which avoids energy being disappated as heat.

Note: Most Power Mosfets need 10 volts supplied to the gate in order to fully switch on. You either need to use a BJT transistor or a MOSFET driver to switch on the MOSFET, if your controlling it using a microcontroller or logic gates that operate at 5V/3.3V.

 
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 17881
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Thoughts on driving solenoids and relays
« Reply #7 on: August 20, 2010, 09:05:31 pm »


Another low energy option is to use latching relays. These have a latching mechanism that retains the relay switch state after you turn off the coil power. Some latching relays use two separate coils (one turns on the relay and the other turns it off). Other switch by the polarity of the power applied to the coil. To operate a latching relay you apply a current pulse for about 1/2 sec which latches the relay into a new state.


 

I was just about to post before you about the latch relay's. I'm using http://uk.farnell.com/tyco-electronics-schrack/rt314f12/relay-pcb-spco-12vdc/dp/1175083?Ntt=rt314f12 great little relay only requires 30ms pulse at least, of course this means that a driving MCU requires 2 outputs to control it but you get the ultimate power saving and in applications in confined spaces carrying large currents (that would make a mosfet solution costly and bulkier) it is just the ticket and very easily controlled with an MCU and small n channel mosfet
 

Offline naxxfishTopic starter

  • Contributor
  • Posts: 22
  • Country: 00
Re: Thoughts on driving solenoids and relays
« Reply #8 on: August 20, 2010, 11:58:11 pm »
Thanks for all the info everyone!

Opamps for everyone, now that will also be useful in another project I'm working on (a telephone balancer unit for my radio station). 

Using PWM - that's interesting. I was thinking about this, but figured you'd have to get it just right or the plunger would vibrate as the magnetic field collapsed during the off period.  But I guess that's a good excuse to experiment!

The speed at which the solenoids switch probably isn't terribly important.  So just a standard flyback diode will probably do the job (though the zener idea sounds interesting). 

I have a feeling in this particular instance, I'll use a FET or something along those lines to do the switching, and I'll then see if I can generate 6 PWM signals from my micro (if nothing else it can be done in software). 


The project I'm working on is fairly low budget.  I have a feeling I won't be replacing the solenoids, as they suggest that they work, just the driver circuit which does not.  It's a model of a shutter signalling tower, with 6 shutters operated by solenoids. 

Currently the logic is all based on a big old custom switch key board, and some EEPROMs to decode the button presses into the right sequence of shutters being open.  Whilst a rather neat solution (and 20 years ago probably the only practical solution), I was planning on replacing most of the logic with a micro, give me greater flexibility for further development. 

 

Offline JohnS_AZ

  • Frequent Contributor
  • **
  • Posts: 499
  • Country: us
    • About.me
Re: Thoughts on driving solenoids and relays
« Reply #9 on: August 21, 2010, 12:08:10 am »
That actually sounds like a pretty cool/fun project.
Post some pictures when you get the thing.
I'm either at my bench, here, or on PokerStars.
 

Offline naxxfishTopic starter

  • Contributor
  • Posts: 22
  • Country: 00
Re: Thoughts on driving solenoids and relays
« Reply #10 on: August 27, 2010, 02:02:55 am »
I started a new thread about the project! https://www.eevblog.com/forum/index.php?topic=1136.0

But back on topic - I've got a theoretical circuit which I was thinking of using to drive a solenoid.  

It's got a flyback diode - which I think should do what I expect.  No biggie there. There's a N channel MOSFET, which would be rated pulse for the peak current draw.  The one thing that I've added is a cap to buffer the initial current draw as the solenoid starts to move - I figure that in the place I've put it, it'll help prevent a large voltage dip in the supply when the solenoid flips.  It might also absorb some of the back e.m.f. when the solenoid is switched off again?  Not entirely sure what value to make it, I guess that all depends on how much current it will draw when it's first energised.  I stuck a little resistor in there, too - which is purely to limit the current to prevent the FET from blowing up.  It'll probably be several low value resistors in parallel in reality.

The other thing that I was wondering about was power supply wise.  I can get a 5A installation power supply - for example - but I can't guarantee that the initial current draw won't be more than that.  Will my decoupling cap let me do that without blowing up the PSU?  I figure that the initial surge will immediately discharge the cap, which should result in plenty of amps very briefly until it's fully discharged (as per the RC time).  If I pick a big enough value cap, that should be enough without drawing too much current from the supply?  

Thoughts are welcome!
« Last Edit: August 27, 2010, 02:15:46 am by naxxfish »
 

Offline TechGuy

  • Regular Contributor
  • *
  • Posts: 79
Re: Thoughts on driving solenoids and relays
« Reply #11 on: August 27, 2010, 07:28:42 pm »
Move R1 from GND Source to between Drain and D1,  R1 between Gnd and Source is going to cause problems since your creating a voltage drop at the Mosfet source. A MOSFET is controlled by the voltage difference between the Source and the gate, not the ground connection. You want the MOSFET source connected directly to ground.

Also add a 10K resistor between the gate and source connection. This will prevent the MOSFET from auto turning on. The gate in mosfet is a cap, and will slow charge turning it self at least partially over time if there is no connection to the gate pin. the 10K resistor will ensure that the MOSFET stays off until you tell it to turn on.

A decoupling cap is typically used for a soleniod drive. The size depends on how much the solenoid needs to energize to move the plunger.

Current demand will increase after the solenoid becomes fully saturated (reaches its maxium magnitizing energy state). When you first turn on an induction (in this case a solenoid) it will resist change in current. this is referred as impediance. Impediance is like resistance, as it limits the current flow through the coil. Unlike a resistor it doesn't dispate energy into heat. when you switch off power to the core, the stored energy will flow back into the coil (in the reverse direction), until the core loses its magnetic field. This is why you need to flyback diode.

Inductor current graph: (although the graph show current demand using a current limiting power supply)


I would recommend thay you try using a small parallel cap (perhaps 10uf to 100uf) across the resistor (R1 -moved between D1 and Drain). This will allow more current to flow when you first turn on the mosfet until the cap saturates. After the cap saturates, on the resistor will source current to the solenoid coil. When you turn off the MOSFET. the resistor will discharge the cap, so it resets for the next cycle. The cap trick will work if the switch cycle is low enough to permit the cap to discharge completely. If you switchin the solenoid on/off dozens of times per second its probably not going to help much. Since the solenoid will have impediance, it will limit the current flow while the cap charges up, so that your MOSFET doesn't blow. Just make sure if you use a polar electrolytic cap that you connect the cap negative terminal to the MOSFET drain side of the resistor.
 

Offline naxxfishTopic starter

  • Contributor
  • Posts: 22
  • Country: 00
Re: Thoughts on driving solenoids and relays
« Reply #12 on: August 27, 2010, 08:52:24 pm »
Ah, yes, forgot that R1 would do that. 

Thanks for the info, very helpful. 

I'd likely be PWMing the solenoid once it has gone into the energised position - I suspect the cap will still do as I expect (and you say), and behave as expected when the solenoid is first energised.  If anything, it'll help hold the solenoid in position when PWMing. 
 

Offline naxxfishTopic starter

  • Contributor
  • Posts: 22
  • Country: 00
Re: Thoughts on driving solenoids and relays
« Reply #13 on: August 28, 2010, 07:10:05 pm »
Had a play with LTSpice to see what I could work out.  I'm probably more confused than I was to start with.  Modelling a solenoid in LTspice is not easy, but using just a plain old inductor give me an idea, I guess.  Nowhere in any datasheet does it show the inductance of the solenoid - in any state.  Which makes it somewhat difficult to model.  i.e. impossible. 

Hrmph >_< am I going to have to try and measure the inductance myself?
 

Offline allanw

  • Frequent Contributor
  • **
  • Posts: 343
    • Electronoblog
Re: Thoughts on driving solenoids and relays
« Reply #14 on: August 28, 2010, 08:13:49 pm »
Had a play with LTSpice to see what I could work out.  I'm probably more confused than I was to start with.  Modelling a solenoid in LTspice is not easy, but using just a plain old inductor give me an idea, I guess.  Nowhere in any datasheet does it show the inductance of the solenoid - in any state.  Which makes it somewhat difficult to model.  i.e. impossible. 

Hrmph >_< am I going to have to try and measure the inductance myself?

You can do it pretty easily if you have a variable frequency sine wave generator. The inductance changes depending on the frequency though.

http://www.daycounter.com/Articles/How-To-Measure-Inductance.phtml
 

Offline naxxfishTopic starter

  • Contributor
  • Posts: 22
  • Country: 00
Re: Thoughts on driving solenoids and relays
« Reply #15 on: August 29, 2010, 03:21:34 pm »
Yeah, can do that.  Annoyingly, the solenoids are about 15 miles away from where I normally work on electronics.  Might have to lug some kit over there to prod them.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf