Notes on CAN bus, so you think you knew everything.
Controller Area Network (CAN) is a network protocol developed by Bosch for vehicle systems, but which is coming into use for linking distributed controllers, sensors etc in other fields.
CAN is a CSMA/CD protocol (some sources have CSMA/CR for similar protocols) that uses non-return to zero coding with bit stuffing. It supports speeds of up to 1Mb/s so is an SAE class C protocol, suitable for real time control applications.
Messages are not addressed to intended recipients, but the sender’s identifier is included, and this tells the receivers what data it contains so the receiver ignores it if it is not interested. Messages are given a priority according to the sender’s address, so the priority of messages is decided at the design stage.
Binary zero is represented by a “dominant” state in the bus and binary one by a recessive state, so a binary zero takes precedence over a one, so lower numbered identifiers have priority over higher numbered ones.
The standard identifier format allows for 2032 nodes on the network (2 to 11 =- 2 to 7) and the extended identifier allows more, but as the extra 18 identifier bits are needed for compatibility with other protocols, their use is restricted.
A 2.0A compliant device will flag an error if presented with a 2.0B message, unless it is “2.0B passive”, when it will tolerate, but ignore, messages in 2.0B format. 2.0B devices are backward compatible, and can transmit and receive messages in either format. The RTR field (set to 1 if the message is a request for information) follows the identifier. As such a “remote request” frame uses the identifier of the source of the required data, this means that data takes precedence over a request for that data, but a request for high priority data takes precedence over lower priority data. These remote request frames are apparently rarely used. The identifier field and RTR field are used in collision resolution.
The data field can contain from zero to eight bytes, its length being stated by a 4 bit DLC field that immediately precedes the data field.
The data field is followed by a 15 bit cyclic redundancy check, a delimiter, acknowledgement field and end of frame and intermission fields. After these and a set idle time (which may be zero) another node can start transmission.