9
\$\begingroup\$

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/D2 is I2C). 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).

I know this is a easy fix by just using a correct plug, but this is not what I'm asking. Question isn't really about the plug, but how to solve the problem for the plug I'm describing below.

Layout of pins can be changed to whatever could best solve the problem.

Here is a visualisation of the connection I have so far: enter image description here

I have to make it so that no matter what way I attach a plug 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: enter image description here

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:

enter image description here

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:

enter image description here


On a side note here is my first iteration I came up with that had 4 pins in a line. Left side is signal source and right side is slave device:

enter image description here

While this works it has some issues, and is not ideal because of some other constraints that I don't wan't to go into. Ideally I wan't to solve this for the 4 corner configuration.

Another thought was adding clock and data to the power rail with some opamp magic and then decoding it on the other side. But it probably is a lot more complicated than I imagine, considering noise, power draw etc.

\$\endgroup\$
19
  • 2
    \$\begingroup\$ What are the "signals"? Digital/Analog? Are they the same voltage as the power supply? push-pull/open-drain/etc? Are they frequently changing, or can they sit at a certain voltage level for extended periods (and if so how long)? Can you change this (i.e. is the external device off-the-shelf, or are you making both ends)? \$\endgroup\$ Commented May 20 at 11:35
  • 1
    \$\begingroup\$ I'm making both ends of the device. The signals are I2C. I have protections on both ends for cases when power is fed in to them. And they are flipped at the source end to adjust the data/clock lines so they match what the slave needs. \$\endgroup\$ Commented May 20 at 11:54
  • \$\begingroup\$ In your solution you have a voltage drop of two body diodes and two normal diodes which sums up to around 2.4 - 2.8 V difference between the external supply and the MCU. Is this acceptable? \$\endgroup\$
    – Jens
    Commented May 20 at 16:44
  • 3
    \$\begingroup\$ If you're making both ends of the device, why the restriction that you can't use any plug you like? \$\endgroup\$
    – Hearth
    Commented May 20 at 20:29
  • 2
    \$\begingroup\$ @somerandomusername It would be helpful if you can fully explain why this constraint is there. Otherwise, it's hard not to want to just say that you're using the wrong plug for the job. \$\endgroup\$
    – Hearth
    Commented May 21 at 12:34

5 Answers 5

2
\$\begingroup\$

I think this works, but I haven't simulated or tested it.

Attempt at solving the problem

Here's what's going on: The mating connector must have power in the two corner pins, and I2C in the other two corner pins.

There are two bridges (with their outputs coupled together) to provide power to the MCU, and all four pins have pull up resistors connected to the bridge output positive. The MCU needs to have two I2C ports. You might need to add a voltage regulator to the power lines before the MCU.

Let's look at an example of it in use:

enter image description here

Here we've connected +ve power to the top right (red) and ground to the bottom left (black). I2C are the green pins.

The active I2C lines in this case are the orange ones.

If you were to use a PSoC microcontroller from Infineon to implement the I2C swapping, you'd need to implement a circuit inside it to perform the swap at run time (it's not a function already provided by the I2C component). This design uses two pairs of external pins, which would need to be connected together on the PCB (blue dashed lines). There's also a way to do it by reprogramming the configuration registers, but that would need some digging into the technical reference manual.

I2C Pin swapping on the PSoC

They're pretty low cost devices, but may not be cheap enough for your application.

