I have an interesting problem that I'd like some input on. It's a bit complex, so I'll do my best to explain it clearly.
I have a connector with 4 pins arranged in a square pattern. The pins are designated as +, -, d1, and d2 (where d1 and d2 are some signal sources). The challenge is that the solution must work regardless of the connector's orientation when it is plugged in (i.e., it must be position-agnostic).
Here is a visualisation of the connection:
I have to make it so that no matter what way I attach a plug to it it will work. I can use a microcontroller and anything else I wan't. I came up with a solution, but would like to see if I can get some better ideas or improvements.
If I add a bridge in this configuration I will get power no matter what direction the plug has connected:
Next I would cut the signal for A or B lines using P-MOSFET and note in my microcontroller memory what line I am cutting:
If my microcontroller is still working after a few milliseconds, it means it has correctly identified the power and data pairs. It then triggers switches to route the data lines appropriately. If it guessed wrong and cuts off the power pair, the system will reset, turning off the microcontroller and MOSFETs. On reset, the microcontroller will try again with the opposite pair, remembering the last state it tried.
Here is a quick sketch of the configuration I imagine: