Part 4 · Technical supplement

CAN bus: the full story

This page is for readers who want the details: measured voltages, oscilloscope traces, part numbers and the exact faults. It is our field note from making both Iveco CAN buses readable and reliable. It is not a theoretical guide. It is what failed, why, and what finally worked.

← Back to Part 4 · Back to the Technical page

1 · Two physical layers

C-CAN and B-CAN are different electrical worlds

Many builders treat CAN as "just CAN". On the Iveco Daily 4x4 there are two distinct physical layers, and almost every difficulty in this project came from that difference.

C-CAN · engine / chassisB-CAN · body
PurposeEngine computer and other powertrain unitsInstrument cluster, lights, doors, climate control, switches
StandardISO 11898-2 high-speed CAN, J1939 messagesISO 11898-3 low-speed fault-tolerant CAN, Iveco-specific messages
Speed250 kbit/s50 kbit/s
TransceiverTJA1051 class (high-speed)TJA1054 / TJA1055 class (fault-tolerant)
Recessive (idle)CAN-H ≈ CAN-L ≈ 2.5 V, difference ≈ 0 VCAN-H near 0 V, CAN-L near 5 V
DominantCAN-H ≈ 3.5 V, CAN-L ≈ 1.5 VCAN-H ≈ 3.6 V, CAN-L ≈ 1.4 V
Termination120 Ω at each end of the busDistributed: RTH and RTL resistors at every node
When it failsA short or open line stops the busKeeps working on one wire, but a wrong interface can pull the whole bus down

Key lesson: you cannot use a high-speed transceiver on B-CAN. A ready-made monitor with a TJA1051 works on C-CAN, but on B-CAN it reads nothing useful, and if it ever drives a dominant bit it disturbs the body bus. For B-CAN you must use a fault-tolerant transceiver from the TJA1054 / TJA1055 family. Ours is a TJA1055T/3, the 3.3 V-compatible version, so no level shifter is needed between the transceiver and the ESP32.

2 · Speed and format

Finding out what we were listening to

We did not know the speed of either bus, or the message format, at the start. We went through many combinations of bit rate and frame format on both buses. With the wrong bit rate a CAN controller sees nothing or only error frames, which is indistinguishable from a wiring fault. Each wrong combination cost time looking for hardware faults that were not there.

The answer, in the end: C-CAN runs at 250 kbit/s with J1939 messages, and B-CAN runs at 50 kbit/s. On B-CAN we use a sample point of 80 %, which gives the most reliable reading on the slow fault-tolerant edges. Our early notes had both speeds wrong.

The bit time is easy to check on a scope once you know to look: at 50 kbit/s one bit is 20 µs wide. Trace 6 below shows a single bit.

3 · C-CAN

The start-up dominant fault

Symptom. With the monitor connected to the live C-CAN, we measured the healthy recessive state as 2.6 V on CAN-H and 2.4 V on CAN-L, a difference of 0.2 V. Powering the ESP32 by USB while it was connected caused an instant jump to 2.9 V / 2.1 V, a difference of 0.8 V. The transceiver was driving dominant. The engine computers logged fault codes and the instrument cluster went blank.

Cause. The transceiver on the monitor board had its mode pin tied permanently to "normal". During the first moments after power-up, before our firmware had configured the CAN transmit pin, that pin was low. A low on the transceiver's TXD input means "send dominant", so the transceiver drove the bus for that short time, right in the middle of other traffic. The software was already set to listen-only, but the software was not running yet.

Fixes, in the order we applied them:

  • Field workaround. Power the monitor first, wait until it reports that it is listening, and only then connect CAN-H and CAN-L. Never power it up while connected.
  • Permanent hardware fix. Remove the zero-ohm resistor that ties the TJA1051's S pin to ground, and tie S to 3.3 V instead. S high puts the TJA1051 into silent mode in hardware. Whatever the processor does during start-up, the transceiver cannot drive the bus. This is the correct modification for any CAN monitor.
  • Firmware. Configure the transmit pin as an output, high, as the very first action at start-up, before the CAN driver is installed. Then start the CAN driver in listen-only mode.

