Today. Last Time. Motivation. CAN Bus. More about CAN. What is CAN?

Similar documents
Controller Area Network

Course Introduction. Purpose. Objectives. Content. Learning Time

Communication Networks for the Next-Generation Vehicles

Introduction to Controller Area Network (CAN)

Real-Time Communications. LS 12, TU Dortmund

Links. CS125 - mylinks 1 1/22/14

Controller area network

2.1 CHANNEL ALLOCATION 2.2 MULTIPLE ACCESS PROTOCOLS Collision Free Protocols 2.3 FDDI 2.4 DATA LINK LAYER DESIGN ISSUES 2.5 FRAMING & STUFFING

Links Reading: Chapter 2. Goals of Todayʼs Lecture. Message, Segment, Packet, and Frame

CS 640 Lecture 4: 09/11/2014

Recommended readings

Getting Connected (Chapter 2 Part 4) Networking CS 3470, Section 1 Sarah Diesburg

UNDERSTANDING THE CONTROLLER AREA NETWORK (CAN)

An Introduction to CAN by Peter Bagschik (I+ME ACTIA)

BOSCH. CAN Specification. Version , Robert Bosch GmbH, Postfach , D Stuttgart

The House Intelligent Switch Control Network based On CAN bus

High Level View. EE 122: Ethernet and Random Access protocols. Medium Access Protocols

Data Link Layer Technologies

CS 123: Lecture 12, LANs, and Ethernet. George Varghese. October 24, 2006

EE 122: Ethernet and

CSCI-1680 Link Layer Wrap-Up Rodrigo Fonseca

CSMA/CD (Collision Detection)

The Link Layer II: Ethernet

Communication (III) Kai Huang

CAN bus and NMEA2000 1

Link Layer and Ethernet

Link Layer and Ethernet

Data Link Layer: Overview, operations

CSE 461: Multiple Access Networks. This Lecture

Computer and Network Security

Lecture 6 The Data Link Layer. Antonio Cianfrani DIET Department Networking Group netlab.uniroma1.it

The Controller Area Network (CAN) Interface

CSCI-1680 Link Layer Wrap-Up Rodrigo Fonseca

Lecture 9: Bridging. CSE 123: Computer Networks Alex C. Snoeren

Contention Protocols and Networks

The Link Layer and LANs. Chapter 6: Link layer and LANs

CSCI-1680 Link Layer Wrap-Up Rodrigo Fonseca

Reminder: Datalink Functions Computer Networking. Datalink Architectures

Lecture 5 The Data Link Layer. Antonio Cianfrani DIET Department Networking Group netlab.uniroma1.it

CIS 551 / TCOM 401 Computer and Network Security. Spring 2007 Lecture 7

Real-Time (Paradigms) (47)

Using CAN Arbitration for Electrical Layer Testing

CSCI-1680 Link Layer I Rodrigo Fonseca

CSCI-1680 Link Layer Wrap-Up Rodrigo Fonseca

Message, Segment, Packet, and Frame Link-layer services Encoding, framing, error detection, transmission control Error correction and flow control

ECE 653: Computer Networks Mid Term Exam all

CSE/EE 461 Section 2

Goals of Today s Lecture. Adaptors Communicating

Controller Area Network (CAN)

Computer Network. Direct Link Networks Reliable Transmission. rev /2/2004 1

Topics Today. Lecture 8: Physical and Link Layers. Protocol Layering. Physical layer: chips versus bits. Physical Layer (Layer 1) Protocol Layering

Physical and Link Layers. CS144 Review Session 6 November 6 th, 2008 Roger Liao Based on slides by Ben Nham

Chapter 8 OSI Physical Layer

Jaringan Komputer. Broadcast Network. Outline. MAC (Medium Access Control) Channel Allocation Problem. Dynamic Channel Allocation

CSCI-1680 Physical Layer Link Layer I Rodrigo Fonseca

Summary of MAC protocols

