# Switching between +9V and -9V (using 5V logic)

I got some linear actuators today and found out that when I give them +9V they extend and -9V makes them contract. This is easy enough to test by hand, simply by wiring the actuator up to the battery backwards for the negative voltage, but when I hook it all up I'm going to be driving all of them from my Atmega1284, which uses 5V logic.

In anticipation of this, I got a bunch of relays that run on 5V logic as well so I can control whether or not there's +9V running through with my 5V microcontroller. However, I have no way to programmatically provide -9V.

My question here is how can I switch between giving +9V and -9V when all I can do from my microcontroller is either push out 5V or 0V? Will I need more than just my relays? Is there some spiffy EE trick to make this work? Thanks!

You can use two SPDT relays to select +9 or -9 or 0V.

Both energized = off, Both de-energized = off, and if one is energized and the other is not it will drive the actuator in one direction or the other.

simulate this circuit – Schematic created using CircuitLab

To suppress electrical noise, add a bridge rectifier (W04G, for example) across the actuator (the AC input terminals) and connect the + terminal to +9 and the - terminal to 0V

• Perhaps you should mention that this is the relay version of an "H-bridge" circuit -- just about any solid-state H-bridge driver with suitable ratings will do the job just as well, although the relay version is nice for exposition's sake :) – ThreePhaseEel Nov 24 '16 at 1:04
• @ThreePhaseEel Good idea, any suggestion for a suitable chip that will do level conversion and handle a reasonable current? – Spehro Pefhany Nov 24 '16 at 1:06
• With the bridge rectifier (or 4 diodes) the contacts will arc more and it might upset your AtMega via EMI. – Spehro Pefhany Nov 24 '16 at 1:09
• @scohe001 -- Sphero's comment should read "Without the bridge rectifier..."...but with that correction, he's right -- the diodes provide a current path for the inductive spikes the coil generates (it acts like the ignition coil in a car, generating a spike every time you cut the power to it) so they don't fry other things (like relay contacts or switching transistors). – ThreePhaseEel Nov 24 '16 at 1:12
• @SpehroPefhany -- half of a L293D can be used to do the trick (possibly along with an inverter), although the L293D is rather ancient xD – ThreePhaseEel Nov 24 '16 at 1:13

The L293D motor driver/ H-Bridge IC should work nicely for this purpose:

This chip is commonly used for controlling motors and because it's able to reverse the polarity of the motor, you can change the direction in software.

For your application this also provides you with the benefit of not having to have a -9V power rail, you just have to provide the chip with 5V and 9V.

Here is a connection diagram: a busy cat http://www.electroons.com/electroons/images/ckt_mtr.jpg

VCC2 (left bottom corner) should not be hooked up to the 5V, but to the 9V supply. 3,4E should be connected to the 5V supply.

Another nice thing: the chip can drive 2 actuators, if you need them.

Just hook up RA2 and RA3 to your MCU, and common the ground of the chip and your processor.

• You're saying that I would connect the 4 grounds to both the ground of the microcontroller and the ground of my 9V power source? Also what signals would drive each actuator? Would it be like @Spehro's answer where RA3 high and RA2 low would mean the actuator is extended and the opposite would be contracted? – scohe001 Nov 24 '16 at 17:48
• The grounds are internally connected, for playing on a breadboard, you only have to connect one of the L293D grounds to your MCU ground and the 9V ground. The actuator would be connected instead of the motor in the upper diagram, so between 1Y and 2Y. – Tobias Mädel Nov 25 '16 at 6:51
• Pulling 1A high and 2A low will let current flow in one direction, 2A high and 1A low in the opposite direction. – Tobias Mädel Nov 25 '16 at 6:51
• I wired up the L293d like you specified and things were working at first, but the actuator was moving lest and less and things smelled weird and I'm pretty sure I've borked the chip. Am I missing a resistor somewhere? Or is this chip just not rated for 9V? – scohe001 Nov 28 '16 at 5:38
• So I looked around online and it seems the chip can take up to 36V, but only 600mA. My solenoids were made for cars (for the locks), so they pull 2 or 3 Amps which is probably why things are dying. Do you know of a motor driver that can take more current? – scohe001 Nov 28 '16 at 6:00

You will need to provide a 9V supply to be able to power the linear actuator. You do not need to have a -9V supply as you can achieve that simply with a polarity reversing scheme controlled by two of your relays. Here is a basic schematic of how you would hook it up. If you use relays with very low power 5V coils you could control them directly from the Arduino otherwise use NPN transistor buffers as shown here.

The Arduino controls to the two relays can apply 9V in either polarity to the actuator to move it in or out. To stop the actuator motion switch both relays to apply either 9V or GND to both wires of the device.

• I assume your actuator actually has three conditions that apply to it: 1) drive to extend ...2) drive to contract and ...3) no voltage to stay where it is. Unfortunately this schematic has only two positions 1) driving to extend and driving to contract, there is no stable state (which I assume you'd want). What you need is an H-Bridge which can be driven by your processor. – Jack Creasey Nov 24 '16 at 1:31
• @JackCreasey - You are correct regarding the original picture I showed. I will modify the answer to correct this problem. – Michael Karas Nov 24 '16 at 11:03