# car solenoid circuit

I have an old solenoid from my car that was used to control the locks. Its 12 volts. I was able to make it work with the arduino using a diode, 2.2k resistor and a TIP transistor.

I've found that if i reverse the leads on the solenoid it either pushes or pulls

If I want to control this with the arduino using 2 pins (or even one would be better), would i use an H bridge? If so what would that circuit look like for this application?

Ideally I would like to have the solenoid pull when a digital pin is low and push when i digital pin is high.

i have some digital relays, can i use those.

Keith

A H-bridge can do the job. These are controlled in different ways. Some have individual inputs for the bridge halves, in this case you will have to invert the signal to one of them. Others have some logic between the halves, you have to study the datasheets

You could probably use the relays. Remember you are switching an inductive load so you need a flyback diode on the solenoid and most relays have different ratings for inductive loads.

A dpdt relay to change direction and a spst to turn power on and off should do the trick.

nilton61:
A H-bridge can do the job. These are controlled in different ways. Some have individual inputs for the bridge halves, in this case you will have to invert the signal to one of them. Others have some logic between the halves, you have to study the datasheets

This is where I'm lost...can you elaborate?

Ok, lets be elaborate. Have a look at the switch bridge picture. In order to form a closed circuit one of the switches a and c must be closed and one of the switches b and d must be closed as well. We now have 4 possibilities:

• a and d closed: the voltmeter shows positive polarity
• b and c closed: The voltmeter shows negative polarity
• a and b closed: Short circuit
• c and d closed: Short circuit

It should be obvious that the last two situations should be avoided. This circuit is the base for all polarity reversals. One way of doing this is with two relay changeover contacts as in relay reversal. in this case the risk for short cicuit has been eliminated. One thing that must be considered when using a circuit like this is that the energy stored in an inductive load has to go somewhere. If you do not provide freewheeling diodes this energy will cause arcing that burn the contacts very quickly.
An other way is to exchange the switches with transistors, this is called a h-bridge. These are fast and do not arc but pose some other problems.

• Great care must be taken not to short circuit, that means one transistor must be turned off before the other is turned on
• Driving the upper transistor complicates the circuit.

It is possible to build an h-bridge with discrete components but for the reasons stated above it is much more common to use a ready made IC. Lets start with a very simple one the SN 754410. It has 4 transistor pairs which can form 2 h-bridges. The driver circuit and the short circuit are taken care of. A low voltage between -0,3 and 0,8V on any on the inputs will turn on the lower transistor for the output with the same number. A high voltage between 2V and 5,5V will turn on the upper transistor. So in order to make our polarity reversal circuit we need to take two transistor pairs and invert the input signal to one of them and connect our load to the outputs. Inverting the signal can be done with a transistor, with a logic inverter IC or using 2 output pins if you can spare then.
A more integrated solution would be using a comple full bridge ic like the TLE 4025 This IC has both normal and inverted inputs for each leg so you don’t need an inverter.
Both these ic’s have integrated freewheeling diodes that recirculate the energy stored ian inductive load like an solenoid so you do not need to take care of that.

You can probably use the circuit that I'm using to drive a latching relay.

It uses a ULN2003 Darlington driver IC to do the main switching duties. You basically connect both sides of your solenoid to 12v through a series resistor, and then use the ULN2003 to effectively ground one side of the solenoid or the other depending on the direction you wish to drive it.

Ian.

@nilton61,

@kieth brown,
If you feel uncomfortable with dealing with the h-bridge learning curve you can use a DPDT relay

COMMON-1 : +Vcc
COMMON-2 : gnd.
NC-1 : Solenoid RED wire
NC-2 : solenoid GND
NO-1 : Solenoid GND
NO-2 : Solenoid red wire

Truth Table

DPDT RELAY OFF
COMMON-1 (+Vcc) => NC-1 (red wire )
COMMON-2 (GND) => NC-2 (solenoid GND)

DPDT RELAY ON
COMMON-1 (+Vcc) => NO-1 (GND )
COMMON-2 (GND) => NO-2 (red wire)

Conclusions
relay OFF = One direction (extended or retracted, I don't know which it is for that solenoid)
relay ON = the OTHER direction

If you are using a transistor or mosfet to drive the relay you should observe the advice already given
of putting a flywheel (or flyback) diode (1N4001 or greater (1N4002 etc) across the relay coil with
the CATHODE connected to the relay +Vcc and the ANODE connected to relay coil GND) to prevent
blowing the transistor with the high reverse voltage when the coil magnetic field collapses on turn off.

If the solenoid is dimensioned for intermittent use you have two options:

• Use two relays or a bridge circuit that can turn fully off.
• Use a circuit like the attached, the resistor must be small enough to permit a sufficient holding current, the capacitor must be large enough to make the solenoid act on reversal

I strongly urge you to isolate the Arduino circuits from the car circuits, both power and ground.

You can use opto-isolators to do this cheaply and indeed a lot of affordable relays come with those built-in. One side has a led, the other has a detector and in between there is typically 5000+ V protection.

steve108:
A DPDT relay to change direction and a SPST to turn power on and off should do the trick.

Nope. Wrong idea.

Two relays, each SPDT (as most are), one on each "end" of the solenoid, "NC" to ground and "NO" to 12V. Same circuit as power windows, and in fact, same as an H-bridge.

For an H-bridge, you have two controls, each switches over one half of the "H". One trips lock, the other unlock. If both should happen to be triggered at the same time, it does not matter (nothing happens).

Two relays, each SPDT (as most are), one on each "end" of the solenoid, "NC" to ground and "NO" to 12V. Same circuit as power windows, and in fact, same as an H-bridge.

Last time I checked, two SPDTs makes one DPDT.

Am I missing something ? Can you show a schematic (or something) that indicates otherwise ?

because I am not following your comment. I have used DPDT relays to change motor direction before.
It's no different with the solenoid. The only difference is he may need a single SPST RELAY to TURN ON
or OFF the solenoid power going to the direction relay to de-energize the solenoid if necessary.
The solenoid is a device that requires power to perform it's function. It should be ON if it is being used and
OFF if it is not being used. It shouldn't be set one direction and then de-energized. I don't think it would
perform it's function if you did that. (it needs to be energized to exert pressure)

Either two spdt or a dpdt and spst would do the job without question. It might be better to use the spdt method so when the arduino pins go high at startup the solenoid is not activated. Either that or wire your spst to be activated by a low signal from the arduino

raschemmel:
Am I missing something ? Can you show a schematic (or something) that indicates otherwise ?

OK, go back to this diagram:

You have two SPDT relays corresponding to the two contacts you see in the diagram. Both relays - unlike the diagram - rest on the lower contact as NC, so at rest, the motor/ solenoid is not powered.

Actuate the left relay, it is powered in one direction, actuate the right and it is powered in the other direction. Actuate both (for whatever reason) and it is again unpowered, so it is quite safe. This is how your car power window switches are arranged. And you can substitute an H-bridge for the relays, controlling each half separately.

No reason for any more complexity than this, just two single changeover relays.

Are you sure it's an solenoid?

All central locking devices that i've seen uses a DC-motor and Rack&pinion gear.

//Per.

Zapro:
All central locking devices that i've seen uses a DC-motor and Rack&pinion gear.

//Per.

That's a very good point. You also get master and slave units that have different configurations of internal micro switches to provide positional feedback etc.

@Paul_B,