Professional Documents
Culture Documents
CAN is documented as an International standard as ISO11898 for high speed applications and
ISO11519 for low speed applications. To discuss the growth of CAN several user groups have been
formed. One of the first is CAN in Automation (CiA). Now in its 20th year CAN is still enhanced. In the
future CAN would be used in every type of embedded systems and machines.
OSI Model
The Open System Interconnection Model is a reference to how messages are transferred in a
network. All the communication protocols including CAN follows this standard.
DOI:10.21884/IJMTER.2017.4352.C180W 109
International Journal of Modern Trends in Engineering and Research (IJMTER)
Volume 04, Issue 11, [November– 2017] ISSN (Online):2349–9745; ISSN (Print):2393-8161
trying to send the message through the network. The seven layers in the OSI model is shown in the
following figure.
1. Bus Arbitration
CAN use “Carrier-Sense Multiple Access with Collision Avoidance“ (CSMA/CA) for the bus
access. Every node in the network can access the bus when the bus is free for 3 bit period. In case of
collision, the message with a higher priority wins the bus access and transmits. If more than one node
tries to send data through the bus, then the bus access is decided by a bitwise arbitration. The nodes
which needs to send the message transmits the message bits at the same time. The node which sends a
dominant (0) bit will gain the access on the bus there on. The other node which sends a recessive (1) bit
changes its state to a receiver and starts to receive the message frame which is on the bus. The
transmission of lower priority message is stalled and transmitted again automatically when the bus is
free.
The message contains 0-8 bytes of date which is specified as Data Length Code (DLC) in the
Control Bits of the message frame. For the error detection a 15 bit checksum is transmitted along with
the message.
2. Bit Stuffing
The receiving node synchronises itself with every start bit of the message. CAN uses a technique
called Bit stuffing to have the proper communication of the messages. After every consecutive bit levels,
the transmitter will automatically stuff a bit of opposite polarity in to the bit stream. The receiver of the
message will automatically destuff (delete) this stuff bit. So if any receiving node detects six consecutive
bits of the same level, then a stuff error is flagged. Theoretically for every 5 bits a stuff bit is sent by the
sender. On an average every message has 3 to 4 stuff bits.
Figure.3. Bit Stuffing(CAN-Frame before and after the addition of stuff bits (in purple))
The CAN controller of every receiving node checks the message format and also the checksum.
It sends an acknowledgement or Error frame within the Acknowledge and EOF (End of Frame) fields in
the frame. In case of an error frame, the received message is ignored by all the nodes in the network.
The sender will automatically try to send the message later on the bus.
3. Bit timing
The nominal bit timing is the time needed to transmit a bit across the network. All the nodes in
the network should have the same bit rate. That is why the synchronisation is being done in several
ways.
Maximum transmission time for a message with 8 data bytes and of higher priority is 225 micro
seconds. And with 29 bit identifier is 260 micro seconds. Therefore the maximum data rate is 35KB/sec
for 11 bit identifier and 30KB/sec for 29 bit identifier.
Figure 4. An example CAN bit timing with 10 time quanta per bit
IV. CAN IMPLEMENTATIONS
In CAN there are two main Hardware Implementations, they are Basic CAN and Full CAN.
1. Basic CAN
Basic CAN has only one Message buffer for Receive and Transmit messages. The received
message is accepted or ignored after acceptance filtering. The decision to process a message or to
ignore it is also achieved by acceptance filtering. This acceptance filtering of the node is done by
software in Basic CAN. To reduce the software load at the nodes, there is a possibility to ignore some
messages by ignoring specific identifiers. This is realized by bit mask for the message identifiers.
2. Full CAN
In Full CAN, there are 8 to 16 memory buffers for every transmitted or received message. Here
the acceptance filtering is done by hardware and not by the
software. Every buffer can be configured to accept messages with specific ID’s.
Since the acceptance filtering is done by hardware, the software load is greatly reduced.
Different messages ensures more time for the processing of the received messages and the
transmitted message can be handled according to the priority levels. Configuring each buffer for every
message ensures also the data consistency in Full CAN.
3. Message Frame Formats
CAN systems have four different types of frame formats
1. Data Frame
2. Error Frame
3. Remote Frame
4. Over load Frame.
detection and the Acknowledgement field. The arbitration field contains the Message Identifier which is
used to determine the priority of the message when two nodes compete to gain access of the bus. The
arbitration field contains 11 bit Identifier for CAN 2.0A with RTR bit and 29 bit Identifier for CAN
2.0B with RTR bit.
The RTR (Remote Transmission Request) bit is dominant for data frames. Next is the data field
which holds 0 to 8 bytes of data and 16 bit CRC for error detection. Finally the ACK field, which is
transmitted as recessive, is overwritten with a dominant bit by a receiver when acknowledged.
The transmitter checks the ACK field to be dominant and transmits the message again on the bus
if it is not.
The following are the fields in the CAN frame format. The format is as shown in figure.
error on the frame then it ignores the frame and leaves this bit recessive. In this way data reliability is
guaranteed by each node. ACK field consists of 2 bit acknowledgement field and 1 bit delimiter.
4.1.3. EOF: The End of frame field indicates the end of the CAN message. It is 7 Bits long and should
be recessive to indicate the complete transmission of a error free message. If any of the ACK delimiter
or EOF bits were transmitted dominantly then it indicates the start of an Error frame.
4.2. Remote Frame
Remote frame is determined by the Remote Transmission Request (RTR) bit in the Arbitration
field. If this bit is dominant then it means that this frame is a Data frame. If this RTR bit is recessive
then it is a request for data. In this way, during an arbitration process a data frame dominates over a
remote frame with a same Identifier. This frame will not have any data. These frames are sent out in a
regular basis to update the values from the sensors in the system.
4.3. Error Frame
The receiver sends the Error frame when it detects an error in the receiving frame. By doing so it
makes all the nodes in the network to ignore the message which is currently on the bus. This frame can
be sent out at any time but before the completion of Data or Remote frame. The transmitter constantly
monitors the bus while transmitting and stops its transmission when it detects an error frame. After
detecting the error frame, the transmitting node tries to send the message again when the bus is idle for
the next time.
4.4. Over load Frame
This is equivalent to a data frame which is sent by a busy node.
i.)Error confinements
CAN controllers of each node in the network have error counters for transmit and receive
messages respectively. Every error message will increment this counter value. Transmission errors have
a weighting of 8 and increment the Transmit Error counter whereas the Receive Errors have a weighting
of 1and increment the Receive Error counter. For every successful transmission or reception of
messages the counter values are decrement by one. Depending upon these counter values, each node can
be in one of the following states.
ii) Error Active mode
In this mode the node is working normally. It can take part in communication and send error
flags when it detects an error frame, thereby destroying the transmitted frame. In this state the counts of
both the error counter would be less than 127. When the error count reaches zero, these node will return
to normal mode form error active mode.
iii) Error Passive mode
When the Error Counters exceed 127, then the node transforms itself from Error active to Error
Passive mode. The Node is still capable of sending and receiving messages. This node is not allowed to
send any error frames with active error flags, instead it is allowed to send out error frames with passive
error flags.After an Error frame, this node has to wait for certain bit times to start its retransmission. By
these tedious procedures the Nodes with higher error counts are limited by the bus to avoid their
interference in the communication. Obviously the node becomes error active again at the point where its
error count falls below 127.
4.5 Buss off state
If an Error counter of a node reaches 255, then the node gets isolated from the bus by
transforming itself from error passive to buss off state. In bus off mode the node can only receive and
cannot transmit. Because only the transmit errors have caused the node to be off the bus. When the error
counts reach 128 or below then the node come back to error passive node and take part in
communication again. Otherwise by resetting the error counters and the CAN controller, they can take
part in communication after 128 occurrences of 11 consecutive bits.
The following figure may help to understand the error states more clearly.
panels, controllers, doors, and light barriers, to each other and control them. CANopen also is used in
nonindustrial applications such as laboratory equipment, sports cameras, telescopes, automatic doors,
and even coffee machines
VII. CAN PHYSICAL LAYERS
1. High-Speed/FD CAN
2. Low-Speed/Fault-Tolerant Hardware
3. Single-Wire CAN Hardware
4. Software-Selectable CAN Hardware
VIII. NATIONAL INSTRUMENTS CAN TOOLS
1. NI-XNET Software Driver
i.) NI-XNET: One API, Many Embedded Networks
ii.)Top Performance with Less Programming
2. NI-CAN Software Driver