Data and Computer Communications. Chapter 11 Local Area Network

CSE 461 Multiple Access. David Wetherall

Local Area Networks (LANs) SMU CSE 5344 /

Computer Network (2012 Spring) Homework Answer. Chapter2

Data and Computer Communications

CS 4453 Computer Networks Winter

Systems. Roland Kammerer. 10. November Institute of Computer Engineering Vienna University of Technology. Communication Protocols for Embedded

COS 140: Foundations of Computer Science

CARRIER SENSE MULTIPLE ACCESS (CSMA):

Additional Slides (informative)

CS 43: Computer Networks. 27: Media Access Contd. December 3, 2018

Development of a CAN Slave Module with SystemC. Igor Sachs Shang Qihua

Medium Access Control. IEEE , Token Rings. CSMA/CD in WLANs? Ethernet MAC Algorithm. MACA Solution for Hidden Terminal Problem

Operating Systems, Concurrency and Time. real-time communication and CAN. Johan Lukkien

EP A1 (19) (11) EP A1 (12) EUROPEAN PATENT APPLICATION. (43) Date of publication: Bulletin 2012/45

Medium Access Protocols

CAN protocol enhancement

CS61C Machine Structures Lecture 37 Networks. No Machine is an Island!

Topics. Link Layer Services (more) Link Layer Services LECTURE 5 MULTIPLE ACCESS AND LOCAL AREA NETWORKS. flow control: error detection:

Faculty of Science Final Examination. Computer Science B Basics of Computer Networks

CS/ECE 438: Communication Networks for Computers Spring 2018 Midterm Examination Online

Data Link Layer, Part 3 Medium Access Control. Preface

Sri Vidya College of Engineering and Technology. EC6703 Embedded and Real Time Systems Unit IV Page 1.

Level 1: Physical Level 2: Data link Level 3: Network Level 4: Transport

IEEE , Token Rings. 10/11/06 CS/ECE UIUC, Fall

CMPE 150/L : Introduction to Computer Networks. Chen Qian Computer Engineering UCSC Baskin Engineering Lecture 16

COS 140: Foundations of Computer Science

Lecture 8 The Data Link Layer part I. Antonio Cianfrani DIET Department Networking Group netlab.uniroma1.it

Overview. Performance metrics - Section 1.5 Direct link networks Hardware building blocks - Section 2.1 Encoding - Section 2.2 Framing - Section 2.

Telematics. 5rd Tutorial - LLC vs. MAC, HDLC, Flow Control, E2E-Arguments

CS 3640: Introduction to Networks and Their Applications

Overview. Data Link Technology. Role of the data-link layer. Role of the data-link layer. Function of the physical layer

Data Link Layer, Part 5. Medium Access Control

Chapter 5: Link layer

Fundamentals of Networking Introduction to Networking Devices

Housekeeping. Fall /5 CptS/EE 555 1

Computer Networks. Today. Principles of datalink layer services Multiple access links Adresavimas, ARP LANs Wireless LANs VU MIF CS 1/48 2/48

Link Layer and LANs 안상현서울시립대학교컴퓨터 통계학과.

Ethernet. Introduction. CSE 3213 Fall 2011

Multiple Access Protocols

Medium Access Control

ECEN 5032 Data Networks Medium Access Control Sublayer

Ethernet Technologies

Links, clocks, optics and radios

Transcription:

