networks//network protocols//CAN

CAN (Controller Area Network) is a shared serial bus on which intelligent nodes exchange messages identified by a CAN ID, designed to connect the electronic controllers of a vehicle. Intelligence is already distributed in the nodes, and there is no master reading everyone.


CAN (Controller Area Network) is a shared serial bus on which intelligent nodes exchange messages identified by a CAN ID, designed to connect the electronic controllers of a vehicle. Intelligence is already distributed in the nodes, and there is no master reading everyone.

A node publishes a frame with an identifier that names the message (engine speed, brake pressure), not the device that sent it; every node on the bus sees it and the interested ones read it. Conceptually close to publish-subscribe, although CAN is not MQTT: there is no broker, the bus itself is the medium, and the identifier doubles as the priority.

Physically it is a differential pair, CAN High and CAN Low, with a 120 ohm terminator at each end, robust against noise. Classic CAN runs up to 1 Mbit/s over some tens of metres; CAN FD keeps the same arbitration and switches to several Mbit/s for the data part of the frame. J1939 is the higher-level protocol used on top of it in heavy vehicles and machinery, and DroneCAN carries the GNSS modules, compasses and motor controllers of many drones.

Collisions are resolved by arbitration on the identifier bits, and nobody loses the message. When two nodes start together, each listens while it sends; a 0 overrides a 1 on the wire, so the node sending a 1 that reads back a 0 stops and retries later, and the frame with the lowest identifier goes through intact. A critical message given a low identifier therefore has a bounded wait, which is the property a control system buys CAN for (determinism). The bound holds only for the high-priority frames, and only while the bus load stays reasonable: a low-priority message can be starved for as long as the important ones keep coming.

Against a request-response fieldbus: in Modbus a PLC reads devices one by one; in CAN multiple controllers share messages on the bus. CAN is the natural fit for distributed systems with many peer nodes (Modbus). For one master moving dozens of servo axes in lockstep, EtherCAT is the tool.

The bus authenticates nobody: any node that is connected can send any identifier, so the security of a CAN system starts with who can reach the wire.