Framework change. Moving from ESP-IDF v5 to v6 changed the CAN (TWAI) programming interface. Listen-only became a flag in the node configuration, and acceptance filters use a new configuration structure. Our final firmware is built on ESP-IDF v6.0.2.

4 · B-CAN

Two faults that look identical on the scope

B-CAN was by far the more difficult bus, and it took weeks. The symptom was always the same. On the scope, the transceiver's RXD output toggled cleanly with every frame. In the log, the CAN controller reported no messages and no bus errors. It never saw a start of frame.

Fault 1: the inversion. On our first transceiver arrangement, the RXD signal arrived at the ESP32 inverted: low when the bus was idle, instead of high. With an inverted input, the CAN controller sees recessive as dominant and can never synchronise. We fixed this in firmware by inverting the RX input inside the ESP32's GPIO matrix before it reaches the CAN controller. That was the first time the bus showed message IDs. Trace 2 shows the inverted idle level.

Fault 2: the logic level. On our later custom transceiver board, the inversion was no longer the problem. Removing it made no difference: still no messages. The cause this time was the voltage. The RXD high level reached only about 1.8 to 2.0 V. The ESP32-S3 needs about 2.5 V (0.75 × 3.3 V) before it reads a logic one. So the controller saw a permanent low, even though the scope showed clean pulses. Trace 1 shows it. Changing the RXD pull-up from 1 kΩ to 3.3 kΩ brought the high level to about 3.1 V with a clean low, and the CAN controller synchronised immediately.

Why a different pull-up value raised the high level depends on that board's transceiver variant and protection network. The general lesson is simpler: measure the voltage at the processor pin, not only at the transceiver, and compare it with the processor's input thresholds.

The final B-CAN firmware is version 0.0.0.12: fault-tolerant CAN working, 3.3 kΩ RXD pull-up, listen-only, 50 kbit/s with an 80 % sample point, ESP-IDF v6.0.2.

5 · Oscilloscope traces

What we saw on the scope

All six traces are from the B-CAN. They were taken while we were finding the faults. The unit is now built into its enclosure and installed, so these are the only records we have. Tap a trace to see it larger.

Oscilloscope trace at 500 millivolts and 20 microseconds per division: RXD switching between about 0.35 volts and only about 1.8 volts.
TRACE 1 · RXD · 500 mV/div · 20 µs/divThe logic-level fault. RXD switches cleanly, but the high level is only about 1.8 V, below the ESP32-S3 input threshold. The controller sees a permanent low.
Oscilloscope trace at 500 millivolts and 2 milliseconds per division: RXD idles low between bursts of frames, with highs of about 1.7 volts.
TRACE 2 · RXD · 500 mV/div · 2 ms/divThe inversion. Between frames the RXD line rests low, where it should rest high. The high level is also weak, about 1.7 V.
Oscilloscope trace at 500 millivolts and 100 microseconds per division: RXD switching between about 0.15 volts and about 2.4 volts.
TRACE 3 · RXD · 500 mV/div · 100 µs/divA later capture. The high level is now about 2.4 V: better, but still just short of the threshold. Close enough to work sometimes, which is the worst kind of fault.
Oscilloscope trace at 1 volt and 100 microseconds per division: a bus line switching between about 0 and 3.9 volts, with a short low pulse after every five long high bits.
TRACE 4 · CAN-H · 1 V/div · 100 µs/divCAN-H switching between about 0 V (recessive) and 3.9 V (dominant). Note the regular short recessive bit after every five dominant bits: CAN bit stuffing.
Oscilloscope trace at 2 volts and 100 microseconds per division: a bus line resting at about 4.7 volts, then a frame starts and the line switches down to about 1 volt.
TRACE 5 · CAN-L · 2 V/div · 100 µs/divCAN-L resting high at about 4.7 V while the bus is idle, then the start of a frame, switching down to about 1 V for dominant bits. This is the "upside-down" resting state of fault-tolerant CAN.
Oscilloscope trace at 1 volt and 10 microseconds per division: a single pulse about 20 microseconds wide, from about 1.1 to 5 volts.
TRACE 6 · bus line · 1 V/div · 10 µs/divOne bit, about 20 µs wide: 50 kbit/s. Useful for checking the bit rate, and for seeing the slow edges and small overshoot of a fault-tolerant bus.
6 · Our own mistakes

