Você está na página 1de 28

Advanced Embedded Systems Design

Lecture 10 Controller Area Networks


BAE 5030 - 003
Fall 2004
Instructor: Marvin Stone
Biosystems and Agricultural Engineering
Oklahoma State University
Goals for Class Today
Questions over reading / homework (Chapters 23, 24)
USB from a developers prospective (Patrick)
SPI and I2C (Brody)
Controller Area Networks introduction (Stone)
Set assignment
Communications busses for embedded systems
(A very abridged list!)
LIN Automotive
On-board busses (inter-IC busses) SAE J1850
SPI SAE J1708 / 1587
I2C CAN based
SAE J1939 / ISO 11783
Microwire
Fault tolerant busses
1-Wire
ByteFlight
Industrial FlexRay
MODBUS TTP / TTCAN
RS485 MOST
Ethernet Avionics
Fieldbus MIL-STD-1553
Bitbus ARINC 429
CAN Marine
DeviceNet

NMEA 0183
SDS
CiA NMEA 2000 (IEC 61162-3 )
Proprietary Ethernet
RS 485 Ethernet
CAN IEEE
803.2 Further defined ethernet
803.11 wireless LAN
802.15.4 Zigbee
CAN Controller Area Network - Introduction
History
Developed by Bosch in mid 1980s to meet a need for networking
ECUs (electronic control units in automobiles)
Initially introduced with an 11-bit message identifier (CAN 1.0 1.2),
later a 29 bit identifier introduced (CAN 2.0)
Now:
11 bit only parts: CAN 1.2 (Also CAN2.0A)
2048 different CAN messages
11 bit compatible with 29 bit messages: CAN 2.0B 29 bit passive
xmit and receive 11 and 29 bit ID: CAN 2.0B
536 million CAN messages
CAN has since been heavily adopted
~350 million protocol controllers sold in 2003 (Bosch / CiA)
Broad industrial support
Automotive
J2284 / IDB-C 500 - kBaud automotive physical and data link
J1939 Heavy duty vehicle physical/data link/network/app layer
Proprietary
Industrial
DeviceNet Industrial physical/data link/network layers
SDS - Industrial physical/data link/network layers
Proprietary
See: http://www.can-cia.de/can/protocol/history/history.html
CAN Overview
CAN = Controller Area Network
Serial data communications protocol for real-time application
using a multiple access bus
Messages have assignable priority
most critical can dominate during heavy load
Messages are short (controlled length)
opportunities to insert a new message come often
Asynchronous serial communications
Serial bus vs. point-to-point
Reduction in wiring complexity
Better information sharing
Low probability of an undetected error
4.7 x 10-11 x message error rate
For a message error rate of 25/sec:
1 undetected error per 10,000 hours operation
Capacity Comparison
Capacity and Performance
Use of bus bandwidth @250 kBaud by messages
100 messages per second (10 ms repetition) =5%
Torque/Speed control on engine
Hitch control
10 messages per second (100 ms repetition) =0.5%
Throttle position
GPS Lat/Lon data
Implement application rate control (process data)
1 message per second (1s repetition) =0.05%
Display updates
System status
Message latency
134 bit message @250 kBaud (bit stuffing ignored)
@ 4 s per bit = 536 s = 0.5 ms per message max
Highest priority message
must wait no more than ~0.5 ms
Low priority messages
must wait till higher priority messages clear
latency may be long at high bus loads
Conventional Wiring (No Bus)

Serial
Communication
Links
Sensors Nozzles
ECUs NOZZLE
ECU

Data
Logging GPS
A Simple CAN Application (Serial Bus)

Sensors Nozzles
ECUs NOZZLE
ECU
Data Bus

Data Bus

Data
Logging GPS
CAN - Introduction
Network structure
Intended as a bus, but other physical implementations are
possible
Limitations No Tees
An overview of CAN based networking
CAN - Elements
CSMA/CA
Bitwize priority access strategy
Uses distributed synchronization of bit timing
Non-destructive collisions
Message components
Identifier / Data
Bus Access - Arbitration / Prioritization
Error Detection / Error Confinement
Filtering
Other features
In Frame Acknowledgement
RTR
Message structure
Message frame contains:
11/29 bit Identifier
Data length
0-8 bytes data
CRC
In-frame acknowledgement
CAN Frame Format - CAN 2.0B

B. CAN Extended Frame Format

CAN Extended Data Frame


Maximum frame length with bit stuffing = 150 bits
Control CRC
Arbitration Field Data
Field
32 Bits
6 Bits
Field Delimiter

