Lego Power Functions Connector Pinout
The Lego Power Functions electrical system replaced the older 9v system used on the Interface B (AKA Control Lab or 9751) and RCX, for connecting motors and in a small number of instances, sensors. The new connector retained the nominally 9v rating, but was no longer possible to rotate to change polarity. To solve this, reversing switches are available, and the most common battery box has a three position switch with both polarities as well as off.
The main advantage of the Power Functions connectors is that they carry an unswitch 9v power bus as well as the traditional reversable control signals. The permanent 9V is used to power the IR receiver, and is always passed through an IR receiver even when outputs are off. I suspect sensors also used the permanent 9v to power their circuitry without interruption.
This is a significant advantage over the older 9v system where sensors used to have to harvest and store power in a capacitor with the input port being momentarily switched to a different mode to recharge the capacitor and keep the sensor powered.
The Pinout
The Power Functions pinout is as follows.
It can be seen that the outer two pins have fixed voltages regardless of the polarity of the orange switch, while the pins labelled A and B (conventionally called C1 and C2, but I was unsure which was which) are swapped depending on whether the orange switch is in position 1 or position 2.
With the connector oriented with the two knobbles / studs at the top, numbering contacts from left to right, 1 is always ground, 4 is always 9v, and 2 & 3 are switchable so that one is 9v (or a reduced power signal when using an analogue controller) and the other 0v. When powered, but with no direction signal (for example plugged into a powered IR receiver, but with no buttons pressed on the basic remote), both 2 & 3 are at 0v.
With this battery box, the third central position of the orange switch completely turns off the power to all pins.
9v to Power Functions Adapter Cables
Warning! When making adapters between Power Functions and 9v, you must not connect the outer two contacts on the Power Functions end. This could/will result in a short.