Embedded networks Characteristics Requirements Simple embedded LANs Bit banged SPI I2C LIN Ethernet Last Time CAN Bus Intro Low-level stuff Frame types Arbitration Filtering Higher-level protocols Today Motivation Some new cars contain > 3 miles of wire Clearly inappropriate to connect all pairs of communicating entities with their own wires O(n 2 ) wires CAN permits everyone on the bus to talk Cost ~$3 / node $1 for CAN interface $1 for the transceiver $1 for connectors and additional board area CAN Bus Cars commonly have multiple CAN busses Physical redundancy for fault tolerance CAN nodes sold 200 million in 2001 300 million in 2004 400 million in 2009 Controller Area Network What is CAN? Developed by Bosch in the late 1980s Current version is 2.0, from 1991 Multi-master serial network Bus network: All messages seen by all nodes Highly fault tolerant Resistant to interference Lossless in expected case Real-time guarantees can be made about CAN performance More about CAN Message based, with payload size 0-8 bytes Not for bulk data transfer! But perfect for many embedded control applications Bandwidth 1 Mbps up to 40 m 40 Kbps up to 1000 m 5 Kbps up to 10,000 m CAN interfaces are usually pretty smart Interrupt only after an entire message is received Filter out unwanted messages in HW zero CPU load Many MCUs including ColdFire have optional onboard CAN support 1

CAN Bus Low Level Dominant and Recessive CAN does not specify a physical layer Common PHY choice: Twisted pair with differential voltages Resistant to interference Can operate with degraded noise resistance when one wire is cut Fiber optic also used, but not commonly Bit encoding: Voltage difference dominant bit == logical 0 No voltage difference recessive bit == logical 1 Each node needs to be able to transmit and listen at the same time Including listening to itself Bus Conflict Detection Bus state with two nodes transmitting: So: Node 1 dominant recessive dominant dominant dominant recessive dominant Node 2 recessive When a node transmits dominant, it always hears dominant When a node transmits recessive and hears dominant, then there is a bus conflict Soon we ll see why this is important More Low Level CAN Encoding: Non-return to zero (NRZ) Lots of consecutive zeros or ones leave the bus in a single state for a long time In contrast, for a Manchester encoding each bit contains a transition NRZ problem: Not self-clocking Nodes can easily lose bus synchronization Solution: Bit stuffing After transmitting 5 consecutive bits at either dominant or recessive, transmit 1 bit of the opposite polarity Receivers perform destuffing to get the original message back CAN Clock Synchronization Problem: Nodes rapidly lose sync when bus is idle Idle bus is all recessive no transitions Bit stuffing only applies to messages Solution: All nodes sync to the leading edge of the start of frame bit of the first transmitter Additionally: Nodes resynchronize on every recessive to dominant edge Question: What degree of clock skew can by tolerated by CAN? Hint: Phrase skew as ratio of fastest to slowest node clock in the network CAN is Synchronous Fundamental requirement: Everyone on the bus sees the current bit before the next bit is sent This is going to permit a very clever arbitration scheme Ethernet does NOT have this requirement This is one reason Ethernet bandwidth can be much higher than CAN Let s look at time per bit: Speed of electrical signal propagation 0.1-0.2 m/ns 40 Kbps CAN bus 25000 ns per bit A bit can travel 2500 m (max bus length 1000 m) 1 Mbps CAN bus 1000 ns per bit A bit can travel 100 m (max bus length 40 m) 2

CAN Addressing Nodes do not have proper addresses Rather, each message has an 11-bit field identifier In extended mode, identifiers are 29 bits Everyone who is interested in a message type listens for it Works like this: I m sending an oxygen sensor reading Not like this: I m sending a message to node 5 Field identifiers also serve as message priorities More on this soon Data frame CAN Message Types Frame containing data for transmission Remote frame Frame requesting the transmission of a specific identifier Error frame Frame transmitted by any node detecting an error Overload frame Frame to inject a delay between data and/or remote frames if a receiver is not ready CAN Data Frame Data Frame Fields Bit stuffing not shown here it happens below this level RTR remote transmission request Always dominant for a data frame IDE identifier extension Always dominant for 11-bit addressing CRC Based on a standard polynomial CRC delimiter Always recessive ACK slot This is transmitted as recessive Receiver fills it in by transmitting a dominant bit Sender sees this and knows that the frame was received By at least one receiver ACK delimiter Always recessive Remote Frame Same as data frame except: RTR bit set to recessive There is no data field Value in data length field is ignored Error Checking Five different kinds of error checking are performed by all nodes Message-level error checking Verify that checksum checks Verify that someone received a message and filled in the ack slot Verify that each bit that is supposed to be recessive, is Bit-level error checking Verify that transmitted and received bits are the same Except identifier and ack fields Verify that the bit stuffing rule is respected 3