Pins, pins and pins

Not every problem was in the silicon or the analogue world. The biggest single source of lost time was the pins. Development boards bring out only some of the chip's pins, and many of those are already used by the SD card, the Ethernet interface, the USB port or an LED. We repeatedly assigned the CAN transmit and receive signals to pins that did not exist on the board, or that belonged to the SD card or the Ethernet port.

On the Guition ESP32-P4 board, the signal from the GPIO pins did not reach the CAN (TWAI) controller. At the time we blamed the chip. In fact we were not routing the pins to the controller correctly. One Waveshare ESP32-P4 board was destroyed during this period, when an open 5 V wire touched it on the workbench. In the end both buses moved to dedicated Waveshare ESP32-S3-ETH boards.

7 · Checklist

If you build a dual CAN listener for an Iveco Daily

  1. Check the logic voltage first. Some transceivers and shields run at 5 V, the ESP32 at 3.3 V. A 5 V signal on an ESP32 pin can destroy it. We lost a Waveshare ESP32-P4 board to an open 5 V wire on the workbench.
  2. Know which CAN you have: classic high-speed, CAN FD (Flexible Data-rate, changes speed within each message) or CAN FT (fault-tolerant). They need different parts. FD and FT differ by one letter and are completely different systems.
  3. Check the speed ceiling. Many CAN chips have a maximum bit rate and support only one kind of CAN. Choose them after you know the bus.
  4. Never share transceivers between the buses. C-CAN needs a high-speed transceiver (TJA1051 class), B-CAN a fault-tolerant one (TJA1055 class). Different supply, different resting levels, different termination.
  5. Always start in listen-only mode, and stay there. Log traffic for weeks before you even think about acknowledging or sending.
  6. Make listen-only true in hardware. Tie the TJA1051 S pin high for a C-CAN monitor. On the B-CAN side, hold the TJA1055 TXD input high (recessive) with a pull-up, so a floating or low pin at start-up cannot drive the bus.
  7. Measure before you connect. A healthy idle C-CAN shows about 2.6 V / 2.4 V (0.2 V difference). If you see about 2.9 V / 2.1 V (0.8 V difference), something is driving dominant.
  8. Find the bit rate first. A wrong bit rate looks exactly like a wiring fault. Measure one bit on the scope.
  9. Check the board's pin map, not the chip's. Avoid pins used by the SD card, Ethernet, USB, LEDs and the chip's strapping pins (on the ESP32-S3: GPIO0, 3, 45 and 46).
  10. Hold the transmit pin high from the first moment of start-up, before the CAN driver takes it over.
  11. Scope the processor's RX pin. If the high level is below about 2.5 V, the processor will not read it. Adjust the pull-up and measure again.
  12. Use multi-pin connectors. Single jumper wires stretch, fall off, and some only make contact one way round. Every one of these faults looks like a software problem.
  13. Check the polarity of RXD. It must rest high when the bus is idle. If it rests low, the signal is inverted.
Closing note

The physical layer is the hard part

B-CAN is now working reliably after a long and frustrating debug. The start-up fault on the C-CAN, and the inversion and logic-level faults on the B-CAN, all made the problem look like software when it was actually analogue. If you are building for the Iveco Daily 4x4, plan plenty of time for the physical layer. Decoding the messages is the easy part, once you can reliably see the bits.

← Back to Part 4 · Back to the Technical page