Presentation is loading. Please wait.

Presentation is loading. Please wait.

An Introduction to CAN CAN Basics 2 Renesas Interactive

Similar presentations

Presentation on theme: "An Introduction to CAN CAN Basics 2 Renesas Interactive"— Presentation transcript:

1 An Introduction to CAN CAN Basics 2 Renesas Interactive
Welcome back…

2 Key reasons to use CAN Scalability More and more chips
Low wiring cost Low node connection costs More and more chips More off the shelf tools Knowledge base growing Reliability (error free) Before we continue our studies, let’s repeat some reasons why CAN is growing in applicability and popularity: Since the bus is a simple “twisted pair” wire, connectivity is easy. A new node is added to the bus simply by tapping into it. As a new node has few connection points, reliability increases compared to multiple wire systems. More and more CAN chips and tools are becoming available to developers and as it has now been around for over 15 years, the knowledge base for CAN is now considerable. CAN provides a simple reliable serial data interface. A network may consist of many nodes, or individual MCUs, spread out over several hundreds of meters with virtually 0% failure since the CAN MCUs have built in error detection and retry. Thus, CAN provides very reliable error free network. This is sometimes a very big key requirement for some safety critical equipment and real time system The bus is not controlled by a master, so all nodes may send a data message, but the one with the lowest Numeric id (highest priority) in the message header wins if two nodes try to transmit at the same time.

3 CAN Message Frames Data Frame - Carries the actual data
Error Frame - When error is detected by any node’s hardware Overload Frame - Request a delay on the bus Interframe Space - Provides minimum spacing between data and remote frames Allows error frames priority Remote Frame - Request transmission of Data Frame. Now lets take a closer look at the data traffic that travels the CAN bus. The Data Frame is the most common frame and carries the actual payload data from transmitters to receivers. An Error Frame is transmitted when an error is detected. A receiving node can intentionally “corrupt” a data frame which will cause retransmission. Nodes will thereby not ACK the message and at CRC-checksum error will be detected by other nodes. An Overload Frame is a request for delay or a pause on the bus. The Inter frame Space provides minimum spacing between data and remote frames. Allows error frames to have priority. The Remote Frame requests transmission of Data Frames. This frame type is not used in a majority of applications.

4 Data Flow Before we study the data frame let us repeat one picture from the previous lesson. Study this one carefully as it is contains the ‘big picture’. A data frame is broadcast to the bus, but only nodes with a message box configured to receive that ID register the data. Now let’s look at that Data Frame.

5 Data Frame Start of Frame Arbitration Field
Control Field Data Field CRC ACK Field End of Frame The Data Frame consists of the following ‘fields’: - Start of Frame - Arbitration Field, this is where the identifier is placed. The upper frame is a data frame with a standard 11-bit id and the lower data frame has the less common extended 29-bit id length (for CAN2.0B spec) - Control Field containing the Data length Code, DLC, the number of bytes In the Data Field - Data Field, contains the payload - CRC - ACK Field - End of Frame Let’s have a look at each field separately.

6 All nodes synchronize to edge
Start of Frame A single dominant bit while the bus is idle All nodes synchronize timing to leading edge All nodes synchronize to edge CAN has a multi-master capability, meaning any node on the bus can initiate communication to any node configured to receive. This is done with a Start of Frame. A single dominant bit while the bus is idle indicates a transmitting node is starting a frame. All nodes on the bus will synchronize their bit timing to the leading edge of SOF.

7 Arbitration Field Standard; 11-bit identifier Extended; 29-bits
ID, or identifier of CAN 2.0B, may be 11 or 29 bits long This is determined by FW at initialization by setting the ID-extension bit (and then configuring each can mailbox with a long ID instead of a standard). Extended ID is less common but you need extended ID in case you have more than 2032 IDs to differentiate. CAN has a multi-master capability meaning any node on the bus can initiate communication to any other node. This is where the Arbitration Field comes in... Note that because of backward compatibility to CAN 2.0A which just has 11 bit long only, the extended ID is split into two pieces; a high order 11 bit field, and a low order 18 bit field. Because the ID extend bit is recessive in the extended format, that the standard ID has a higher priority than the extended ID for the same leading 11 bit identifier.

