CAN Basic Traininig

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 56

CAN Training

16.05.2008

Continental AG

Training content
1. WHY we need CAN
2. WHAT is CAN
3. HOW does CAN work! (protocol explained)
4. PROGRAM presentations(CAN tools)
5. PRACTICE session (CAN in real life)

WHY we need CAN


CAN is needed for
Information exchange

Information exchange

Information exchange

Information

Information exchange

exchange

Information exchange

Information exchange

Information exchange

Information exchange

Information exchange

Information exchange

Information exchange

Information exchange

Information exchange
Information exchange

Information exchange
Information exchange
Information exchange

WHAT is CAN

CAN is Low Cost


- Protocol devices are low-cost
- Good price/performance ratio
- Low cost twisted wire pair

WHAT is CAN

CAN is Reliable
- Sophisticated error detection and error handling
- High immunity against electromagnetic interference
- Automatic retransmission of erroneous messages
- Recovery of temporary errors
- Automatic switch-off of defective nodes
- Guaranteed data consistency

A CAN network running 2000 hours per year at a CAN bus speed of 500 kbit/s with 25% bus load statistically will result in 1 undetected error every 1000 years .

WHAT is CAN

CAN is Real-Time.
- High baud rate
- Short message length
- Low latency
- Multi-master
- Arbitration

WHAT is CAN

CAN is Fast
- 8-Byte limit on messages
- Bus access prioritized
- 1 Mbps baud rate

WHAT is CAN

CAN is Flexible
- Number of nodes not limited by protocol (only by physical layer)
- Changes possible without disturbing communications

HOW does CAN work!

CAN (HOW IT LOOKS LIKE)

HOW does CAN work!


CAN (HOW IT LOOKS LIKE)

HOW does CAN work!

CAN physical Layer


www.techonline.com
dominant/recessive bits

HOW does CAN work!

CAN start of frame

A Data Frame is generated by a CAN node when a node wishes to transmit data. Here, we
see an example of a Standard CAN Data Frame. The frame begins with a dominant Start Of
Frame bit for hard synchronization of all nodes

HOW does CAN work!

CAN frame Arbitration Field

The Start of Frame bit is followed by the Arbitration Field, consisting of 12 bits, which includes
the 11-bit Identifier that reflects the contents and priority of the message, and the Remote
Transmission Request bit. The Remote Transmission Request bit is used to distinguish a Data
Frame, when RTR is dominant, from a Remote Frame, when RTR is recessive.

HOW does CAN work!

CAN frame - Control Field

The next field is the Control Field, consisting of 6 bits. The first bit of this field is called the Identifier
Extension, or IDE bit. When this bit is in a dominant state it specifies that the frame is a Standard Frame.
The bit following the IDE bit is reserved and is defined as a dominant bit. The remaining 4 bits of the
Control Field represent the Data Length Code, or DLC, which specifies the number of bytes of data
contained in the message, that is, 0 to 8 bytes.

HOW does CAN work!

CAN frame Data Field

The data being sent follows in the Data Field which, as weve seen, is of the length defined by the DLC.
The Data Field can contain anywhere from 0 to 8 bytes, or 0 to 64 bits.

HOW does CAN work!

CAN Frame - CRC

Following the Data Field, we have the Cyclic Redundancy Field, or CRC field. This field is used to detect
possible transmission errors. The CRC Field consists of a 15 bit CRC sequence, completed by the
recessive CRC Delimiter bit.

HOW does CAN work!

CAN Frame ACK Field

The next field is the Acknowledge Field. The Acknowledge Slot bit is transmitted as a recessive bit. Any
node that has received an error free frame acknowledges the correct reception of the frame by sending
back a dominant bit, regardless of whether the node is configured to accept that specific message or
not. This shows that CAN belongs to the "in-bit-response" group of protocols. The recessive
Acknowledge Delimiter completes the Acknowledge Slot and may not be overwritten by a dominant bit.

HOW does CAN work!

CAN Frame - EOF

