# How to achieve reverse polarity switching?

Hi, I am trying to get reverse polarity switching with arduino pins but not really sure how to do it.... I guess with transistors but perhaps not.... Let me explain.

If I have 2 wires I can off course apply logic level voltage across the pair with a digital pin on one and GND on the other. Next I want to reverse the polarity of these two wires by setting another digital pin high... so the two states would be:

Wire 1 = 5v Wire 2 = 0v Digital control pin = low

Wire 1 = 0v Wire 2 = 5v Digital control pin = high

Any pointers greatly appreciated.

Case 1: DigitalWrite digital pin X high DigitalWrite digital pin Y low

Case 2: DigitalWrite digital pin X low DigitalWrite digital pin Y high

Where pin X is a pin selected by you and setup using a define:

# define digital pin Y = some pin on the Arduino

In the playground are many examples and sample sketches I SUGGEST you read all you can find as this is a really easy beginners task. You will need to learn the basics of what is there so you don't need to have someone help you across the Arduino Street every time you need to like a child needs help to cross a busy street

Doc

There's two things that immediately spring to mind:

1. Are you using this to run a motor in both directions? Then you need a H Bridge - There are billions of examples around. Try searching.

2. Are you using this to light LEDs? Then you need to look at Charlieplexing - There are billions of examples around. Try searching.

I would also think that he needs to do some basic reading too... Or post exactly what the OP's original purpose in asking the question was? My Crystal Ball has been broken ever since I used it to crack nuts with...

Doc

Docedison: I would also think that he needs to do some basic reading too... Or post exactly what the OP's original purpose in asking the question was? My Crystal Ball has been broken ever since I used it to crack nuts with...

Doc

... And I know just whose nut you used it on ... ;)

point5: Hi, I am trying to get reverse polarity switching with arduino pins but not really sure how to do it.... I guess with transistors but perhaps not.... Let me explain.

If I have 2 wires I can off course apply logic level voltage across the pair with a digital pin on one and GND on the other. Next I want to reverse the polarity of these two wires by setting another digital pin high... so the two states would be:

Wire 1 = 5v Wire 2 = 0v Digital control pin = low

Wire 1 = 0v Wire 2 = 5v Digital control pin = high

Any pointers greatly appreciated.

Well not knowing all the electrical properties of your wire signals (current capacity?) one could accomplish your task by having your new digital control pin out to control a DPDT relay. The DPDT contact wiring on the relay would be wired such that the polarity reverse would happen when the relay was activated, and normal polarity when not activated. There are certainly other ways to accomplish the task but I would need to know the maximum current that the two wires could be called on to carry and if it would be acceptable to wire a common ground wire from the arduino board to what ever is sourcing the signals on the two wires.

Lefty

Hi, Thanks for the input folks.

The circuit I am looking at is very simply measuring an unknown resistance between wire 1 & wire 2 (perhaps lets call them probes). These are long term measurements so to avoid problems associated with galvanic action I would like to alternate the polarity of the circuit for each measurement. This is all being done via an external ADC so keen to achieve the polarity reversal with transistors or similar if poss - we are talking very low currents, perhaps 10mA and less, so no need for relays I hope.

Hmmmm, wondering if this polarity reversal could be achieved with something like this?

http://uk.farnell.com/fairchild-semiconductor/74lvx02m/74lvx-smd-74lvx02-soic14-3-6v/dp/642400

retrolefty:

point5: Hi, I am trying to get reverse polarity switching with arduino pins but not really sure how to do it.... I guess with transistors but perhaps not.... Let me explain.

If I have 2 wires I can off course apply logic level voltage across the pair with a digital pin on one and GND on the other. Next I want to reverse the polarity of these two wires by setting another digital pin high... so the two states would be:

Wire 1 = 5v Wire 2 = 0v Digital control pin = low

Wire 1 = 0v Wire 2 = 5v Digital control pin = high

Any pointers greatly appreciated.

Well not knowing all the electrical properties of your wire signals (current capacity?) one could accomplish your task by having your new digital control pin out to control a DPDT relay. The DPDT contact wiring on the relay would be wired such that the polarity reverse would happen when the relay was activated, and normal polarity when not activated. There are certainly other ways to accomplish the task but I would need to know the maximum current that the two wires could be called on to carry and if it would be acceptable to wire a common ground wire from the arduino board to what ever is sourcing the signals on the two wires.

Lefty

i was thinking about the same thing the other day and i dont know if this would work.

with a DPDT relay, you have two states: one when the relay is on and one when it is off. you have two possible paths for current. one will be +x volts and the other will be -x volts, am i right? reverse polarity? if this is running a motor, what happens if we want the motor to STOP? or am i missing something here?

I was thinking you need to do some things with logic and transistors etc. a chip that controls the motor is possibly already in existence?

The DPDT switch idea is nice - wonder if this could be the answer?

