1
\$\begingroup\$

I'm trying to make a USB-C switcher.

I'm using a rotary switch (center) to have one input USB-C receptacle switch between two output receptacles. This is so I can plug my keyboard into the input and two computers into the two outputs, and use a knob to select which computer the keyboard is attached to without unplugging any cables.

Here is my circuit diagram:

Circuit diagram of USB-C switcher

The VBUS, D+, and D- lines of the two output receptacles are switched through the rotary switch and connected to the input receptacle. Pins CC1 and CC2 of each Output receptacle are joined, and then switched through the rotary switch and connected to the CC1 and CC2 pins of the input receptacle. A common ground plane is shared between all three receptacles and isn't switched by the rotary switch.

Here's the PCB I designed: USB-C PCB design from KiCad

I thought I could join together the CC pins (since there is only one CC line in USB-C cables) and pass the CC line through the switch to allow for native USB-C power delivery negotiation between each host and the keyboard. But when I soldered up the boards, that didn't work. No connection was made no matter what cables or plug orientation I used. It also didn't help to unplug one cable so only two cables were plugged into the device, one input and one output. I have verified with a multimeter that my solder connections on the board are sound.

My question is: why isn't passing through the VBUS, D+, D-, and CC lines of a USB-C cable, with a common ground, allowing USB connections?