Error Handling Every node is in error-active or error-passive state Normally in error-active Every node has an error counter Incremented by 8 every time a node is found to be erroneous Decremented by 1 every time a node transmits or receives a message correctly If error counter reaches 128 a node enters errorpassive state Can still send and receive messages normally If error counter reaches 256 a node takes itself off the network Error Frame Active error flag six consecutive dominant bits This is sent by any active-error node detecting an error at any time during a frame transmission Violates the bit stuffing rule! This stomps the current frame nobody will receive it Following an active error, the transmitting node will retransmit Passive error flag six consecutive recessive bits This is sent by any passive-error node detecting an error Unless overwritten by dominant bits from other nodes! After an error frame everyone transmits 8 recessive bits Bus Arbitration Problem: Control access to the bus Ethernet solution: CSMA/CD Carrier sense with multiple access anyone can transmit when the medium is idle Collision detection Stomp the current packet if two nodes transmit at once Why is it possible for two nodes to transmit at once? Random exponential backoff to make recurring collisions unlikely Problems with this solution: Bad worst-case behavior repeated backoffs Access is not prioritized CAN Arbitration Nodes can transmit when the bus is idle Problem is when multiple nodes transmit simultaneously We want the highest-priority node to win Solution: CSMA/BA Carrier sense multiple access with bitwise arbitration How it works: Two nodes transmit start-of-frame bit Nobody can detect the collision yet Both nodes start transmitting message identifier As soon as the identifiers differ at some bit position, the node that transmitted recessive notices and aborts the transmission Multiple Colliding Nodes Arbitration Continued Consequences: Nobody but the losers see the bus conflict Lowest identifier always wins the race So: Message identifiers also function as priorities Nondestructive arbitration Unlike Ethernet, collisions don t cause drops This is cool! Maximum CAN utilization: ~100% Maximum Ethernet with CSMA/CD utilization: ~37% 4

CAN Message Scheduling Network scheduling is usually non-preemptive Unlike thread scheduling Non-preemptive scheduling means high-priority sender must wait while low-priority sends Short message length keeps this delay small Worst-case transmission time for 8-byte frame with an 11-bit identifier: 134 bit times 134 µs at 1 Mbps Babbling Idiot Error What happens if a CAN node goes haywire and transmits too many high priority frames? This can make the bus useless Assumed not to happen Schemes for protecting against this have been developed but are not commonly deployed Most likely this happens very rarely CAN bus is usually managed by hardware CAN on ColdFire 52233 does not have CAN But sibling chips 52231, 53324, and 52235 have FlexCAN 16 message buffers Each can be used for either transmit or receive Buffering helps tolerate bursty traffic Transmission Both priority order and queue order are supported Receiving FlexCAN unit looks for a receive buffer with matching ID Some ID bits can be specified as don t cares More CAN on CF Interrupt sources Message buffer 32 possibilities successful transmit / receive from each of the 16 buffers Error Bus off too many errors Higher Level Standards CAN leaves much unspecified How to assign identifiers? Endianness of data? Standardized higher-level protocols built on CAN: CANKingdom CANOpen DeviceNet J1939 Smart Distributed System Similar to how TCP is built in IP HTTP is built in TCP Etc. CANOpen Important device types are described by device profiles Digital and analog I/O modules Drives Sensors Etc. Profiles describe how to access data, parameters, etc. 5

CAN Summary Not the cheapest network E.g., LIN bus is cheaper Not suitable for high-bandwidth applications E.g. in-car entertainment streaming audio and video MOST Media Oriented Systems Transport Design point: Used where reliable, timely, medium-bandwidth communication is needed Real-time control of engine and other major car systems 6