Like i said earlier, you might run into problems using a DPDT switch depending on what you're trying to do. WIth a DPDT, retrolefty suggests that you can use it to switch from one extreme (positive) to another (negative). You're missing one important thing: zero. If this is to be used for a motor, how do you make the motor stop? that will be the problem with a DPDT switch. If you're using this for something else, you might not need to turn it off.

This is a very simple application I am looking at, sensing resistance, so all I need to do is invert 5V & GND across the unknown resistor.

point5: This is a very simple application I am looking at, sensing resistance, so all I need to do is invert 5V & GND across the unknown resistor.

My concern is your calling one of the wires GND. Ground is a term usually used to define a common reference potential for a complete circuit(s). So what is not clear to me is if the two wires are carrying power supply + and - and you need the ability to reverse them but still apply signification power to something (like a motor), or if they are two logic level signals that need to ability to always be the inversion of each other no matter how they attach to where they are going, kind of like RS-485 signal pairs.

So without more context of how the two 'signal' or 'power' wires are created and how there are going to be used by whatever is going to receive these two wires, it's hard to tell you what methods of 'polarity switching' is best or even possible. For example, if your 'unknown' resistance can be as low as 1 ohm the method would be quite different then if the lowest resistance possible is 10,000 ohms.

Lefty

I know this is am old post but I don't really care.

Arduinos are built for various levels of expertise. You should expect and respect questions like these. I search as much as possible before asking a question that has already been asked but the answer isn't always clear.

If you know so much about electronics, share that information if you want. Don't Badger someone because they ask a question. If you have a problem with someone's question, don't answer it.

Honestly, I wonder sometime why people who supposedly have so much knowledge are working with Arduinos other then the fact that they are fun.

I am tired of "know it alls" or people who have more knowledge than others being rude to those trying to learn.

If you are so educated, then share what you know or keep your mouth shut. Your rude responses only make people who have an interest in electronics question their real ambition. Chances are that they have already searched and couldn't find a clear answer.

Bottom line, if you have a rude comment, keep it to yourself. If you want to help, which is the intent of this forum, then be nice and don't let you egov overload your tail.

I agree with brad. Don’t be a jerk to people and ruin this awesome hobby. :0

bradlandreth: I know this is am old post but I don't really care.

Arduinos are built for various levels of expertise. You should expect and respect questions like these. I search as much as possible before asking a question that has already been asked but the answer isn't always clear.

If you know so much about electronics, share that information if you want. Don't Badger someone because they ask a question. If you have a problem with someone's question, don't answer it.

Honestly, I wonder sometime why people who supposedly have so much knowledge are working with Arduinos other then the fact that they are fun.

I am tired of "know it alls" or people who have more knowledge than others being rude to those trying to learn.

If you are so educated, then share what you know or keep your mouth shut. Your rude responses only make people who have an interest in electronics question their real ambition. Chances are that they have already searched and couldn't find a clear answer.

Bottom line, if you have a rude comment, keep it to yourself. If you want to help, which is the intent of this forum, then be nice and don't let you egov overload your tail.

There's a limit though..... basic search skills vs I'll ask everything here instead.

Hi,

I am dealing with a selenoid valve which has a shaft that moves one side if you apply current and to opposite side if you switch the polarity.

But the current shall be timely limited (only 50 ms). If the current is always on the valve is getting very hot quickly.

So I need to do two things; I shall be able to switch the polarity (by pressing a button maybe) and I shall limit the duration of current.

I will be very appreciated for any help. Thanks in advance.

Hi, and welcome to the forum. You should have started a new thread for this, instead of digging up an old one.

It seems that you need an H-bridge. Commonly used to drive motors in both directions. Which one depends on the working voltage and current of your solenoid. Post a link to the solenoid. Leo..

I realize this thread is ancient, but it popped up on a search. I have an aquarium with a refugium (a second tank for filtering and introducing new members to the tank) The bottom tank is gravity fed and the water is pumped back up the main display tank.

The issue for me was, how to cut-off the gravity flow in case of a power failure.. so I'm looking at electronic ball valves instead of solenoids (because the solenoid needs constant power to stay open). For the ball valve: To open the valve, you need power.. The close the valve, you need power with reverse polarity .(it doesn't close with a lack of power)

Here's how I'm going to tackle it (might seem brute force, but I"m pretty sure it will work) I'm going to order a 4 channel 5v SainSmart physical relay controlled by an Arduino. I'm going to feed a 3v line into the Arduino to detect a power failure (some cheap transformer)

The 4 channels will be configured in the following manner: + - - + For "open" operations, I will open relays "1 and 2" (+ -) For "close" operations, I will open relays "3 and 4" (- +)

After 15 seconds, I will close all relays, since it takes about 5-10 seconds to fully open the valve. The only issue that could happen is if I get my wires crossed and open the wrong relays..

but this gives me total control.. Of course, the Arduino and corresponding power source to open/close the valve will need battery backup.