\$\endgroup\$
11
  • \$\begingroup\$ Oh. This definitely looks promising. I have only one I2C hardware interface on the IC I'm using. But I can route multiple pins to it internally. Will play around with this and see how it goes. I have a bunch of free pins to try and "listen" on each of the 4 corners to "see" the orientation and select appropriate I2C pins - without waiting on data from them. \$\endgroup\$ Commented May 21 at 11:21
  • \$\begingroup\$ I put it in a simple online falstad simulator and it seems to work as you described. I will try to breadboard this soon and see how it goes. \$\endgroup\$ Commented May 21 at 12:11
  • 1
    \$\begingroup\$ @somerandomusername - Nice. I hope it works. I'd love to know what the project is. \$\endgroup\$ Commented May 21 at 12:18
  • 3
    \$\begingroup\$ Note that this is actually the same as the answer by @2012rcampion, just drawn differently. \$\endgroup\$ Commented May 21 at 14:58
  • 1
    \$\begingroup\$ @Rocketmagnet so I put it together on a breadboard and it works exactly as described. This is a amazing solution, and easy/cheap component wise. Thank you. \$\endgroup\$ Commented May 22 at 14:28
8
\$\begingroup\$

Instead of four discrete pins, use a 4-circuit circularly-symmetrical connector.

These connectors may be plugged-in in any orientation. Regardless of orientation, each contact is connected to the corresponding contact in the mate. There is no need to detect the orientation and reroute the signals.

  • In-line:
    • Helicopter headphone (top left)
    • 3.5 mm TRRS phone (middle left)
  • Coplanar:
    • Concentric coplanar cylindrical (top right)
    • Flush concentric (bottom right)

circularly symmetrical connectors

{Sources: Digikey, Digikey, LEMO, Fischer}

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Thank you for your input. I probably should have made it clearer that I'm really not asking this as a solution for the plug. But as a signal/pin detection problem. For reasons I won't go into I need to solve it for the plug that I described. \$\endgroup\$ Commented May 20 at 12:51
1
\$\begingroup\$

You can also consider moving almost all inteligence into master - put current-limited H-bridge + i2c on each leg. On slave, put protection diodes on scl and sda (against + and - leg) and antiparallel diode between + and -. Master can probe (single) combination that is shorted by diode, then reverse polarity and communicate normally.

\$\endgroup\$
0
\$\begingroup\$

Is it a strict requirement that your I2C and power are run on separate sets of pins? If not, you can add a chip like the MAX20340 that will let you send and receive data over your DC power line, which makes your connector orientation issue significantly easier to solve (your original bridge circuit might be sufficient).

\$\endgroup\$
3
  • \$\begingroup\$ Yes I did consider using I2C over power line. But when I looked into it all the IC's where quite pricey. Wouldn't be a problem for one off device. But I will potentially need couple of hundred of these "connectors". So put together with other components it wouldn't scale well. \$\endgroup\$ Commented May 22 at 7:42
  • \$\begingroup\$ To put it in perspective all the parts+pcb for one of them would be around 1USD, so this kind of MAX20340 would double or triple that. \$\endgroup\$ Commented May 22 at 12:47
  • \$\begingroup\$ @somerandomusername That was just the first example I could find, others exist that may be cheaper. Also, don't forget to factor in your time. Spending 15 hours of engineering time trying to design something custom would likely cost more than spending $300 on additional parts. \$\endgroup\$
    – bta
    Commented May 28 at 19:25
-1
\$\begingroup\$

The correct answer is to use a stout plug that has survived for decades of use and costs a few cents.

Designing your own connector is expensive and error prone. However as an exercise, avoid a circuit-based solution and use geometry?

This assumes you have some lee-way to move the pins a little. If they're fixed in a square, this solution won't work.

One side : viewed from above. Each pin can land in any of 4 positions, which are simply pads on the same track and are joined together.

+-------------+
| - D2   D1 - |
|D1 +     + D2|
|             |
|             |
|D2 +     + D1|
| - D1   D2 - |
+-------------+

Other side: (for simplicity, this is viewed from above also, so mirrored or "through")

+-------------+
| . .     . . |
| . +     . D2|
|             |
|             |
| . .     . . |
| . D1    . - |
+-------------+
\$\endgroup\$
1
  • 2
    \$\begingroup\$ Sorry. You assume that this is about the connector. But it isn't. Imagine that there are some dark forces that prevent me to do anything to the connector. This question is about the problem that I described, not the connector. \$\endgroup\$ Commented May 21 at 6:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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