The CAN Bus in More Detail

10 May

The CAN Bus in More Detail: As mentioned already, CAN messages contain a message identifier to indicate the contents of the message rather than using device addresses. This makes the CAN bus a multimaster bus, that uses multicast communication. As a multimaster bus, any device can determine that the bus is available for transmission of a message. If several devices start transmitting at the same time, then the message priority is used to determine which device gets to complete transmission. CAN is also a multicast form of communication because the messages are transmitted on the bus to all devices. Any device on the bus may determine that the message it received is of interest and act on that message. The benefit of being both multimaster and multicast is that new devices can be added to the bus without reconfiguring any of the existing devices. The diagram below shows multiple devices using a common CAN bus to send messages. Only the devices that are interested in the data they receive (determined by the message identifier) need to actually process and act on the message.

Now let’s examine some of the details on how the CAN bus is implemented.

Bus states
The CAN bus has two states, one representing a logical 1, called the recessive state, and the other representing a logical 0, called the dominant state. When the bus is idle (no message traffic) the bus is in the recessive state. A device communicating on the bus will pull the bus to the dominant state.

Dominant = Logic 0
Recessive = Logic 1

Figure 12-3: CAN bus messages
CAN controllers are connected to the CAN bus through a transceiver. The Bosch CAN specification does not specify a bus media but common implementations include twisted-pair and optical media. The diagram below shows a typical connection to a twisted-pair cable. In this case the CAN controller is our TINI microcontroller and the CAN transceiver is the Philips PCA82C250 (or compatible). The CAN transceiver puts the data on the twisted pair using differential voltage (balanced line) signaling for noise immunity.

Figure 12-4: CAN bus signaling
Like I2C devices, CAN devices are connected to the CAN bus in a wired-AND configuration. This means that it is possible for multiple devices to change the bus state to a dominant state without adverse effects. Exactly which device and how to handle multiple devices acting as masters will be discussed in the section on arbitration. In the case of twisted-pair bus wiring, the transceiver converts the microcontroller CAN-transmit and CAN-receive signals into differential voltages. A typical CAN transceiver for twisted pair will hold the CAN_L (CAN Low) and CAN_H (CAN High) lines at 2.5 volts in the recessive state. To signal a dominant state on the CAN bus, the transceiver will pull CAN_H to 3.5 volts and CAN_L to 1.5 volts (note that CAN_H is higher than CAN_L, hence the names high and low) as shown in the following diagram.

Figure 12-5: Differential signaling
The receiving transceiver will invert CAN_L and add that to the CAN_H signal to recover the CAN signal. In doing this, any noise induced on the line will be cancelled out.

Message coding
CAN bus signals are encoded on twisted-pair wiring using non-return-to-zero (NRZ) bit encoding. NRZ encoding is a two-level signaling mechanism used to transmit data. Using NRZ encoding, one bit of data is transmitted per clock cycle. The significance of NRZ is more easily seen when compared to return-to-zero (RZ) encoding. With RZ encoding, the signal returns to the low state after each bit is transmitted. With NRZ encoding it does not. If two or more high value bits are transmitted, the voltage stays at the level.

Figure 12-6: NRZ bit encoding

Random Posts

Comments are closed.