Can A 2-prong AC/DC Converter Switch Polarity Based On Inverting The Plug?
Answer : This circuit will do what you want (for a literal interpretation of the question): 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...