I have a few ideas:

  • Maybe the fact that I'm sharing ground between all three receptacles isn't good, and is messing up various things.
  • Maybe the fact that B8 and A8 aren't passed through is causing some issue? But I've learned these are USB-C SuperSpeed lines and I think it should work fine to leave them unconnected. (I don't need high-speed data since I just want this to work for a keyboard.)

Thanks for the help!

\$\endgroup\$
8
  • 1
    \$\begingroup\$ Even without SuperSpeed, USB is a fairly fast interface that requires attention to signal integrity; your rotary switch and layout could be causing significant signal degradation. By any chance, do you have suitable equipment (such as access to an oscilloscope) to assess this? (it's worth noting that for an alternate design, you could maybe have the rotary switch control a dedicated, off-the-shelf chip designed for switching/muxing USB) \$\endgroup\$
    – nanofarad
    Commented May 6, 2022 at 17:20
  • 1
    \$\begingroup\$ Sorry, but your idea is never going to work - at least not that implementation of it anyway. USB's D+/D- signal lines must be routed as an impedance-controlled differential transmission line pair. You can't randomly rout them apart from each other like that, and your rotary switch is simply not able to maintain the impedance matching required. There's a reason that USB switch ICs exist. \$\endgroup\$
    – brhans
    Commented May 6, 2022 at 17:31
  • 4
    \$\begingroup\$ Using a rotary switch will bypass the hot-plugness of USB. It does not guarantee that power connects first and then data pins, or that data disconnects before power does. Not to mention the obvious that USB is a high speed differential data pair which does not tolerate impedance discontinuities. It would have been more correct to use a chip dedicated for USB multiplexing and to use the rotary to control the chip to select how the ports are routed. And CC pins cannot be combined like that. \$\endgroup\$
    – Justme
    Commented May 6, 2022 at 17:37
  • \$\begingroup\$ @Justme Thanks, can you elaborate on why CC pins can't be combined? Is it because the resistance used for power delivery negotiation needs to be measured with both pins? I was under the impression that there are two CC pins only for plug symmetry and plug orientation detection \$\endgroup\$
    – will
    Commented May 6, 2022 at 17:52
  • \$\begingroup\$ @nanofarad Thanks for the feedback! I wasn't taking into account signal integrity, or using a USB muxing chip (which I've looked into now). I don't have access to an oscilloscope to assess what's going on. However I don't think signal degradation is entirely the problem, because if I manually pull all CC pins to ground through a 5.1kΩ resistor, I can get a working USB signal through the device. \$\endgroup\$
    – will
    Commented May 6, 2022 at 17:55

3 Answers 3

1
\$\begingroup\$

The CC pin connections are not correct.

Sure, there is only one CC wire in the cable itself.

The other CC pin that is not wired 7n the cable is pulled down to ground via a resistor by the cable, in the connector, which enables the host to detect which way the connector is plugged in to host.

The cable wiring will then connect the remaining CC pin to the device, to detect if something is connected, and what type of device is connected.

The device (keyboard) will also detect cable orientation from which pin is connected to correct resistance by cable and which pin is connected to host.

Only when correct cable and device resistance signatures are detected, the host will turn the standard 5V VBUS on to power the device.

So having short-circuited the CC pins, the host can't detect cable orientation or device type so it will not turn 5V VBUS on.

Since your device is a keyboard, it is highly unlikely it needs to communicate USB PD, but even if it would like to communicate USB PD, nothing happens as the keyboard won't receive even 5V from host.

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

This board ought to work for a keyboard usecase, but there's a situation where this might not work.

It's indeed likely your problem is CC-related, but not in a way that anyone has correctly identified. With a 'smart' USB-C port (aka, most of the native USB-C ports), you only get 5V out of it when the port detects a pulldown out of certain range of values on one of its two CC pins. Even then, this circuit ought to work in the simplest usecase, as I don't see why the downstream devices wouldn't just expose the (typical, other values possible) 5.1K pulldown through CC seamlessly.

Unless you're using emarker-equipped cables for connecting any of the parts circuit, that is. The emarker is a cable-end-embedded IC, connected to the pin opposite of the CC pin, referred to as "VCONN". When two CC pins are connected together, the pulldown-connected CC pin and VCONN-bearing pin will be joined together, with the emarker IC consuming some current, and making the effective resistance no longer be (typical) 5.1K. This is what happened with Raspberry Pi 4.

My recommendation - test your board with a USB-A to USB-C cable, plugged into your PC's USB-A port. That is a surefire way to verify such a board, since there's no CC detection involved at any point, VBUS supply is non-conditional with such a cable. Otherwise, if you only have C-C cables, test if you actually get 5V on VBUS, given you're using a 'smart' port (most of them, save for USB A male-C female adapters). If not, this is most certainly a CC-related issue.

If a USB A-C cable works, see if your board works using the cheapest C-C cables possible, USB 2.0 only kind of deal, make sure they're not "100W". Such cables are +- guaranteed to be emarker-less.

While USB 2.0 does technically require impedance-matched pairs, it's well known for working through wet string, as they say - even more so for a keyboard, which is likely to use 12Mbps. See if you actually get USB errors - on Linux, sudo dmesg -Hw shows them in realtime.

\$\endgroup\$
9
  • \$\begingroup\$ What do you mean other answers not correctly identifed the problem? My answer does. The CC1 and CC2 pins can't be shorted together on a connector or proper detection of what is connected will fail and there will be no VBUS output from PC. \$\endgroup\$
    – Justme
    Commented Sep 10, 2022 at 23:06
  • \$\begingroup\$ Because the situation you describe only applies to emarked cables being used in this circuit, and you don't define that. If the problem is indeed Rd and emarker pulldown interference, then using emarker-less cables will help, and A-C cables will work too. Your answer incorrectly states 'this can't work at all', which is untrue and misleading, and doesn't help the OP understand what actually went wrong. In other words, you misidentified the scope of the problem. \$\endgroup\$ Commented Sep 10, 2022 at 23:30
  • \$\begingroup\$ My answer applies to both e-marked and non-e-marked USB-C to USB-C cables. Because the board shorts CC1 and CC2 pins together, it makes the PC to see the 1kohm Ra pull-down of the cable even without the keyboard, so the resistance is invalid and PC can't detect what is connected, as it would require to see 5.1k Rd of the keyboard. With the keyboard connected, there will be both Rd and Ra pulling down, so invalid resistance for detecting that a device is connected. Now, please explain in detail how did I misidentify the problem? \$\endgroup\$
    – Justme
    Commented Sep 11, 2022 at 0:04
  • \$\begingroup\$ Non-emarked cables don't have Ra. \$\endgroup\$ Commented Sep 11, 2022 at 0:33
  • \$\begingroup\$ Powered cables do have Ra if they require power for some other reason that the e-mark. But I get what you mean. It still does not work even with unpowered cable with no Ra, because the keyboard side CC pins are also shorted together, so PC will not see Rd of 5.1k, but it will see two loads of Rd, 2.55k, which is invalid resistance for sink detection. Which is why the keyboard might not work with USB legacy to C adaper if the keyboard sees too low voltage on CC pins because double Rd load. \$\endgroup\$
    – Justme
    Commented Sep 11, 2022 at 1:13
0
\$\begingroup\$

To summarise and conclude:

It's not possible to create a USB-C pass-through device and remain compliant. To remain compliant, you would have to act as a hub.

The reason it's not possible is that USB-C cables are either EMCA (Electronically Marked Cable Assembly) or not. For EMCA cables, one CC line is passed-through, and the other (called Vconn) is pulled down (800Ω ~ 1.2kΩ) and terminated. Optionally Vconn is also used to power an EMCA controller (E-Marker) so the cable can communicate its capabilities.

For non-EMCA cables, one CC line is passed through like before, but the other is not connected.

So if you join up CC1 and CC2 like you've done, it will work for non-EMCA cables, but not EMCA cables. If instead you pass CC1 and CC2 straight through, it will work for non-EMCA cables, and even if one of them is EMCA, in one orientation only. Two EMCA cables will still fail because the two EMCA devices will clash in either orientation.

Other than implementing a hub, or only using non-EMCA cables, the other option is to use a non-standard "extension cable". These cables have both CC lines passed through. Typically they're female on one end, so your Out A and Out B would need to be male, but that way you could get away either a EMCA or non-EMCA cable on IN.

Whatever way you slice it, pass-through is non-compliant. USB-C is not your father's USB...

\$\endgroup\$

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.