8 Arbitration Handling collisions Carrier Sense Multiple Access/Collision Resolution = CSMA/CR By using Dominant and Recessive Bits To allow multiple devices to initiate communication, the arbitration protocol determines which device will receive priority and access to the bus. This is called Carrier Sense Multiple Access/Collision Resolution (CSMA/CR). When two nodes negotiate for the bus at the same time, a dominant bit state will override a recessive bit state. When a node transmits a recessive state on the bus, but detects a dominant state on its receiver, it knows that higher priority message is being transmitted and immediately ceases transmission. The losing node will renegotiate for the bus as each new opportunity comes until the message is transmitted.

9 Control Field Control Field contains the DLC 2 bits reserved
4 bits Data Length Code; number of Data Field bytes Number of Data Bytes Data Length Code DLC3 DLC2 DLC1 DLC0 1 2 3 4 5 6 7 8 The Control Field consists of six bits - 2 are reserved - 4 are the Data Length Code which indicates number of data bytes in the data field [0-8 bytes being valid sizes] - DLC codes not shown in the figure are reserved

10 Data Field Data content = payload of the frame 0-8 bytes
MSB transmitted first This field carries the actual payload of the can-bus communication. It may be 0 to 8 bytes long, as defined by the Data Length Code in the Control Field. The most significant bit is transmitted first within each byte.

11 CRC Field 15 bit CRC value followed by a recessive delimiter
Generated by transmitter node’s HW and verified in receiver’s HW CRC polynomial: x15+x14+x10+x8+x7+x4+x3+1 The CRC Field is sent by the transmitter and verified by all receivers. Each receiver generates a CRC on the observed data frame and compares it with the transmitted CRC check value. If it is they match, a dominant bit is put into the ACK slot. If the result is a mismatch, nothing is transmitted by that node; instead, a ‘no’ vote is sent AFTER the upcoming ACK delimiter, that is at End of Frame.

All receivers that received valid message reports with a ’dominant’ bit during the ACK slot Any receiver that disagrees votes no after the delimiter with an error flag The ACK FIELD is two bits long and contains the ACK slot and the ACK delimiter. In the ACK slot the transmitting station sends two recessive bits. Every receiver which has received a valid message correctly, reports this to the transmitting node with a ’dominant’ bit during the ACK slot. Any node that disagrees, votes no after the delimiter by sending an error flag.

13 End of Frame DATA FRAME and REMOTE FRAME delimited by ‘End of Frame’ consisting of seven recessive’ bits. Gives a break before the next frame.. This is the last of the fields of the data frame. The End of Frame field provides the necessary portion of idle between messages, for example for the transmitter to detect if a node decided to send an error frame, which is allowed anytime. The End of Frame field consists of seven recessive bits.

14 Error detection Locally detected errors
When is an error frame sent? Bit error -receive bit at sender not equal to transmit bit. Bit stuffing violation -max 5 bits with same polarity CRC error -checksum violation Form error -bit pulse malshaped Ack error -no dominant level in ACK slot so sender must retransmit A key concept in reliability is to have all messages confirmed or acknowledged. All nodes on the bus verify the integrity of the frame. If a node sees valid data on the bus for a data frame, it will drive a dominant bit during the acknowledge slot of the frame. If a node sees invalid data on the bus, it can drive dominant bits onto the bus to ensure that no other node recognizes the frame as valid. Remember, the error frame can be sent at any time and consists of 6 dominant bits. (Don’t we need to explain more in detailed about the error frame?) Depending on rules, nodes participate in frame verification if they are ‘error active’. If not they have become ‘error passive’ or entered ‘bus off’ states. Because every node acknowledges, the round trip propagation delay is the primary distance limitation of CAN.

15 What is needed? Firmware CAN controller CAN transceivers
A physical media To implement a CAN solution one needs application firmware, a CAN controller, CAN transceivers to drive the bus signal and of course the bus line. Many Renesas MCUs have a CAN controller integrated in the MCU.

