Skip to the content
PCBKitNew board
2 layers90 × 89.4 mm38-04-usb sleuth, the printed circuit board in 3D

38-04-usb sleuth

smaroukis/usb-sleuth61

USB cable continuity tester ++

Size
90 × 89.4 mm
Copper layers
2
Thickness
4.69 mm
Parts
68
Nets
90
Pads
320
Tracks, vias
978, 131
Pours
502
Routed
Yes
KiCad
KiCad 7 (file 20221018)
Created
14 Dec 2023
Updated
27 Apr 2024

Overview

38-04-usb sleuth is an open-source printed circuit board by smaroukis, from the smaroukis/usb-sleuth repository on GitHub. It is a 2-layer board of 90 × 89.4 mm with 68 parts on 90 nets, routed with 978 tracks and 131 vias.

It is built around the STM32C031K6T6, CR2032 and ZX-1.27BM-4PSMD. Its parts include 25 diodes, 6 connectors, 5 capacitors, 5 resistors and 2 switches. It belongs with the STM32 boards of this library.

Main components

3

README

README.md

See this README for usage of the STM32CubeIDE to flash firmware on the device.

Overview

The device tests for continuity and internal resistors within various USB Cables and exposes some pins for multimeter testing. The project is a hardware fork of aroerina/LimePulse that I decided to reverse engineer and write the firmware for.

A STM32C031K6T microcontroller is used for testing connection and orientation, powered by a CR2032 battery. Code is given using STM32 HAL libraries and the device can being programmed over SWD.

KiCad and gerber files are provided for the board layout, as well as the library footprints for non-standard parts ordered from JLCPCB/LCSC. See the BOM.

This USB cable tester has the "B" side on the right, and the "A" side on the left. Receptacles are given for the following:

  • Type-C (both sides)
  • Type-C to A
  • Type-C to micro B (2.0)
  • Type-C to mini B

The device has some benefits over a simple continuity tester

  • displays the as-plugged orientation of the 4 different possibilities of the USB-C to C cable
  • detects pullup and pulldown resistors on the CC lines as required by the USB standard for legacy cables
  • identifies active cable with E marker (via the pulldown resistor present on VCONN)
  • doesn't apply a +V to the Ground line/pin, instead it uses a MCU to test the presence of a connected ground wire
  • exposes various pins to test cable and internal resistors manually with a DMM

Example Tests

USB C-C Active Cable

Note in this test only one of the USB 2.0 Data pair LEDs will light up depending on the cable orientation, showing that the two pairs are not connected inside the cable (the pairs are also not connected on the PCB). The user must flip the orientation to test both data pairs.

DMM Test of Internal Resistor

Testing the value of the pulldown resistor on an active cable by measuring between B_CC2 and B_GND (should be between 800-1.2K Ohms).

OTG Test

General PCB Layout

Layout

  • Various B side pins are biased to VBUS through pullup resistors. A side pins are either connected to ground through an LED, thus lighting up if the corresponding wire is continuous, or the pins are connected into the MCU for inputs. These pins that the MCU tests for are as follows:
  • Ground (note all four GND pins are tied together)
  • VBUS (note all four VBUS pins are tied together)
  • CC1 to test for CC line and orientation
  • CC2 to test for VCONN line and pull down resistor for active cables, as well as a flipped CC cable

Note: Both A-side and B-side CC1 and CC2 pins are tapped off into corresponding control inputs to the MCU through a resistor, allowing for pulling the control pins high or low to sense the result on the opposite side.

Simplified layout of testing CC1 pin.

Programming and Reset

Programming is done via the Serial Wire Debug headers (labeled DEBUG) via an STLink debugger probe.

The device can also be reset by shorting out the nRESET line to GND (pins 1 and 2 on the header).

[!CAUTION] In the case where the debugger is providing power to the target, make sure the POWER switch is OFF.

[!NOTE] For the SWD pins we need pullup or pulldown resistors on SWDIO and SDCLK respectively. These are provided internally by the STM32 MCU, but if there is an issue with the debugger try adding an external weak pulllup and pulldown (10K-100K).

Description of Operation

Sensing VBUS and GND

[!NOTE] VBUS: Pulled up on B-side to VDD via 2K, pulled down to ground at A-side MCU input sense pin via 10K. Sense pin reads high if VBUS line is continuous through the cable. GND: B-side receptacle ground pin connected to board ground, A-side receptacle pin is direct to input sense pin.

