CAN Bus — Controller Area Network
CAN (Controller Area Network) was developed by Bosch in 1986 for automotive wiring. Before CAN, every sensor in a car needed its own dedicated wire back to a central ECU. A modern car has hundreds of sensors — that wiring harness would be enormous, heavy, and expensive. CAN replaced point-to-point wiring with a two-wire differential bus where every module talks to every other module.
Today CAN is found in every modern vehicle, industrial machines, medical equipment, agricultural machinery, and aerospace systems.
The Core Idea — Message-Based, Not Address-Based
CAN does not work like I²C or Modbus, where you address a specific device. CAN is message-based:
- Every node on the bus broadcasts a message with an identifier (ID)
- Every other node receives every message and decides whether it is relevant
- There are no device addresses — only message IDs
This publish-subscribe model means adding a new module to the bus requires no wiring changes to existing nodes — it just starts listening for the messages it needs.
Differential Signaling — Like RS-485, But Faster and Smarter
CAN uses a differential pair: CAN-H (High) and CAN-L (Low). The receiver measures the difference between them, giving excellent noise rejection.
| State | CAN-H voltage | CAN-L voltage | Difference |
|---|---|---|---|
| Recessive (logic 1) | ~2.5 V | ~2.5 V | ~0 V |
| Dominant (logic 0) | ~3.5 V | ~1.5 V | ~2 V |
The "dominant" state (logic 0) always wins over "recessive" (logic 1) — this is the foundation of CAN's arbitration mechanism.
120 Ω termination resistors at both ends — same daisy-chain topology as RS-485.
The CAN Frame
Every CAN message follows this frame structure (Standard 11-bit ID frame):
┌───────┬────────────┬─────┬───┬──────────────────┬─────┬──────┐
│ SOF │ ID │ RTR │IDE│ Data │ CRC │ ACK │
│ 1 bit │ 11 bits │1 bit│1b │ 0–8 bytes │15+1 │ 2 bit│
└───────┴────────────┴─────┴───┴──────────────────┴─────┴──────┘
| Field | Size | Purpose |
|---|---|---|
| SOF | 1 bit | Start of Frame — dominant bit signals a message starting |
| ID | 11 bits (standard) or 29 bits (extended) | Message identifier — also sets message priority |
| RTR | 1 bit | Remote Transmission Request — ask another node to send |
| DLC | 4 bits | Data Length Code — how many data bytes follow (0–8) |
| Data | 0–8 bytes | The payload (CAN classic max is 8 bytes) |
| CRC | 15 bits | Cyclic Redundancy Check for error detection |
| ACK | 2 bits | Any node that receives the frame correctly pulls this dominant |
The ID is the priority — lower ID number = higher priority. If two nodes transmit simultaneously, the one with the lower ID wins without any collision (non-destructive arbitration).
Non-Destructive Arbitration — CAN's Superpower
This is the most important concept in CAN. When two nodes transmit at the same time:
No message is lost, no collision destroys either frame. The higher-priority message gets through first, the lower-priority message retries. This is called CSMA/CD with non-destructive arbitration.
CAN Speeds
| Speed | Max Cable Length | Typical Use |
|---|---|---|
| 1 Mbps | ~40 m | Automotive, industrial |
| 500 kbps | ~100 m | Most automotive CANbus |
| 250 kbps | ~250 m | Agricultural machinery (J1939) |
| 125 kbps | ~500 m | Building automation |
| 10 kbps | ~5 km | Long-distance industrial |
Lower speed = longer cable. The timing must allow the signal to propagate to the farthest node and back within one bit period.
CAN FD — Faster Data
CAN FD (Flexible Data Rate, 2012) extends classic CAN:
- Up to 8 Mbps data rate (but only in the data phase — arbitration still at ≤1 Mbps)
- Up to 64 bytes per frame (vs 8 bytes in classic CAN)
- Same physical layer (CAN-H / CAN-L, same transceivers mostly)
CAN FD is now standard in automotive ECUs and modern industrial controllers.
Error Detection — CAN Is Self-Healing
CAN has five built-in error detection mechanisms:
| Mechanism | What it catches |
|---|---|
| CRC check | Corrupted bits in data or header |
| Bit monitoring | Node reads back what it sent — mismatch = error |
| Bit stuffing | After 5 same bits in a row, a different bit is inserted. Violation = error |
| Frame check | Fixed-format fields must match expected values |
| ACK check | If no node acknowledges, the transmitter knows nobody heard |
When errors are detected, the node sends an Error Frame which destroys the current message and signals all nodes to discard it. The transmitter retries. A node that repeatedly causes errors is automatically put into Bus-Off state (it stops transmitting) to prevent one faulty node from crashing the entire network.
CAN vs RS-485 (Modbus)
| CAN | RS-485 (with Modbus) | |
|---|---|---|
| Topology | Multi-master, any node can transmit | Single master, slaves only respond |
| Addressing | Message ID (content-based) | Device address (node-based) |
| Arbitration | Non-destructive, automatic | None — only one master, no collision possible |
| Max payload | 8 bytes (classic), 64 bytes (FD) | 252 bytes |
| Error handling | Built into hardware | CRC only, software handles retries |
| Speed | 1 Mbps (classic), 8 Mbps (FD) | Up to ~1 Mbps (practical) |
| Common use | Automotive, machines, robotics | Industrial sensors, meters, drives |
Higher-Level Protocols on CAN
CAN is a hardware protocol — like RS-485, it defines the physical and data-link layer only. The application meaning of the data is defined by software protocols on top:
| Software Protocol | CAN Layer Used | Domain |
|---|---|---|
| SAE J1939 | CAN 2.0B (29-bit ID) | Heavy vehicles, trucks, construction |
| CANopen | CAN 2.0A/B | Industrial automation |
| DeviceNet | CAN | Factory automation (Rockwell) |
| ISOBUS (ISO 11783) | CAN | Agricultural machinery |
| OBD-II / ISO 15765 | CAN | On-board vehicle diagnostics |
Every modern OBD-II port you plug a diagnostic scanner into is CAN.
CAN Transceiver — The Physical Interface
The MCU's CAN peripheral outputs single-ended TXD/RXD signals at 3.3 V or 5 V logic. A CAN transceiver (e.g., MCP2551, TJA1050, SN65HVD230) converts these to the differential CAN-H / CAN-L bus signals.
Key Takeaway
CAN is a multi-master, message-broadcast, differential bus designed to survive the electrical environment inside a car or machine. Its non-destructive arbitration, built-in error detection, and bus-off protection make it far more robust than RS-485 for environments where many independent nodes need to communicate simultaneously without a designated master.
It defines the physical and data-link layer only — the meaning of those 8 bytes is defined by higher-level protocols like J1939, CANopen, or OBD-II on top.