The CAN transceiver boards on the pan tracker were hanging off loose jumpers, and the bus between the Nucleo and the Jetson was hand-twisted wire. Due to my deep-seated fear of bumping my boards to the point of destruction: I decided to print an enclosure for the motor driver on my new Bambu A1. It went well, so the CAN boards were next.

A USB-C cable already has a twisted pair (D+ and D−) and a ground, so I put a USB-C port on the end of the enclosure, and now any USB-C cable is a CAN cable!

Background

CAN
A bus where every node shares two lines, CAN-H and CAN-L. Each bit is the voltage difference between them, so noise that hits both wires equally cancels out. It’s all over cars and robots.
Transceiver
The chip between the microcontroller’s CAN controller (TX and RX logic pins) and the bus wires. The SN65HVD230 is a 3.3 V part, and the Waveshare board has a 120 Ω terminator on it.
Twisted pair
Two wires twisted around each other so they pick up the same noise.
D+ / D−
The USB 2.0 data pair, which runs as a twisted pair inside a USB-C cable.
Heat-set insert
A brass threaded insert pressed into a printed hole with a hot soldering iron, so the screw bites metal instead of plastic.
TEC / REC
Each CAN controller’s transmit and receive error counters. 0 means it hasn’t seen any errors. A node with low counts is “error active”, the normal state.

The enclosure

My second Fusion design, after the VNH5019 enclosure.

Fusion render of the open shell, with the USB-C recess on the near end and two screw posts inside, next to the base plate with two rails

  • Fits a Waveshare SN65HVD230 board and a 16-pin USB-C panel-mount breakout (20 × 6.6 mm metal faceplate, with V / D− / D+ / G pads).
  • The faceplate sits flush in a recess on one end, held with two M2 screws.
  • A slot on the other end for the board’s 4-pin header (3V3, GND, RX, TX), so the Dupont jumpers plug in from outside the box.
  • Stepped rails on the base plate locate the board and keep the solder joints underneath off the base.
  • The base plate screws on with two M3 screws into heat-set inserts.
  • “CAN” is embossed on top. I was quite pleased with the lettering, my first time trying that in CAD!
  • The shell prints upside down (top face on the plate) and the base prints flat, no supports. PETG, 48 minutes, 18 g.

The printed shell and base plate on the A1’s textured build plate

Wiring

The open enclosure on a cutting mat: the USB-C breakout and the CAN board joined by twisted red and yellow wires, a black ground wire, and brass inserts in the screw posts

  • CANH → D+
  • CANL → D−
  • GND → G
  • V (VBUS) left unconnected

I also wanted a shared ground between the STM32 and the Jetson, so that’s a bonus on top of cleaning up the wire clutter.

D+ and D− are a twisted pair in the cable, which is exactly what CANH and CANL want. I also twisted the wires inside the box. The breakout connects both rows of the USB-C receptacle, so the plug works either way up. I checked continuity end to end with the plug both ways to be sure, and the mapping was the same.

Testing

The bench: the Jetson with a CAN enclosure next to it at the top, the Nucleo with the other enclosure at the bottom, and a white USB-C cable between the two
  • Classic CAN at 1 Mbps, with one enclosure at each end of the bus (Nucleo and Jetson) and less than 1 m of cable.
  • can test 10000 on the Nucleo sends 10,000 frames, and can_echo.py on the Jetson sends each one back.
  • 10,000/10,000 round trips, 0 gaps, 0 bad data!!! Love to see it.
  • Nucleo TEC/REC stayed at 0. The Jetson stayed error active with 0 bus errors.

It’s not USB

It looks exactly like a USB port, but it carries CAN. I’ll be careful to never put either end into my Mac!