All VBUS pins are tied together and tested via a pulldown resistor on the MCU (similarly for GND pins).

Most B-side receptacle pins are pulled up to supply/VDD through resistors with exception for CC pins and Ground. B-side ground is connected to board ground through a DIP switch for isolation from the MCU ground if needed.

A-side receptacle pins are connected to the MCU input for sensing.

A_VBUS/A_GND and connected to VBUS_SENSE/GND_SENSE inputs to the MCU through DIP switches for isolation from the MCU during DMM testing.

VBUS_SENSE pin is an input to the MCU with a pull down resistor forming a voltage divider with the 2K VDD pulllup resistor. If the VBUS line is discontinuous, the pin reads LOW. If VBUS is continuous then the pin reads VCCx10/12, or digital HIGH.

Indicator LEDs are driven by the MCU outputs GND_LED and VBUS_LED.

MCU Testing Logic

Orientation of CC Pin

Here is the type-C receptacle pinout

Source: "USB 2.0 Type-C Plug Pin-Out" https://ww1.microchip.com/downloads/en/appnotes/00001953a.pdf

Possible orientations of USB-C Plug.

Note Ra is for the active pulldown emarker, but don't take this "straight through" configuration literally as there are diodes preventing shorting of the pins.

Simplified PCB layout:

We can determine that a C-C type cable is connected by pulling both A_CC1 and A_CC2 HIGH and CCx_CTRL pins LOW, then looking for one of the B_CCx pins coming HIGH.

MCU Testing of Ra on Emarker (Active) Cables

The pulldown (Ra, for "active") is nominally 800-1.2K. Connection is as follows:

We simply configure the A_CC2 and B_CC2 pins as INPUT_PULLUPs and test if these lines (the VCONN line) are pulled low (normally it is open), since the pulldown Ra is strong at ~1K.

MCU Testing of Rp on Type-A to Type-C Cable

[!NOTE] It is programmed to work for both USB-C plug orientations

Setup

  1. VBUS is connected to VCC through a 2K resistor (ignored for the calculations below)
  2. Write CC1_CTRL and CC2_CTRL → LOW (pulls B_CCx pin toward ground through 10K R)
  3. Perform analog read of B_CC1_sense and B_CC2_SENSE
  4. If the analog read is above a threshold, RP_THRESH, to account for ground noise, then the 56K Rp pullup exists.

[!TIP] An analog read is required since the internal Rp is weak enough such that it doesn't pull it all the way up to the digital HIGH threshold

MCU Testing of Rd on Type-B to Type-C Cable

Note this works for both CC configurations

  1. Set A_CC1 as INPUT_PULLUP (~50K internal pullup)
  2. Read A_CC1, if pulled LOW, then it means that Rp is present (Rd = 5K which is much stronger than the 50K internal pullup)

Power Isolation For Testing

Isolation switches are provided to isolate the DMM from the MCU as it injects a test current to measure resistance, and also to allow us to measure the resistance of the cable itself (e.g. VBUS to GND).

Note during testing it was found that even with the switches closed the DMM measurements weren't affected.

In the schematic these are modeled as a multi-unit DIP switch:

  • SW2A: Separates VCC from VBUS
  • SW2B: Separates B_GND from GND
  • SW2C: Separates A_GND from A_GND_SENSE (input to MCU)
  • SW2D: Separates A_VBUS from A_VBUS_SENSE (input to MCU)

DMM Testing

DMM Testing of Rp on CC line

[!Caution] Verify the following:

  1. USB cable is in the normal CC Orientation of STD>STD before proceeding (or note the configuration to choose the correct pad to test)
  2. All DIP switches are in the OFF position
  3. Power switch is in the OFF position

For the Type-A to C cable the USB standard specifies at 56K pullup resistor between VBUS and CC (since the A side is the host, CC pin needs to be pulled up for the B-side/peripheral to recognize A side as host).

We can test the exact value of this resistor by using a DMM between B_VBUS and B_CC1 testing pads.

DMM Testing of Rd

[!Caution] Verify the following:

  1. USB cable is in the normal CC Orientation of STD>STD before proceeding (or note the configuration to choose the correct pad to test)
  2. All DIP switches are in the OFF position
  3. Power switch is in the OFF position

