Title: Advanced Embedded Systems Design
1Advanced Embedded Systems Design
- Lecture 10 Controller Area Networks
- BAE 5030 - 003
- Fall 2004
- Instructor Marvin Stone
- Biosystems and Agricultural Engineering
- Oklahoma State University
2Goals 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
3Communications busses for embedded systems(A
very abridged list!)
- Automotive
- SAE J1850
- SAE J1708 / 1587
- CAN based
- SAE J1939 / ISO 11783
- Fault tolerant busses
- ByteFlight
- FlexRay
- TTP / TTCAN
- MOST
- Avionics
- MIL-STD-1553
- ARINC 429
- Marine
- NMEA 0183
- NMEA 2000 (IEC 61162-3 )
- Ethernet
- Ethernet
- IEEE
- LIN
- On-board busses (inter-IC busses)
- SPI
- I2C
- Microwire
- 1-Wire
- Industrial
- MODBUS
- RS485
- Ethernet
- Fieldbus
- Bitbus
- CAN
- DeviceNet
- SDS
- CiA
- Proprietary
- RS 485
- CAN
4CAN 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
5CAN 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
6Capacity Comparison
7Capacity and Performance
- Use of bus bandwidth _at_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
8Message latency
- 134 bit message _at_250 kBaud (bit stuffing ignored)
- _at_ 4 ms per bit 536 ms 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
9Conventional Wiring (No Bus)
Serial Communication Links
10A Simple CAN Application (Serial Bus)
11CAN - Introduction
- Network structure
- Intended as a bus, but other physical
implementations are possible - Limitations No Tees
12An 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
13- Message structure
- Message frame contains
- 11/29 bit Identifier
- Data length
- 0-8 bytes data
- CRC
- In-frame acknowledgement
14CAN Frame Format - CAN 2.0B
15Typical ECU Components
16ECU Connection to the bus
ECU 1
ECU 2
CAN_H
CAN_L
TBC_PWR
Terminator
Terminator
CAN_H
CAN_L
TBC_RTN
17Physical network structure
Message
Message
18Message Components
Message (up to 150 bits)
0 to 8 bytes (0 to 64 bits)
Identifier
Data
Serial bit stream
Start
19CAN Arbitration
ISO 11878
Lower numbered identifiers assume higher priority
20Bit 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
21CAN 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
22Physical Layer
- Many physical layer definitions
- Most ISO 11898 based
- Maximum number of ECU's
- Typical 30 (per segment)
- Typical Media
- Twisted shielded pair
- 120 W nominal impedance
- Two data lines (CAN_H, CAN_L)
- One shield
- Twisted Quad un-shielded
- 75 W nominal impedance
- Two data lines (CAN_H, CAN_L)
- Two termination supply lines
- Signal
- Compatable with ISO 11898 drivers (eg. Phillips
80C250)
23ISO 11898 Bus levels Microchip AN 228
24Mapping of CAN to the OSI Microchip AN 228
- Characteristics of CAN - CAN provides Data Link
functions
25To form a complete communications system
ISO 7498
26Message Filtering - Example
Accept if (ID AND MASK) XOR MATCH 0
10111100100
IDENTIFIER
1 Care, 0 Dont Care
11100000000
MASK
ID AND MASK
10100000000
10100000000
Pattern must match
MATCH
00000000000
(ID AND MASK) XOR MATCH
27Error 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
28Assignment
- 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