The next field is the Acknowledge Field. The Acknowledge Slot bit is transmitted as a recessive bit. Any
node that has received an error free frame acknowledges the correct reception of the frame by sending
back a dominant bit, regardless of whether the node is configured to accept that specific message or
not. This shows that CAN belongs to the "in-bit-response" group of protocols. The recessive
Acknowledge Delimiter completes the Acknowledge Slot and may not be overwritten by a dominant bit.

HOW does CAN work!

CAN frame - Intermission

Between any two frames the bus must remain in the recessive state for at least a further 3 bit times. This
is called Intermission. If, following the frame, no nodes wish to transmit, then the bus stays in the
recessive state, or Bus Idle state.

HOW does CAN work!

CAN bits (timing, construction)

One CAN bit time, that is one high or low pulse of the NRZ code, is specified as
constructed from four non-overlapping time segments.

HOW does CAN work!

CAN bits (timing, construction)


Each segment, in turn, is constructed from an integer multiple of Time Quanta. The Time Quantum,
noted as TQ, is the smallest discrete timing resolution used by a CAN node. Its length is generated by
a programmable divide of the CAN node's oscillator frequency. There is a minimum of eight and a
maximum of 25 Time Quanta per bit. The bit time, and therefore the bit rate, is selected by
programming the width of the Time Quantum and the number of Time Quanta in the various segments.

HOW does CAN work!

CAN bits (timing, construction)


The first segment within the CAN bit is called the Synchronization Segment and is used to synchronize
the various bus nodes. On transmission, the output state is asserted at the start of this segment. If
there is a bus state change between the previous bit and the current bit, then this change is expected
to occur within this segment by the receiving nodes. The length of this segment is always one Time
Quantum.

HOW does CAN work!

CAN bits (timing, construction)


The Propagation Time Segment is used to compensate for signal delays across the network. These
delays are caused by signal propagation delays on the bus line and through the electronic interface
circuits of the bus nodes. This segment may be one to eight Time Quanta long.

HOW does CAN work!


CAN bits (timing, construction)
The Phase Buffer Segments One and Two are used to compensate for edge phase errors. These
segments may be lengthened or shortened by resynchronization. Phase Buffer Segment One may be
between one to eight Time Quanta long. Phase Buffer Segment Two is the maximum of Phase Buffer
Segment One and the information processing time, which is the time segment starting with the sample
point reserved for calculation of the subsequent bit level and is less than or equal to two Time Quanta
long. The sample point is the point of time at which the bus level is read and interpreted as the value of
that respective bit. Its location is between the two Phase Buffer Segments.

HOW does CAN work!

CAN bits (timing, construction)


As a result of resynchronization, Phase Buffer Segment One may be lengthened or Phase Buffer
Segment Two may be shortened to compensate for oscillator tolerances within the different CAN nodes.
If for example the transmitter oscillator is faster than the receivers oscillator, the next falling edge used
for resynchronization may be delayed.

HOW does CAN work!

CAN bits (timing, construction)


Therefore Phase Buffer Segment 1 is lengthened in order to adjust the sample point and
the end of the bit time.

HOW does CAN work!

CAN bits (timing, construction)


If, on the other hand, the transmitter oscillator is slower than the receivers oscillator, the next falling edge
used for resynchronization may be early.

HOW does CAN work!

CAN bits (timing, construction)


Therefore Phase Buffer Segment 2 in bit n is shortened in order to adjust the sample point for bit n+1 and the end of the
bit time.
The lengthening or shortening the phase buffer segments has an upper limit given by the Resynchronization Jump Width.
The Resynchronization Jump Width may be between 1 and 4 Time Quanta, but it may not be longer than Phase Buffer
Segment 2.

For many CAN module implementations, the Propagation Time Segment and Phase Buffer Segment One
are combined into one segment often called Timing Segment One for ease of programming. Phase Buffer
Segment Two is then known as Timing Segment Two.

HOW does CAN work!

CAN bandwidth vs network lenght

HOW does CAN work!

CAN connectors

PROGRAM PRESENTATIONS

1. CAN databases + CANdb


2. CANoe
3. uC implementation

CAN databases + CANdb

1. CAN database = All information that is processed in a