For the Type-B to C cable the USB standard specifies at 5K6 pulldown resistor between CC and GND (since the B side is the peripheral, CC pin needs to be pulled down for the A-side/host to recognize B side as peripheral).

We can test the exact value of this resistor by using a DMM between A_GND and A_CC1

DMM Testing of Ra

  1. With device ON, make sure the CC orientation is STD>STD
  2. Switch isolation switches to OFF
  3. Switch power OFF
  4. Place a DMM between B_CC2 and B_GND since the Ra will be on the VCONN line.

Shields and ID Pin

Shields

Shields are connected together and exposed to a through hole testing terminal. For this we can test with a multimeter.

Note the shield and ground are connected inside the receptacle.

ID (On The Go / OTG)

The OTG specification allows a USB device normally acting as a peripheral, to now act as a host (example use case: a tablet normally a peripheral, acting as a host can read from removable media on a flash drive)

For the OTG cable the A-plug side ties its ID pin to ground, and the B-plug side leaves it floating.

Since the ID pin is supposed to be tied to its ground pin within the plug, we just connect an LED between VDD → ID pin (=Ground pin) to test the connection.

The ID pin is also brought out on an exposed pad.

FAQ

Only one set of the D+ and D- pins light up.

  • The D1+/- and D2+/- pins are not connected together to allows the user to test both sets of pins independently (but requires the user to flip the USB-C side)

OTG Cable test doesn't work?

  • Make sure the test setup is as shown in the examples

If the OTG cable has two male plugs, the data lines are not connected between the male ends, only from female → male 1 and female → male 2. The proper way to test will require the OTG adapter plus a normal USB cable.

With one end plugged in, when I touch the other cable plug to the receptacle the GND (and sometimes Rd) LEDs light up.

  • This happens because the tester first checks for VBUS=+Vsupply, and next checks for Ground=0V. If GND=0V it waits 300ms for the plug to "seat" before running through the other tests. But since the receptacle chassis and plug sheath are connected to GND, if you touch the plug to the receptacle it will read GND as 0V and proceed with the other tests. In the USB C<>B case, the Rd test will run if the CC pins aren't connected through on both sides, so it will also test once this contact is made.

Notable Documentation

The USB-C Type Spec provides the Rp and Rd requirements for legacy cables.

For example, Type-C to 2.0 Type A:

USB Type-C Spec R2.3 - October 2023.pdf