16 Example of Renesas CAN MCUs
SH705x series Automotive Powertrain SH7047 series General purpose SH2…soon updated derivative available. M32R/ECU series M32C series General purpose (1-3 channels of CAN) M16C/6N series M16C/62 family with CAN. General purpose. M16C/29 series General Purpose M16C/Tiny with CAN. M16C/10 series Better off with M16C/Tiny or R8C/Tiny R8C/Tiny series General Purpose (Please remove SH, M32RE and M16C10 from this presentation. I do not think those are appropriate for general promotion. Therefore, we may need to change the title so that it does not give the impression to the audience that Renesas CAN MCU offerings are just limited to M16C family.) Finally here are the existing Renesas MCUs containing an integrated CAN controller. Within each MCU series listed here there are many variants to suit your company’s needs. You have completed CAN Basics Interactive #2. Thank you for showing interest in Renesas CAN!

17 Question 1 Which is normally by far the most common frame type?
Data Frame Error Frame Overload Frame Remote Frame A: 1 B: 2 C: 3 D: 4

18 Question 2 Which of these statements is false?
The data field in a data frame can consist of max 255 bytes The data field has only 8 bytes You must specify for each data frame how many data bytes follow Remote frames are not necessary to use CAN A: 1 B: 2 C: 3 D: 4

19 Question 3 Which of these is false?
The CRC field is sent by all receivers and verified by the transmitter. Each receiver generates a CRC on the observed data frame and compares it with the transmitted CRC check value. Every receiver which has received a valid message correctly, reports this to the transmitting node with a ’dominant’ bit during the ACK slot. Any node that disagrees, votes no after the delimiter by sending an error flag. A: 1 B: 2 C: 3

20 Question 4 When is an error frame sent?
Bit stuffing violation; > 5 bits with same polarity CRC error; checksum violation Form error; bit pulse malshaped Ack error; no dominant level in ACK slot so sender must retransmit A: 1-3 B: 2-4 C: 2 and 4 D: All above

21 Glossary Finally, here are some CAN ‘buzzwords’.
Advanced CAN: CAN peripheral with varying numbers of buffers configurable for transmit/receive. Receive buffers have hardware filtering on at least mask/match identifier content. Basic CAN: CAN peripheral with no hardware filtering. Typically two receive buffers act as FIFO accepting all bus traffic. Usually one transmit buffer. Bit Time: Nominal time of one bit on the CAN bus. Made up of multiple segments that allows each node to synchronize to the received bus traffic. All nodes on a bus must be configured to the same (nominal) bit time. CAN: Controller Area Network CAN 2.0B: Version 2.0 was the last version of CAN defined by Bosch. Part B added extended identifiers and the idea of hardware filtering. CIA: CAN in Automation. Group controlling the CANOpen protocol. CANOpen: Multi-area communication protocol using CAN. CRC: Cyclic Redundancy Check DeviceNet: Industrial communication protocol using CAN. Dominant/Recessive: Dominant bits on physical layer can override recessive bits. Filters: Hardware in the CAN peripheral that can mask/match bits within the identifier field used to determine whether or not route bus data to a mailbox. GM LAN 3.0: GM protocol, encompasses all GM serial protocols. Identifier: Frame field that indicates the message content. This field also is used to arbitrate the message priority on the bus; lower identifier is higher priority. Standard Format; frames use 11 bit identifier. Extended Format “ bits ISO 11898: ISO standardized version of CAN. Mailbox: CAN hardware buffer that can be used to transmit or receive data. Most full CAN implementations have at least 16 mailboxes. ODVA: Open DeviceNet Vendor Association. Group controlling DeviceNet protocol. Time Quanta: Smallest time unit used by CAN. Multiple time quanta make up the segments of a bit time. TT CAN: Time Triggered CAN. More deterministic CAN by assigning time slots when nodes may transmit. FlexRay: Next generation automotive network. Time slots on the bus provide more deterministic behavior. Vector-CanTech: Supplier of the majority of CAN software drivers and tools to North American and European automobile ECUs. Finally, here are some CAN ‘buzzwords’.

22 Come back for more! End CAN Basics 2
You have now completed Renesas CAN Basics part #2. Please come back to do Renesas CAN Basics part #3. In part 3 we will look at how to use the Renesas CAN MCU peripheral and how to use it. End CAN Basics 2

Download ppt "An Introduction to CAN CAN Basics 2 Renesas Interactive"

Similar presentations

Ads by Google