networked bus system, as well as the interrelationships
between units of information, are usually managed in a
database.
2. CANdb is a data management program which can be
used to create and modify these databases.

CAN databases + CANdb

CAN db objects:
- Vehicles (not available in CAN db++)
- Networks
- Control Units (ECUs)
- Environment Variables
- Node Groups (logical grouping of nodes)
- Network Nodes
- Messages
- Signals

CAN databases + CANdb (Networks)

CAN db objects:
- Networks

CAN databases + CANdb


Control Units (ECUs)

CAN db objects:
- Control Units (ECUs)

Control Units are the distributed processing units in the Network.


Information is exchanged with other control units via Network Nodes, which
represent the control unit's interface to the CAN bus.

CAN databases + CANdb


Environment Variables

CAN db objects:
- Environment Variables
Input and output variables of Network Nodes, such as
switch position, sensor signals and actuator signals.
In the CANdb++ data model environment variables are
assigned to the Control Unit.

CAN databases + CANdb


- Network Nodes

CAN db objects:
- Network Nodes

Network nodes are the interfaces of the Control Unit to a Network, over which the control unit outputs
information and receives information via the CAN bus.
A network node is defined by the following System Parameters:

Symbolic network node name

Address

In addition, value tables and values for user defined attributes can be attached to a network node.

CAN databases + CANdb


- Messages

CAN db objects:
- Messages
Messages can be transmitted over the CAN bus. A message is defined by the following System
Parameters:

Symbolic message name

Identifier (CAN ID)

Number of data bytes (DLC Data Length Code)

. Other parameters

CAN databases + CANdb


- Signals

CAN db objects:
- Signals
Signals represent the smallest unit of information. A signal is defined by the following System
Parameters:

Symbolic signal name

(see also Rules for naming objects)

Signal length
The signal length is set in bits.

Format (Intel or Motorola)

Value type (data type)

CAN databases + CANdb


CAN db view

CANoe

CANoe is a universal
- development
- testing and
- analysis environment for CAN bus systems

CANoe

CANoe is a universal
- development
- testing and
- analysis environment for CAN bus systems

CANoe - development

The development process is based on a phases


model which differentiates between four development
phases:
Phase 1: Requirements analysis and design of the
distributed system / Functional modeling
Phase 2: Implementation with simulation of remainder
of bus
Phase 3: Integration of the overall system

CANoe development phase 1

System responsible defines:


-network topology
-design each network node (definition of messages)
-baud rate
-statistic behavior of nodes => bus load & latency analysis
Functional modeling:
-nodes are given input / output messages and variables.
-done in CAPL (programming language)
-totally simulated, no HW is neccessary (???)

CANoe development phase 2

the design and development of individual network nodes is


conducted independently and in parallel by all participating
parties

CANoe development phase 3

all real network nodes are connected to the bus in a stepby-step manner. To do this, the network node models can
be switched-off individually in the simulator of the
remainder of the bus.

CANoe in action

CANoe Development

Elements of CANoe:
-built-in (analysis, architecture, measurements,
simulation setups, wizards etc)
-user defined
-panels (graphical control elements user
interaction)
-CAPL programs (implement user interaction)

CANoe build in elements

Trace

Graphics

CANoe build in elements

Interactive generator

CANoe User Defined

Panels
- windows defined by the user that can present
information or drive CAN behavior

CANoe User Defined

Panels
-defining graphical interface using PANEL EDITOR
-define behavior using CAPL programs

CANoe User Defined

Panel Editor
-defines graphically the interface
-defines link between elements and CAPL control
variables (environment variables)

CANoe User Defined

CAPL editor
CAPL is the
programming
language of CANoe
very similar to "C"
code

uC implementation

uC implementation
-done with CANgen (.dbc + config files) =>
generated files. Not the point of this training
-From application point of view there are: [BMW]
-SET_SIG_CAN(signal_name, value)
-SET_SIG_CAN_FORCED(signal_name, value)
-GET_SIG_CAN(signal_name)

uC implementation Network Management

Sleep Mode to reduce power consumption


Sleep Indication
Sleep Ack

You might also like