tl;dr any legacy cable assembly that sources power to a Type C connector must use the default 56K pullup (note this is for both 3.1 and 2.0 versions, since the power negotiation didn't come along until later)

Note the A5 CC pin and the B5 VCONN pin are not connected internally. This means it is up to the hardware developer to implement orientation detection on the C-receptacle side.

And here is for the Type-C to 2.0 Micro-B: ^dzdzs5

Improvements

  • USB C<> Micro/Mini B D+/D- LED pair is dependent on C side orientation - make it more user friendly by only lighting up the bottom 2.0 row
  • Low power

Attributions

Icons

Inspired By

Parts

68
QtyValueFootprintReferences
25YLWLED_SMD:LED_0805_2012MetricD1, D2, D10, D11, D12, D13, D14, D15, D16, D17, D18, D19, D20, D21, D22, D23 +9
71K6Resistor_SMD:R_Array_Concave_4x0402RN1, RN2, RN3, RN4, RN5, RN6, RN7
4MountingHole_3.2mm_M3_DIN965MountingHole:MountingHole_3.2mm_M3_DIN965, , ,
3100nCapacitor_SMD:C_0402_1005MetricC1, C2, C4
310kResistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR1, R2, R3
22KResistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR4, R5
2USB_C_12401832E402A01-UserFootprints:USB_C_Receptacle_Amphenol_12401832E402AJ2, J3
11uFCapacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolderC5
14u7Capacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolderC3
1A_CC101-UserFootprints:Connector_Pad_Edge_Oval_5mm_ExtendedH4
1A_CC201-UserFootprints:Connector_Pad_Edge_Oval_5mm_ExtendedH5
1A_DRAINTestPoint:TestPoint_THTPad_D1.5mm_Drill0.7mmH12
1A_GND01-UserFootprints:Connector_Pad_Edge_Oval_5mm_ExtendedH9
1A_SHIELDTestPoint:TestPoint_THTPad_D1.5mm_Drill0.7mmH6
1A_VBUS01-UserFootprints:Connector_Pad_Edge_Oval_5mm_ExtendedH10
1B_CC101-UserFootprints:Connector_Pad_Edge_Oval_5mm_ExtendedH1
1B_CC201-UserFootprints:Connector_Pad_Edge_Oval_5mm_ExtendedH2
1B_GND01-UserFootprints:Connector_Pad_Edge_Oval_5mm_ExtendedH7
1B_SHIELDTestPoint:TestPoint_THTPad_D1.5mm_Drill0.7mmH8
1B_VBUS01-UserFootprints:Connector_Pad_Edge_Oval_5mm_ExtendedH3
1CR2032Battery:BatteryHolder_Keystone_103_1x20mmBT1
1Conn_1x05Connector_PinSocket_2.54mm:PinSocket_1x05_P2.54mm_VerticalJ1
1IDTestPoint:TestPoint_THTPad_D1.5mm_Drill0.7mmH11
1STM32C031K6T6Package_QFP:LQFP-32_7x7mm_P0.8mmU1
1SW_DPDT_x2Button_Switch_THT:SW_E-Switch_EG1271_SPDTSW1
1USB3_A_HC-USB3.0-L168-WP01-UserFootprints:USB3_A_Hong-Cheng_HC-USB3.0-L168-WP_THT-9-2MP_P2.0mmJ6
1USB_Micro-B_KH-MICRO5P-JN01-UserFootprints:USB_Micro-B_Kinghelm-KH-MICRO5P-JNJ4
1USB_Mini-B_U-M-M5DD-W-101-UserFootprints:USB_Mini-B_Korean-Hroparts_U-M-M5DD-W-1_SMD-5-4MPJ5
1ZX-1.27BM-4PSMD01-UserFootprints:SW-DIP-4P_P1.27mm_SMD-2x4SW2

Questions

How big is the 38-04-usb sleuth PCB?

It measures 90 × 89.4 mm and has 2 copper layers, 4.69 mm thick.

What parts does the 38-04-usb sleuth use?

68 parts, built around the STM32C031K6T6, CR2032 and ZX-1.27BM-4PSMD. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the 38-04-usb sleuth KiCad files?

From the smaroukis/usb-sleuth repository on GitHub, at the commit this page was made from: the board is 38-04-usb-sleuth.kicad_pcb and its schematic 38-04-usb-sleuth.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the 38-04-usb sleuth design in my own project?

Its repository states no licence, so its author keeps all rights: ask smaroukis before reusing the design.

Similar boards

  • 2 layers58.4 × 21.6 mmLimbusZero, the printed circuit board in 3D

    LimbusZero

    LMWB/LimbusZero

    Custom Microcontroller Board based on STM32C0-Series

    17 partsMIT
  • 4 layers175 × 40 mmBed lift, the printed circuit board in 3D

    Bed lift

    j9brown/bed-lift

    Motorized bed lift system

    117 parts2MIT
  • 2 layers333.4 × 149.9 mmOmega Mainboard, the printed circuit board in 3D

    Omega Mainboard

    skiselev/omega

    Omega Home Computer

    248 parts459GPL-3.0
  • 2 layers17.2 × 30.4 mmWeigand, the printed circuit board in 3D

    Weigand

    linklayer/BLEKey

    A Bluetooth Low Energy device for interfacing with Wiegand

    17 parts268
  • 4 layers188 × 188 mmITX Llama, the printed circuit board in 3D

    ITX Llama

    eivindbohler/itxllama

    422 parts246GPL-3.0
  • 2 layers61 × 36.8 mmKeebcard, the printed circuit board in 3D

    Keebcard

    rsheldiii/Keebcard

    Home of the KeebCard project - Kicad files, code, and more!

    15 parts112
  • 2 layers59.2 × 41 mmBluey, the printed circuit board in 3D

    Bluey

    electronut/ElectronutLabs-bluey

    Nordic nRF52832 BLE development board with sensors.

    79 parts96
  • 2 layers35 × 35 mmQron0b, the printed circuit board in 3D

    Qron0b

    qewer33/qron0b

    a sleek and low-power binary wristwatch

    35 parts62GPL-3.0