Switching / Multiplexing USB Data - Page 1
Forum section: electronics / beginners

author: joshua1909
author_rank: Newbie
timestamp: September 15, 2022, 12:36:48 pm
content: Hey all, I've been working on a project to build a cable pinout "solver". I've tried a few variations of my idea and I'm trying to narrow down why it's not working.Problem Background:I recently had a problem where I had access to an 8-pin connector. I knew that 4 pins were probably wired back to a USB port (for the sake of argument, let's say I knew it connected to a PC USB port), but I had no idea of the pinout nor access to check behind the connector.I needed to figure out the pinout, so I used a multimeter to identify candidates for the VCC and GND, then essentially "brute force" manually tested combinations of 4 pins to a USB drive that had an LED indicator on it when data was communicating. So eventually when I got the pinout correct, the USB drive lit up and I knew the pinout was right.The project:In future, rather than manually testing each cable pinout, I thought why not build a circuit that automates it. I figured something like an analog mux would let me wire in 8 possible pins to a single output. So I could test possible combinations. From my limited knowledge it sounded like an analog mux might work.To test it, I spliced a single USB cable data pin through a 4051 mux into a PC and ran the other USB wires directly (not through the mux). But the PC doesn't detect the USB drive. I also tested the wire running through the mux with a multimeter and got no continuity. After a bit of troubleshooting I realised the mux actually has resistance of ~125ohms and a continuity tester only pings if resistance is under ~40ohms. So it might be I had the mux correctly wired but just continuity test couldn't work due to resistance.I then decided on an analog mux with very low resistance, SN74CBT3251 at ~5ohms. The continuity test started working, but I still could not get the USB protocol working with a data wire running through the mux.I did a bit of research into some USB switching ICs, and I found that USB 2.0 wires require something like 60MHz frequency. I'm currently thinking that's where I'm going wrong in my logic and I actually need a switch or mux that can support a higher frequency connection.This is stretching my knowledge so I'd really appreciate any pointers or topics to look into.Cheers,Josh

author: ledtester
author_rank: Super Contributor
timestamp: September 15, 2022, 02:51:17 pm
content: How about using a scope to figure out which pins could be USB data lines?Here are some videos on probing the USB protocol:How does a USB keyboard work?https://youtu.be/wdgULBpRoXkHow does USB device discovery work?https://youtu.be/N0O5Uwc3C0oThen you can you use trial and error to figure out which is D+ and which is D-.

author: joshua1909
author_rank: Newbie
timestamp: September 15, 2022, 08:07:52 pm
content: Thank you for the pointers. I have watched those videos and it's a great insight into USB. I think separate to the actual protocol discovery, practically having to trial and error each potential pinout would be just as time consuming.It's the process of automatically switching the pinout I'm trying to automate.Instead of this -Imagine I'm presented with this and no idea which pins connect back to D+ and D-

author: ledtester
author_rank: Super Contributor
timestamp: September 15, 2022, 11:48:38 pm
content: You can trigger host initiated USB traffic by simply pulling either D+ or D- to V_USB through a 1.5K resistor. The host will send messages on the data lines once every millisecond for a period of time (haven't determined exactly how long.)See below for the rig I made to test this.Here is a capture of the data lines after pressing and holding one of the buttons:If you pull D+ high you will get traffic at the high-speed rate (12 Mb/s):If you pull D- high you will get it at the full-speed rate (1.5 Mb/s):So you could program a microcontroller to pull a line high and see what other lines show activity.Main source of info was this Renesas app note:https://www.renesas.com/us/en/document/apn/395-hosthub-detection-usb-disconnect

author: joshua1909
author_rank: Newbie
timestamp: September 20, 2022, 05:38:04 am
content: This is very coolSo basically you'd only be limited by the number and combination of GPIOs.I did kind of have my heart set on building an automatic pinout switcher, but this seems like a good solution.