I got an electrical engineering degree 15 years ago that I barely use. Although I bought a fairly fancy multimeter, I will freely admit to having only a vague recollection of what I did back then... which was mostly discrete math and signal processing (as opposed to circuits).

A friend of mine who has a lot more real-world "electrician" experience was trying to figure out what was wrong with some cameras he owned. They were powered by cheap wall-warts and failing. We were trying to check these power supplies to make sure they were working, as we didn't know if the problem was with the power or the camera. Sure enough, some of the supplies were dead.

We tried to substitute in some switchable supplies to get them working. In the process, I noted with the multimeter that the polarity was different on the switchable supply from the adapters we were trying to replace. As we were plugging in these 2-prong plugs haphazardly into 3-prong outlets, I wondered out loud if we might have the plugs in upside-down.

He looked at me condescendingly and said "Oh, I see. You have a degree in this, do you?"

Well firstly, it's been 15 years, and secondly...while he may know a lot about being an electrician I know about the diode bridge inside the stupid wall wart. And yes, diodes can tell the difference between electron source and electron sink. But if the power is an AC sine wave then it spends as much time in an up cycle as down cycle and so the decision about polarity is in the circuit post-rectification, etc.

(So it was; to change the polarity on the adapter you just changed the terminals on the plug once it had been converted to DC, not before. Fine.)