S S I R E
Identifier ACK
O Identifier R D T r r DLC Data Field CRC O
Ext. 1 0
F R E R Field F
Bits 1 11 1 1 18 1 1 1 4 0 - 64 15 1 2 7

No Bit
Bit Stuffing
Stuffing
Typical ECU Components

Power
C o n d itio n in g

C AN C AN
M ic r o - C o n tr o lle r P ro to c o l Bus
C o n tr o lle r D r iv e r

M e m o ry In te rfa c e
I/O
ECU Connection to the bus

Power
ECU 1 Pow er
ECU 2
C o n d itio n in g C o n d itio n in g

CAN CAN CAN_H C AN C AN


M ic r o - C o n tr o lle r P ro to c o l Bus M ic r o - C o n t r o lle r P ro to c o l Bus
C o n tr o lle r D r iv e r C o n tr o lle r D r iv e r
CAN_L

M e m o ry In te rfa c e M e m o ry In te rfa c e
I/O I/O

TBC_PWR
CAN_H
Terminator CAN_L Terminator
TBC_RTN
Physical network structure

ECU 1 ECU 2 ECU 3


Message Message Message

Message
Communications Bus
Message Components

Message (up to 150 bits)

11 bits or 29 bits 0 to 8 bytes (0 to 64 bits)


Identifier Data

Start Serial bit stream


CAN Arbitration

V C AN _H

V d if f ISO 11878
V C AN _L
r e c e s s iv e d o m in a n t r e c e s s iv e

Identifier (29 bits) Data (8 bytes)


ECU 1 1 0 1 1 0 0 0 1 1 1 ... 1 0 1 1 1 1 1 1 1 0 0 0 0 0 1 1 1 ...
ECU 2 1 0 1 1 1 ECU 2 ceases transmission
and prepares to resend later
Bus
Result 1 0 1 1 0 0 0 1 1 1 ... 1 0 1 1 1 1 1 1 1 0 0 0 0 0 1 1 1 ...
Arbitration Field NO Arbitration
Lower numbered identifiers assume higher priority
Bit time control Length of a single bit

Bit must arrive a destination before phase_seg1


begins. Sampling at receiver will occur within the
phase segment.
Prop_seg. should accommodate total out and back
propagation time plus delay in tranceivers
CAN synchronization / bit timing
Definitions:
Synchronization segment (Sync_Seg) - that part of the bit time where bit
edges are expected to occur
Propagation segment (Prop_Seg) - intended to compensate for the physical
delay times
Phase segment (Phase_seg1, Phase_seg2) Provide control of the sample
point position
Synchronization Jump Width (SJW) defines how far a resynchronization
may move the Sample Point inside the limits defined by the Phase Buffer
Segments to compensate for edge phase errors.
Synchronization
Hard synchronization will be done to align bits at the beginning of a
message.
Phase_seg1 is lengthened or phase_seg2 is shortened to minimize phase
error by up to the synchronization jump width (SJW). Larger phase errors
cannot be compensated for.
See: http://www.can.bosch.com/docu/CiA99Paper.pdf
Physical Layer
Many physical layer definitions
Most ISO 11898 based
Maximum number of ECU's
Typical 30 (per segment)
Typical Media
Twisted shielded pair
120 nominal impedance
Two data lines (CAN_H, CAN_L)
One shield
Twisted Quad un-shielded
75 nominal impedance
Two data lines (CAN_H, CAN_L)
Two termination supply lines
Signal
Compatable with ISO 11898 drivers (eg. Phillips 80C250)
ISO 11898 Bus levels Microchip AN 228
Mapping of CAN to the OSI Microchip AN 228

Characteristics of CAN - CAN provides Data Link functions


To form a complete communications system

ISO 7498
Message Filtering - Example

Accept if:
(ID AND MASK) XOR MATCH = 0

10111100100 IDENTIFIER 1 = Care, 0= Dont Care

11100000000 MASK
10100000000 = ID AND MASK

10100000000 MATCH Pattern must match

00000000000 = (ID AND MASK) XOR MATCH


Error Detection
5 Error Types Detected
Bit Error (Sent bit doesnt match monitored bit)
Stuff Error (more than 6 successive in one state)
CRC error
Form Error
Acknowledge Error
Probability of an undetected error
4.7 x 10-11 x message error rate
for a message error rate of 25/sec,
1 undetected error per 10,000 hours operation
Assignment
Install the Pont time triggered scheduler in hardware
and toggle the RED/GREEN LED at 1 per sec.
Read Pont, Chapter 25, 28
Tutorial 30 min
Review SAE J1708, SAE J1850, SAE J1939
or
Review DeviceNET and SDS

Você também pode gostar