But the hypothetical question kept nagging me. Given that one of the terminals is ostensibly true ground, would it be possible to build an AC/DC converter whose DC polarity would flip based on which way you plugged it in (and I'm talking about no connection to 3rd prong)? Do such things exist?

  • \$\begingroup\$ I got tempted to edit out all the irrelevant fluff in this question, but in all honesty, you've made a good & entertaining story to read, so I decided it has to stay. chuckle \$\endgroup\$ – vaxquis Aug 20 '15 at 18:32

No way. Given just a differential, just a pair of connections, there's no way for a circuit to tell which is which.

If you had access to phase information about the grid, you might be able to do it, but as the mains frequency isn't terribly constant, you would not be able to rely on predicting this. Your device would have to get information about the present phase angle of the mains from someplace.

However, if you do have a real earth-ground reference from some place, you could build a circuit to look at the voltage of each supply line with respect to ground. One will be a small drop below the full 120 (or whatever the local mains supply) whereas the other will be slightly above ground. (Neutral return current vs your neutral run's resistance). This would just let you know which leg was 'hot', and you could swap your output polarity accordingly.

A Second Thought

If the power supply has only four connections with the world, two from the mains plug, and two to output the DC, there's no way I can think of that you could deterministically set output polarity based on plug orientation.


if you're willing to make your otherwise simple supply a lot more complex, you could conceivably make it so that if you pulled the plug and flipped it, and plugged it back in straight away, the output would flip.

Here's the idea: You stuff some kind of micro-controller in the box, that monitors the line voltage, and determines when rising-crossing-zero (or some other phase point) happens on one of the legs. You'd have to reference this to the midpoint of the two supply legs via a voltage divider. The micro could then anticipate when the next such phase point would occur. Now you'd also have to put some kind of super-cap in the box and pick a low power micro that could live off the super-cap long enough for the user to flip the plug. When power comes back, either the anticipated phase change happens when you expect, or half-way between. Half-way between means the user flipped the plug, so your micro flips the output polarity.

Of course, that still would be problematic. If the thing had been unplugged for a while, the micro would be dead, and you'd have to make an assumption about what the output polarity should be. Finding a micro that could last maybe 10 seconds on a cap's worth power while actively chugging away could be easier said than done. Last and not least, this would really only be a novelty gadget.

  • 1
    \$\begingroup\$ Yes the third prong would help but you can't plug it upside down then under current designs. :) \$\endgroup\$ – HostileFork Jan 3 '11 at 2:01
  • \$\begingroup\$ Isn't 1 of the prongs tied to the ground pin (at least in the US)? If this is the case then if you have reference to some other ground you could detect which line had AC on it and know which output polarity you wanted. \$\endgroup\$ – Kellenjb Jan 3 '11 at 2:42
  • \$\begingroup\$ Another though, take the ground pin on the plug and make it spring loaded. If you plug it in correctly the ground pin goes in correctly. If inverted the pin will be pressed in and could cause a switch to switch the output polarity. Might be odd, worthless, and wouldn't work in outlets with no ground, but could work. \$\endgroup\$ – Kellenjb Jan 3 '11 at 2:44
  • \$\begingroup\$ @Kell the third prong is tied to the ground. The main two are tied to a live and a neutral wire. If you had all three then you could detect which is live and which is neutral by measuring voltage w.r.t. the ground. But the OP is that you don't have that ground reference. \$\endgroup\$ – Roman Starkov May 11 '11 at 0:17
  • 1
    \$\begingroup\$ I'm not sure why this answer, which is actually correct, hasn't been upvoted as much as the other two answers, which seem like jokes. \$\endgroup\$ – psusi Mar 15 '12 at 14:05

This circuit will do what you want (for a literal interpretation of the question):

alt text

  • 2
    \$\begingroup\$ What is ADXL103, and where is my hossenfeffer? \$\endgroup\$ – tyblu Jan 3 '11 at 5:35
  • 8
    \$\begingroup\$ Hahahahahahaha - What this is doing is literally detecting if it is upside-down or not. The accelerometer detects if it is inverted, and changes the polarity by toggling a relay based on it's physical position. \$\endgroup\$ – Connor Wolf Jan 3 '11 at 8:09
  • 1
    \$\begingroup\$ Why use an accelerometer - just use a mercury switch / or tilt switch to operate the relay from the supply... \$\endgroup\$ – Wonko The Sane Jan 3 '11 at 23:26
  • 4
    \$\begingroup\$ Mercury switches were hard to find even before RoHS. And the rolling-ball tilt switches are really noisy and bouncy. The ADXL 103 has +/- 1.7g, which means the voltage facing "up" is 2.5+2.5*1/1.7, or 4V, and the voltage facing down is 1V. The Schmitt-trigger gives about 1V (or 0.7g) hysteresis. This should remove false triggers caused by vibration, and even under zero-g conditions (being thrown across the room in frustration, say) the circuit will maintain its previous state. A realistic circuit will use all six gates in parallel and a low-current relay, or add a transistor. \$\endgroup\$ – markrages Jan 4 '11 at 0:42
  • 1
    \$\begingroup\$ +1 for the most absurd and entertaining answer to one of the most absurd & entertaining questions lately! Go go the wicked ACME squad! \$\endgroup\$ – vaxquis Aug 20 '15 at 18:36

Actually yes, you can. Ever used one of those nifty non contact voltage testers?


They can pretty reliably figure out which wire is phase and which is neutral, so all you'd need to do to build a magical wall wart would be to integrate such a sensor (just an antenna and an opamp).

  • \$\begingroup\$ Link doesn't work for me. \$\endgroup\$ – Kellenjb Jan 3 '11 at 2:52
  • \$\begingroup\$ Should work now. \$\endgroup\$ – Gabriel Ebner Jan 3 '11 at 2:54
  • 1
    \$\begingroup\$ Have you actually ever used one of those? They can be very sensitive and pick up AC from over a foot away. It isn't really the best method for trying to find the neutral vs hot. \$\endgroup\$ – Kellenjb Jan 3 '11 at 5:42
  • \$\begingroup\$ The existence of this thing raises the question of how such a thing works, as that is the issue here. Antenna and op-amp, but how? \$\endgroup\$ – HostileFork Jan 3 '11 at 6:23
  • 2
    \$\begingroup\$ @Kellenjb I've got a cheap one from Conrad. It's not that sensitive, and sometimes it's even fooled by a thick layer of insulation. \$\endgroup\$ – Gabriel Ebner Jan 3 '11 at 12:16

Short answer is, no, it is not possible.

With a rectifier you are taking the negative part of the sine wave and flipping it to be a positive wave or to just ignore it. Because of this it doesn't matter what way you plug it in, negative will always be chopped off.

  • \$\begingroup\$ i think he's thinking along the lines of maybe reversing the output (dpdt relay/h-bridge would do) in response to being able to determine which way the plug is. figuring out which way the plug is would be the harder part. \$\endgroup\$ – JustJeff Jan 3 '11 at 1:57
  • \$\begingroup\$ I'm wondering if there's some other outlier that could be drawn in to make this "magic" adapter. Something that interacts with the atmosphere to help discern true ground, I dunno... just imagining an inventors challenge to build such a device. Sure, a radiotransmitter which lets you know the local power grid's phase... but... is there better? \$\endgroup\$ – HostileFork Jan 3 '11 at 2:05
  • \$\begingroup\$ Although it might be fun to build something you plug in elsewhere in the house, that then gives an AC/DC adapter this property. My friend would baffle for a bit, until he found it. :) \$\endgroup\$ – HostileFork Jan 3 '11 at 2:06
  • \$\begingroup\$ @Hostile Fork: elsewhere in the house, you could put a widget that puts a couple msec burst of 10kHz onto the mains at a selected phase point. Your Magic Supply could detect this. But then, many of your un-magic supplies might find this purposeful EMI objectionable. \$\endgroup\$ – JustJeff Jan 3 '11 at 2:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.