T2 Automotive SWArch 27102022 CAN Bus Protocol
T2 Automotive SWArch 27102022 CAN Bus Protocol
Technical Methodological
Process Competence
Competence Competence
T1: Automotive Basics
(Sensor, SW, Mobility P1: Requirements
M1: SW Development Engineering
Solution) Lifecycle
T2: Automotive SW
Architecture (AUTOSAR) P2: Design Principles
This slide is a part of BGSV Embedded Academy (BEA) program and only used for
BEA training purposes.
This slide is Bosch Global Software Technology Company Limited’s internal property.
All rights reserved, also regarding any disposal, exploitation, reproduction, editing,
distribution as well as in the event of applications for industrial property rights.
This slide has some copyright images and text, which belong to the respective
organizations.
T2
AUTOMOTIVE SOFTWARE
ARCHITECTURE
WHAT IS
SOFTWARE
ARCHITECTURE?
What is Software Architecture
Plot environment (adjacent to Position and size of walls, wall 3D representation of the building Physical realization: built home
neighbors‘ plots), permissible and openings, floors and ceilings or parts of it. Location and views of (ready to move in).
used building footprint furniture and fixtures. Virtual tour
inside the object.
7
What is Software Architecture
How to build an ECU
E/E architecture Circuit PCB Layout Implementation
Network and electrical Logical wiring of components Physical location and wiring of Physical realization: anufactured
environment of the ECU describing electrical functions components (considering of non- Electronic Control Unit to be
functional requirements like EMV, installed into the vehicle.
heat dissipation, physical
interfaces to housing)
8
What is Software Architecture
How to build a software product – Oversimplify
9
What is Software Architecture
How to build a software product – Architectural Views
10
What is Software Architecture
What is an architecture
Definition of Architecture (IEEE, 2011-12-01): According to this definition architectures
architecture <system> fundamental describe:
concepts or properties of a system in its fundamental concepts on which
environment embodied in its elements, corresponding systems are built,
relationships, and in the principles of its the environment where the system under
design and evolution design need to be integrated into,
components which the system consists
of, and
relations between the components and
the environment.
What is Software Architecture
Quiz time
Select the three most often used architecture views:
(a) Physical database view
(b) Context view
(c) Building Block/Component view
(d) Test-driven view
(e) Configuration view
(f) Runtime view
12
What is Software Architecture
Quiz time
Select the three most often used architecture views:
(a) Physical database view
(b) Context view
(c) Building Block/Component view
(d) Test-driven view
(e) Configuration view
(f) Runtime view
13
WHAT IS
AUTOSAR?
What is AUTOSAR
AUTOSAR Vision
AUTOSAR aims to improve complexity management of integrated E/E architectures
through increased reuse and exchangeability of SW modules between OEMs and
suppliers.
Exchangeability
between suppliers’
Platform solutions Platform
a.1, a.2, a.n b.1, b.2, b.n
Exchangeability
Exchangeability between vehicle
between manufacturers’ Platform Platform
platforms
applications e.1, e.2, e.n d.1, d.2, d.n
What is AUTOSAR
Aims and benefits of using AUTOSAR
AUTOSAR aims to standardize the software architecture of Electronic Control Units
(ECUs). AUTOSAR paves the way for innovative electronic systems that further improve
performance, safety and security. • Hardware and software –
widely independent of
each other.
• Development can be de-
coupled (through
abstraction) by horizontal
layers, reducing
development time and
costs.
• Reuse of software
enhances quality and
efficiency
16
What is AUTOSAR
More Than 280 AUTOSAR Partners
9 Core Partners
53 Development Partners
+ 152 Associate
Partners
+ 29 Attendees
18
What is AUTOSAR
AUTOSAR Deliverables Most common type of deliverables
• ATS: Acceptance Test Specification
• CONC: Concept document
Acceptance Application Sensor • EXP: Explanation document
• MMOD: Meta-model files (M2)
Test Interfaces Interfaces • MOD: Model files (M1)
• PRS: Protocol Specification
• RS/SRS: Requirement Specification
• SWS: Software Specification
• TPS: Template Specification
Classic Platform Adaptive Platform • TR: Technical Report
Legend
Released as an own standard
A B A planned to extend B
Application Layer
Microcontroller
AUTOSAR Layered Architecture
Coarse view
The AUTOSAR Basic Software is further divided in the layers: Services, ECU Abstraction,
Microcontroller Abstraction and Complex Drivers.
Application Layer
Runtime Environment
Services Layer
Compl
ex
ECU Abstraction Layer Driver
s
Microcontroller Abstraction Layer
Microcontroller
22
AUTOSAR Layered Architecture
Detailed view
The Basic Software Layers are further divided into functional groups. Examples of Services
are System, Memory and Communication Services.
Application Layer
Runtime Environment
System Services Memory Crypto Services Off-board Communicatio I/O Hardware Complex
Services Communicatio n Services Abstraction Drivers
n Services
Microcontroller
23
AUTOSAR Layered Architecture
Microcontroller Abstraction Layer
The Microcontroller Abstraction Layer is the lowest software
Application Layer
layer of the Basic Software.
It contains internal drivers, which are software modules with direct RTE
access to the µC and internal peripherals.
Co
mpl
Task ECU Abstraction Layer ex
Driv
Make higher software layers independent of µC ers
Microcontroller Abstraction Layer
Properties Microcontroller
Implementation: µC dependent
Upper Interface: standardized and µC independent
24
AUTOSAR Layered Architecture
ECU Abstraction Layer
The ECU Abstraction Layer interfaces the drivers of the
Application Layer
Microcontroller Abstraction Layer. It also contains drivers for
external devices. RTE
It offers an API for access to peripherals and devices regardless of
their location (µC internal/external) and their connection to the Co
µC (port pins, type of interface) mpl
ex
ECU
ECU Abstraction
Abstraction Layer
Layer
Driv
ers
Task Microcontroller Abstraction Layer
Properties
Implementation: µC independent, ECU hardware dependent
Upper Interface: µC and ECU hardware independent
25
AUTOSAR Layered Architecture
Complex Drivers
The Complex Drivers Layer spans from the hardware to the RTE.
Application Layer
Task RTE
Complex
Drivers
➢ which are not specified within AUTOSAR, ECUECU Abstraction
Abstraction Layer
Layer
Properties
Implementation: might be application, µC and ECU hardware
dependent
Upper Interface: might be application, µC and ECU hardware
dependent
26
AUTOSAR Layered Architecture
Services Layer
The Services Layer is the highest layer of the Basic Software
which also applies for its relevance for the application software: Application Layer
Complex
Drivers
➢ Memory services (NVRAM management) ECUECU Abstraction
Abstraction Layer
Layer
➢ Diagnostic Services (including UDS communication, error memory and
fault treatment) Microcontroller Abstraction Layer
➢ ECU state management, mode management
Microcontroller
➢ Logical and temporal program flow monitoring (Wdg manager)
Task
Provide basic services for applications, RTE and basic software
modules.
Properties
Implementation: mostly µC and ECU hardware independent
Upper Interface: µC and ECU hardware independent
27
AUTOSAR Layered Architecture
AUTOSAR Runtime Environment (RTE)
The RTE is a layer providing communication services to the application
software (AUTOSAR Software Components and/or AUTOSAR Application Layer
Sensor/Actuator components).
AUTOSAR Runtime Environment (RTE)
Above the RTE the software architecture style changes from “layered“ to Services Layer
“component style“.
Complex
Drivers
ECUECU Abstraction
Abstraction Layer
Layer
The AUTOSAR Software Components communicate with other components
Microcontroller Abstraction Layer
(inter and/or intra ECU) and/or services via the RTE.
Microcontroller
Task
Make AUTOSAR Software Components independent from the mapping to a
specific ECU.
Properties
Implementation: ECU and application specific (generated individually for
each ECU)
Upper Interface: completely ECU independent
28
AUTOSAR Basic Software
Quiz time
From the top to bottom, how many software layers of the
highest abstraction level of AUTOSAR architecture?
(a) 3 layers: Application, RTE, BSW.
(b) 5 layers: Application, RTE, Service layer, ECU Abstraction layer,
MCAL.
(c) 3 layers: Services layer, Abstraction layer, MCAL.
(d) 4 layers: Application, RTE, BSW, MCAL.
31
AUTOSAR Layered Architecture
Quiz time
Which of the following qualities can most likely be improved
by using a layered architecture?
(a) Runtime efficiency (performance).
(b) Flexibility in modifying or changing the system.
(c) Flexibility at runtime (configurability).
(d) Non-repudiability.
32
AUTOSAR BASIC
SOFTWARE
AUTOSAR Basic Software
What is “Basic SW”?
Basic Software
/ˈbeɪ.sɪk/, adj /ˈsɑːft.wer/, noun
simple and not complicated, so able to the instructions that control what a
provide the base or starting point from computer does; computer programs
[cambridge.org]
which something can develop
[cambridge.org]
34
AUTOSAR Basic Software
What is “basic” to Embedded Software?
Embedded Software
ECU Function A
ECU Function B
ECU Function C
BSW
Schedule Communication
Memory
…
I/O
35
AUTOSAR Basic Software
Question 1
Map BSW module type to the suitable layer
Services Layer
On-chip Driver
Off-chip Driver
Complex
ECU Abstraction Layer Drivers
Interface
Handler
Manager
Microcontroller Abstraction Layer
36
AUTOSAR Basic Software
BSW Vertical view / Stack view
Application Layer
ECU Abstraction
Onboard Memory Crypto Communication
and Complex
Device Hardware Hardware Hardware
Drivers
Abstraction Abstraction Abstraction Abstraction
Microcontroller
37
AUTOSAR BASIC
SOFTWARE:
COMMUNICATION
STACK
AUTOSAR Basic Software
Communication Stack – Building Blocks
ComStack facilitates vehicle network
Application Layer communication and provides
communication services to other
BSW components and Application
AUTOSAR Runtime Environment (RTE) BSW-Layers Layer.
39
AUTOSAR Basic Software REF
Abstraction is a group of modules which abstracts from the location of I-PDU1 I-PDU1 NM
I-PDU NM
communication controllers and the ECU hardware layout. Module
NM
Module
CAN Tp NM
Module
- Provide equal mechanisms to access CAN bus channel regardless of it‘s Module
J1939Tp
location (on-chip / on-board)
- µC independent, ECU hardware dependent and external device dependent N-PDU N-PDU
Communication
HW
internal drivers, which are software modules with direct access to the µC internal L-PDU
40
AUTOSAR Basic Software REF
- Provides routing of PDUs between different abstract communication controllers PDU Router
and upper layers
I-PDU1 I-PDU1 NM
- Provides TP routing on-the-fly. Transfer of TP data is started before full TP data is I-PDU NM
Module
NM
buffered Module
NM
CAN Tp Module
J1939Tp Module
<BusType>If L-PDU
- Provides a unique interface to manage different hardware device types e.g., CAN Communication Drivers
controllers and CAN transceivers used by the defined ECU hardware layout CAN Driver2
41
AUTOSAR Basic Software REF
ComM Manager
<BusType>SM
PDU Router
- Handles the communication system dependent Start-up and Shutdown features
I-PDU1 I-PDU1 NM
I-PDU NM
Module
NM
Module
Nm CAN Tp NM
Module
J1939Tp Module
- Acts as a bus-independent adaptation layer between the bus-specific Network N-PDU N-PDU
Management modules and the Communication Manager module (ComM)
- Synchronization of Network States of different communication channels Communication
connected to an ECU via the network managements handled by the NM HW
Coordinator CAN Interface2 Abstraction
L-PDU
- Coordinate the transition between normal operation and bus-sleep mode of the CAN Driver2
network.
42
AUTOSAR Basic Software REF
Rte
Generic interface.
ISignal_A ISignal_B
Data exchanged as I-Signals.
Layer 6: I COM, DCM I-PDU
Presentation Com
(Interaction) Generic interface. IPdu_B
IPdu_A
Data exchanged as I-PDUs.
I PDU router, I-PDU
PduR
PDU Bus Type dependent interface. IPdu_A IPdu_B
multiplexer Data exchanged as I-PDUs.
Layer 3: N TP Layer N-PDU
Network CanTp
Layer Can Transport Protocol dependent interface. Npdu_B
Data exchanged as N-PDUs.
Layer 2: L Driver, Interface L-PDU
Data Link Can Driver Instance dependent interface e.g.
CanIf
Layer rba_Can_MCan_Write. HwObject_A LPdu_B
Data exchanged as L-PDU and HW Object handler.
Can 1 Can 2
Layer 1: Microcontroller, Transceiver, Bus medium
Physical Can Frames on physical network CanFrame_A CanFrame_B
43
AUTOSAR Basic Software REF
Communication
Signals
Manager
Socket Adaptor
XCP
PDU Router
Messages Streams
Ethernet Protocol
TCP/IP Communication
I-PDU1 I-PDU1 NM
DHCP I-PDU I-PDU1 I-PDU I-PDU NM
Module
NM
UDP TCP Module
NM
CAN Tp Module
Services
FlexRay Tp Module
Packet Segment J1939Tp
I-PDU: Interaction Layer PDU Note: This image is not complete with 1 The Interface between PduR and Tp differs significantly compared to the interface between PduR and the Ifs.
N-PDU: Network Layer PDU respect to all internal communication In case of TP involvement a handshake mechanism is implemented allowing the transmission of I-Pdus > Frame size.
L-PDU: Data Link Layer PDU paths. 2 CanIf with TTCAN serves both CanDrv with or without TTCAN. CanIf without TTCAN cannot serve CanDrv with TTCAN.
45
AUTOSAR Basic Software REF
OSEK: Offene Systeme und deren Schnittstellen für die Elektronik in Kraftfahrzeugen (DE) or Open Systems and the Corresponding Interfaces for Automotive Electronics (EN).
46
AUTOSAR Layered Architecture
Quiz time
Which component is responsible for distribution of Pdu for
inter- and intra-ECU communication?
(a) Com.
(b) PduR.
(c) ComM.
(d) Rte.
47
AUTOSAR Layered Architecture
Quiz time
Which component is responsible for distribution of Pdu for
inter- and intra-ECU communication?
(a) Com.
(b) PduR.
(c) ComM.
(d) Rte.
48
AUTOSAR Layered Architecture
Quiz time
Which statement below is not correct when talking about
data exchange in AUTOSAR?
(a) On Application layer, System Signal is being exchanged without
context of bus system.
(b) Two Signal can be packed inside a Pdu. Two Pdus can be
packed inside a Frame.
(c) I-Pdu is data unit at Interaction layer. L-Pdu is data unit of Data-
link layer.
(d) N-Pdu is data unit at Transport layer, which is mandatory for all
AUTOSAR systems.
49
AUTOSAR Layered Architecture
Quiz time
Which statement below is not correct when talking about
data exchange in AUTOSAR?
(a) On Application layer, System Signal is being exchanged without
context of bus system.
(b) Two Signal can be packed inside a Pdu. Two Pdus can be
packed inside a Frame.
(c) I-Pdu is data unit at Interaction layer. L-Pdu is data unit of Data-
link layer.
(d) N-Pdu is data unit at Transport layer, which is mandatory for all
AUTOSAR systems.
50
AUTOSAR Layered Architecture
Quiz time
What are the drawbacks of AUTOSAR?
(a) Standardization by aggregation.
(b) It is huge.
(c) Moving target.
(d) All of above.
51
AUTOSAR Layered Architecture
Quiz time
What are the drawbacks of AUTOSAR?
(a) Standardization by aggregation.
(b) It is huge.
(c) Moving target.
(d) All of above.
52
CLASSIC AUTOSAR
USE CASE
AUTOSAR RTE
Integrator
Operating
Silicon Vendor A
Complex
System Drivers
Standardized Interface
DIO PWM CAN Driver
Microcontroller Abstraction
ECU-Hardware
54
of
65
AUTOSAR Introduction 24
Classic AUTOSAR Use Case
Use Case ‘Front Light Management’: Exchange Type of Front Light
Integrator Supplier B OEM Supplier A
SwitchEvent LightRequest Front-Light Manager Xenonlight
Headlight
check_switch () switch event (event) request_light (type, mode) set_light (type, mode)
set_light(type, mode)
get_keyposition()
set_light (type, mode) set_current (…)
set_current(…)
Switch_event (event) request_light (type, mode)
set_dboard(type, mode)
AUTOSAR Interface AUTOSAR Interface AUTOSAR Interface AUTOSAR Interface
AUTOSAR RTE
Integrator
Operating
Silicon Vendor A
Complex
System Drivers
Standardized Interface
DIO DIO
PWM CAN Driver
Microcontroller Abstraction
ECU-Hardware
55
of
65
AUTOSAR Introduction 24
Classic AUTOSAR Use Case
Distribution ECUs
SwitchEvent LightRequest
LightRequest Front-Light Manager Xenonlight
check_switch () switch_event(event) request_light(type, mode) set_light(type, mode)
switch_event request_light get_keyposition()
set_light(type, mode) set_current (…)
(event) (type, mode)
AUTOSAR Int. AUTOSAR
AUTOSAR Interface
Interface AUTOSAR Interface AUTOSAR Interface
56
of
65
AUTOSAR Introduction 24
Classic AUTOSAR Use Case
Distribution on ECUs – ‘Front-Light Management’
SwitchEvent LightRequest Front-Light Manager Xenonlight
check_switch () switch_event(event) request_light(type, mode) set_light(type, mode)
get_keyposition()
switch_event request_light set_light(type, mode) set_current (…)
(event) (type, mode)
AUTOSAR Int. AUTOSAR Interface AUTOSAR Interface AUTOSAR Interface
Std. Interface
set_light(type, mode)
set_current (…)
AUTOSAR Interface
LightRequest
switch_event(event)
request_light
(type, mode)
AUTOSAR Interface
AUTOSAR Interface
CAN Bus
57
of
65
AUTOSAR Introduction 24
CAN
PROTOCOL
Introduction
Vehicle network
59
Introduction
History
Maximum Bitrate Mbit/s
Year
60
Introduction
Characteristics of ‘CAN’
• CAN is a multi-master Bus
• Theoretically No limitation on the number of nodes
• Configuration flexibility - No node addressing
• Prioritization of messages through “Identifiers”
• Multicast reception with the time synchronization
• System wide data consistency
• Guarantee of latency times
• Error detection and error signaling
• Automatic retransmission of corrupted messages
• Temporary errors - permanent failures of nodes and
autonomous switching off defect nodes
61
Introduction
CAN in the OSI model
62
CAN Protocol
Physical Layer
➔ Bit rate: up to 1Mbit/s
➔ Bidirectional Dual-wire bus with 40-50m maximum in length
➔ Multi-Master
Volt
OBD connector
63
CAN Protocol
Relation between Baud Rate and Bus Length
64
CAN Protocol
Bus Access and Arbitration
• Bus access through CSMA with AMP
NODE Arbitration phase
Remainder
A 0 1 0 0
B 0 1 0 1
C 0 1 1 0 Node B looses
arbitration
Node C looses
BUS 0 1 0 0
arbitration
• Advantages
• No Collision
• Transmission of highest priority message within the latency time
65
CAN Protocol
Message Transfer
Frame Formats
• Standard Frame - 11bit Identifier
• Extended Frame - 29 bit Identifier
Frame Types
• Data Frame
• Remote Frame (not useful)
• Error Frame
• Overload Frame (not useful)
66
CAN Protocol
Data Frame
Standard Data Frame Format
Arbitration Control Field Data Field CRC Field ACK End of Inter
Field Frame mission
Field -
SOF
RTR
IDE
11 Bit Identifier DLC (4) 0 to 64 Bits 15 Bits 7 Bits 3 Bits
r0
Bus Idle CRC Delimiter
Ack Slot Bus Idle
Ack Delimiter
RTR
IDE
11 Bit Identifier 18 Bit Identifier DLC (4) 0 to 64 Bits
r1
r0
Difference between Standard Frame and Extended Frame
• Differs only in Arbitration field and Control field
67
CAN Protocol
Error Frame
Error Frame Format (Active Error Frame)
Error Condition
• Error flag can start within the frame that is currently being transmitted
68
CAN Protocol
Error Handling
The mode of the controller is controlled by two error
counters - the transmit error counter (tx_count) and the
receive error counter (rx_count).
69
CAN Protocol
Interframe Spacing
After the transmission of a frame by an Error Active node
3 Bits
3 Bits 8 Bits
70
CAN Protocol
Message Coding
Non-Return-to-Zero coding
• Keeps the frequency of the signal on the bus to minimum.
“1”
“0”
1 1 0 1 0 0 1 1 ………………..
Bit-Stuffing
• Ensures sufficient Recessive and Dominant edges for Re-Synchronization.
Data Stream
1 1 2 3 4 5 6 7 8 9 101 2 3 1 2 1 2 3 4 5 6 1 2
Bit Stream
1 1 2 3 4 5 S 6 7 8 9 10S 12 3 1 2 1 2 3 4 5 S 6 1 2
71
A complete CAN bus frame
Source: Wikipedia
72
CAN Protocol
Types of Error Detected in CAN Bus
CRC Error:
• Every node receive the message, Calculate CRC and compare it with Received CRC.
Acknowledge Error:
• Transmitting node send a ACK slot bit as a recessive bit and check for dominant bit to verify reception.
Form Error:
• Generated when any of following bit is detected as a dominant bit where One should not be.
e.g. CRC delimiter, ACK delimiter, End of Frame, Inter Frame Space.
Bit Error:
• Node detect the signal that is opposite of what it send on Bus.
Stuff Error:
• Bit stuffing rule is violated when 6-consecutive bits with the same polarity are detected.
73
Introduction about CAN FD
Main improvement:
• Increase bit rate ( 2,4 … up to 8 Mbit/s)
• Increase payload up to 64 bytes
74
Abbreviation
CAN: Controller Area Network
CAN FD: Controller Area Network Flexible Data-Rate
CSMA: Carrier Sense Multiple Access/ Collision Detection
AMP: Arbitration on Message Priority
OSI: Open Systems Interconnection model
SOF: Start Of Frame
RTR bit: Remote Transmission Request bit
SRR bit: Substitute Remote Request bit
IDE bit: Identifier Extension
DLC: Data Length Code
EOF: End Of Frame
CRC: Cyclic Redundancy Check/ Check sum
ACK bit: Acknowledgment bit
IFS: Inter Frame Space
REC: Receive Error Counter
TEC: Transmit Error Counter
75
Reference
- CAN Specification 2.0 – Bosch
- CSMA/CD : https://en.wikipedia.org/wiki/Carrier-sense_multiple_access_with_collision_detection
76
DIAGNOSIS
OVERVIEW
Definitions
Diagnosis – What?
“In automotive engineering, Diagnosis is typically used to determine the
causes of symptoms and solutions to issues.”
symptom(s) – what the user/operator/repairer of the system (vehicle or
whatever) notices;
fault(s) – the error(s) in the system that result in the symptom(s);
root cause(s) – the cause(s) of the fault.
78
Definitions
Diagnosis – How?[1]
To do Diagnostic, Technician have to know how to use Diagnostic Tools
and Equipment.
Tool and Equipment could be classified into:
Basic Equipment: such as Multi-meter
Tracing Tool: like Oscilloscope
Scanner/Fault Code Readers and Analyzers.
79
Definitions
Diagnosis – How?[2]
The Equipment shall help technician indicate where is fault occurs in
systems.
In the other word, In Vehicle, Systems should have ability to provide
information in case request.
This is the motivation of On-board diagnostics (OBD).
80
Definitions
Diagnosis – How?[3]
When the fault occurs, the system stores a diagnostic trouble code
(DTC), also store important information of the vehicle when the fault was
set.
A service technician is able to connect a diagnostic scan tool or a code
reader that will communicate with the system and retrieve this
information.
As vehicles and their systems become more complex, the functionality
of OBD is being extended to cover vehicle systems and components
that do not have anything to do with vehicle emissions control: Vehicle
body, chassis and accessories
OBD systems use a standardized communications port to provide data
The Communication between Diagnostic Equipment and ECUs through
Vehicle Special Interface for Diagnosis purpose is called Diagnostic
Communication.
81
Definitions
States and Events
Everything about the car is either in a "normal" state or an "abnormal"
state.
Either the car is starting normally or it is not. Either the engine is running
normally or it is not.
Used in this way, "normal" means acceptable, the way they are
supposed to be, okay. "Abnormal" means not acceptable, not the way
they are supposed to be, not okay.
The purpose of all automobile repair is to correct abnormal states and
restore the car to its normal state of operation.
82
Definitions
States and Events
An "event" is when something happens: a spark plug fires, the brakes
are applied, a fuel injector opens, a relay closes.
An event is a change of state, from one condition to another.
A "normal event" occurs when something happens just as it is supposed
to happen.
An "abnormal event" is when something happens that is not supposed
to happen: the engine quits unexpectedly, the car fails to stop when the
brakes are applied.
All automotive complaints can be described and understood in terms of
abnormal events: some things are happening which are not supposed to
happen, and the driver has noticed them.
83
Diagnosis Uses
Use to read the parameters like WSS signal, SAS signal, YRS signal etc.
84
On board and Off board Diagnosis
85
Diagnosis Protocols
Unified Diagnostic Services (UDS)
86
Diagnosis Protocols
Emissions-related diagnostics (emissions-related OBD)
87
Diagnosis Protocols
ECU(server) – Tester(client) communication
88
Request and response
Overview
Positive response Negative Response
90
Request and response
Overview
0x00 .. 0x0F 0x40 .. 0x4F OBD in ISO 15031-5 Emissions-related diagnostic services
Others Reverse
91
Request and response
Negative response
92
Diagnosis mode
➔ Reprogramming mode
93
Addressing
Functional Address:
Physical Address:
94
Definitions
Milestones
1969: Volkswagen introduces the first on-board computer system with
scanning capability, in their fuel-injected Type 3 models.
1975: Datsun 280Z On-board computers begin appearing on consumer
vehicles, largely motivated by their need for real-time tuning of fuel
injection systems. Simple OBD implementations appear, though there is
no standardization in what is monitored or how it is reported.
1980: General Motors implements a proprietary interface and protocol
for testing of the Engine Control Module (ECM) on the vehicle assembly
line. The 'assembly line diagnostic link' (ALDL) protocol communicates
at 160 baud with Pulse-width modulation (PWM) signalling and monitors
very few vehicle systems.
95
Definitions
Milestones
1986: An upgraded version of the ALDL protocol appears which
communicates at 8192 baud with half-duplex UART signalling. This
protocol is defined in GM XDE-5024B.
~1987: The California Air Resources Board (CARB) requires that all
new vehicles sold in California starting in manufacturer's year 1988
(MY1988) have some basic OBD capability. These requirements are
generally referred to as "OBD-I", though this name is not applied until
the introduction of OBD-II. The data link connector and its position are
not standardized, nor is the data protocol.
1988: The Society of Automotive Engineers (SAE) recommends a
standardized diagnostic connector and set of diagnostic test signals.
96
Definitions
Milestones
~1994: Motivated by a desire for a state-wide emissions testing
program, the CARB issues the OBD-II specification and mandates that it
be adopted for all cars sold in California starting in model year 1996.
The DTCs and connector suggested by the SAE are incorporated into
this specification.
1996: The OBD-II specification is made mandatory for all cars sold in
the United States.
2001: The European Union makes EOBD mandatory for all gasoline
(petrol) vehicles sold in the European Union, starting in MY2001 (see
European emission standards Directive 98/69/EC)).
97
UNIFIED
DIAGNOSTIC
SERVICES
Agenda
1. Overview
1. UDS
2. Diagnostic Communication Protocol
3. Related ISO Standards
2. UDS In General
1. Application Layer
2. Session Layer
3. UDS In CAN Implementation
99
Overview
UDS
(U)nified (D)iagnostic (S)ervices is a diagnostic communication protocol
Use cases:
Detect faults in the system
Read vehicle parameters
Configuration/Calibration ECUs
End Of Line Routine
Reprogramming
100
Overview
Protocol
101
Overview
Related ISO Standards
Derived and distributed based on OSI model
102
UDS in General
Application Layer – Services
Also referred to as Diagnostic Services
At client side: used to request certain diagnostic functions
At server side: used to send response data back to client
6 service primitives are specified
Service request primitive
Service request-confirmation primitive
Service indication primitive
Service response primitive
Service response-confirmation primitive
Service confirmation primitive
103
UDS in General
Application Layer – Request Format
Application Layer Protocol Data Unit (A_PDU)
104
UDS in General
Application Layer – Response Format
Application Layer Protocol Data Unit (A_PDU)
105
UDS in General
Application Layer – Service ID List
106
UDS in General
Application Layer – Common NRC List
Value Response Code Value Response Code
0x00 positiveResponse 0x10 generalReject
0x11 serviceNotSupported 0x12 subFunctionNotSupported
0x13 incorrectMessageLengthOrInvalidFormat 0x21 busyRepeatRequest
0x22 conditionNotCorrect 0x24 requestSequenceError
0x31 requestOutOfRange 0x33 securityAccessDenied
0x35 invalidKey 0x36 exceedNumberOfAttempts
0x37 requiredTimeDelayNotExpired 0x72 generalProgrammingFailure
0x78 responsePending 0x7E subFunctionNotSupportedInActiveSession
0x7F serviceNotSupportedInActiveSession 0x83 engineIsRunning
0x88 vehicleSpeedTooHight 0x93 voltageTooLow
107
UDS in General
Application Layer –
Server Response
Implementation Rules
General server response behavior upon
receiving a request from client
108
UDS in General
Application Layer –
Server Response
Implementation Rules
General server response behavior upon receiving a
request with sub-function is given in the picture
109
UDS in General
Application Layer – List Of Standardized Services
SID Service Name SID Service Name
Diagnostic & Communication Management
0x10 Diagnostic Session Control 0x11 ECU Reset
0x27 Security Access 0x28 Communication Control
0x3E Tester Present 0x83 Access Timing Parameter
0x84 Secured Data Transmission 0x85 DTC Control Setting
0x86 Response On Event 0x87 Link Control
Data Transmission
0x22 Read Data By Identifier 0x2E Write Data By Identifier
0x23 Read Memory By Address 0x3D Write Memory By Address
0x23 Read Scaling Data By Identifier 0x2C Dynamically Defined Data Identifier
0x2A Read Data By Periodic Identifier
110
UDS in General
Application Layer – List Of Standardized Services
SID Service Name SID Service Name
Stored Data Transmission
0x14 Clear Diagnostic Information 0x19 Read DTC Information
Input Output Control
0x2F Input Output Control By Identifier
Routine
0x31 Routine Control
Upload Download
0x34 Request Download 0x35 Request Upload
0x36 Transfer Data 0x37 Exit Transfer
111
UDS in General
Application Layer – Service $10 – Overview
System starts with default session at power up. Other sessions must be
requested with service $10 to start
112
UDS in General
Application Layer – Service $10 – Request Format
113
UDS in General
Application Layer – Service $10 – Positive Response Format
114
UDS in General
Application Layer – Service $27 - Overview
Client Server
Service $27 – Security Access
115
UDS in General
Application Layer – Service $27 - Overview
Security Level
Security Level 1 2 3 … n …
Seed-related sub-function 1 3 5 … 2n-1 …
Key-related sub-function 2 4 6 … 2n …
116
UDS in General
Application Layer – Service $27 – Request Format
Security Access
Data Record
(optional):
information about
the seed
117
UDS in General
Application Layer – Service $27 – Response Format
118
UDS in General
Application Layer – Service $22/$2E – Overview
Service $22 – Read Data by Identifier
Service $2E – Write Data by Identifier
DID along with referred data length and format are pre-defined by user
119
UDS in General
Application Layer – Service $22/$2E – Request Format
120
UDS in General
Application Layer – Service $22/$2E – Response Format
For multiple DIDs read request, data
is provided in the response along with
the respective DID
121
UDS in General
Session Layer - Services
E.g.: transmission/reception of data, setting of protocol parameters
Primitives: request, indication, confirm
122
UDS in General
Session Layer – Timing
Parameter – P2, P2*, P4
123
UDS in CAN Implementation
Application Layer
SID Service Name SID Service Name
Diagnostic & Communication Management
0x10 Diagnostic Session Control 0x11 ECU Reset
0x27 Security Access 0x28 Communication Control
0x3E Tester Present 0x83 Access Timing Parameter
0x84 Secured Data Transmission 0x85 DTC Control Setting
0x86 Response On Event 0x87 Link Control
Data Transmission
0x22 Read Data By Identifier 0x2E Write Data By Identifier
0x23 Read Memory By Address 0x3D Write Memory By Address
0x23 Read Scaling Data By Identifier 0x2C Dynamically Defined Data Identifier
0x2A Read Data By Periodic Identifier
124
UDS in CAN Implementation
Application Layer
SID Service Name SID Service Name
Stored Data Transmission
0x14 Clear Diagnostic Information 0x19 Read DTC Information
Input Output Control
0x2F Input Output Control By Identifier
Routine
0x31 Routine Control
Upload Download
0x34 Request Download 0x35 Request Upload
0x36 Transfer Data 0x37 Exit Transfer
125
126
DIAGNOSTIC
COMMUNICATION
OVER CAN
Agenda
1. Overview
1. Diagnostic over any protocol
2. OSI encapsulation model
2. Diagnostic over CAN
1. Problem
2. Single-frame transmission
3. Multi-frame transmission
4. N_PDU definition
5. Timing parameters
128
Overview
Diagnostic Over Any Protocol
Diagnostic communication protocols (like UDS) cover the
upper layers (5, 6, 7)
129
Overview
OSI Encapsulation Model
Layer header is included in the data before
passing to the adjacent lower layer
130
Overview
OSI Encapsulation Model
Terminology:
SDU – Service Data Unit (payload)
PCI – Protocol Control Information (header)
PDU – Protocol Data Unit
Note:
Nth-PCU is added by Nth-layer of sender, then removed by Nth-layer of receiver
Not always all 7 layers are present, processing data or adding header
For the rest of this document, PDU provided by network layer are denoted as N_PDU, similarly for N_PCI and
N_SDU
131
Diagnostic Over CAN
Problem - Overview
Requirement: ECU must be able to provide Vehicle Identification
Number (VIN) via a diagnostic read service
Example
Tester: 22 F1 90
ECU: 62 F1 90 31 48 47 42 48 34 31 58 4A 4D 4E 31 30 39 31 38 36
(ASCII translation: 1HGBH41XJMN109186)
Problem:
VIN according to automotive standard are 17-byte long
UDS protocol requires 3 more bytes to specify for the service
CAN protocol only allows 8 bytes in the data field at max
132
Diagnostic Over CAN
Problem – VIN Format
133
Diagnostic Over CAN
Problem – CAN Frame Format
CRC ACK
Arbitration Field Control Field Data Field
Field Field
SOF
EOF
Byte Byte Byte Byte Byte Byte Byte Byte Byte
Identifier RTR Res DLC Deli Ack Deli
#1 #2 #3 #4 #5 #6 #7 #8 #1
0 10 9 8 7 6 5 4 3 2 1 0 0 5 4 3 2 1 0 7-0 7-0 7-0 7-0 7-0 7-0 7-0 7-0 7-0 0 1 0 6 54 3 2 1 0
134
Diagnostic Over CAN
Single-frame Transmission
Data can be fitted in single CAN
frame
No segmentation is needed
135
Diagnostic Over CAN
Multi-frame Transmission
Data doesn’t fit a single CAN frame
136
Diagnostic Over CAN Tester ECU
N_PDU Definition – Single Frame
Arbitration Field Control Field Data Field
CRC
Field
ACK
Field
SF: 03 22 F1 90
SOF
EOF
Byte Byte Byte Byte Byte Byte Byte Byte Byte
Identifier RTR Res DLC Deli Ack Deli
#1 #2 #3 #4 #5 #6 #7 #8 #1
0 10 9 8 7 6 5 4 3 2 1 0 0 5 4 3 2 1 0 7-0 7-0 7-0 7-0 7-0 7-0 7-0 7-0 7-0 0 1 0 6 54 3 2 1 0
N_PDU
N_PCI N_SDU
Byte Byte Byte Byte Byte Byte Byte
Byte #1
#2 #3 #4 #5 #6 #7 #8
7-4 3-0
7-0 7-0 7-0 7-0 7-0 7-0 7-0
FT DL
0 3 22 F1 90 x x x x
137
Diagnostic Over CAN Tester ECU
N_PDU Definition – First Frame
Arbitration Field Control Field Data Field
CRC
Field
ACK
Field
SF: 03 22 F1 90
SOF
EOF
Byte Byte Byte Byte Byte Byte Byte Byte Byte
Identifier RTR Res DLC Deli Ack Deli
#1 #2 #3 #4 #5 #6 #7 #8 #1
0 10 9 8 7 6 5 4 3 2 1 0 0 5 4 3 2 1 0 7-0 7-0 7-0 7-0 7-0 7-0 7-0 7-0 7-0 0 1 0 6 54 3 2 1 0
FF: 10 14 62 F1 90 31 48 47
N_PDU
N_PCI N_SDU
Byte Byte Byte Byte Byte Byte
Byte #1 Byte #2 #3 #4 #5 #6 #7 #8
7-4 3-0 7-4 3-0
7-0 7-0 7-0 7-0 7-0 7-0
FT DL
1 0 1 4 62 F1 90 31 48 47
138
Diagnostic Over CAN FT: Frame Type: 0x3 for Flow Control
N_PDU Definition – Flow Control
Arbitration Field Control Field Data Field
CRC
Field
ACK
Field
FS: Flow State
SOF
EOF
Identifier RTR Res DLC
Byte Byte Byte Byte Byte Byte Byte Byte Byte
Deli Ack Deli 0x0: CTS – continue to send
#1 #2 #3 #4 #5 #6 #7 #8 #1
0 10 9 8 7 6 5 4 3 2 1 0 0 5 4 3 2 1 0 7-0 7-0 7-0 7-0 7-0 7-0 7-0 7-0 7-0 0 1 0 6 54 3 2 1 0 0x1: WT – wait
0x2: OVFLW – overflow
N_PDU
N_PCI N_SDU
Byte Byte Byte Byte Byte Byte Byte
BS: Block Size
Byte #1
#2 #3 #4 #5 #6 #7 #8 0x00: no more FC needed
7-4 3-0 7-0 7-0 7-0 7-0 7-0 7-0 7-0
0x01..0xFF: max number of CFs can be
ST
FT FS BS
min
N/A N/A N/A N/A N/A sent until the next FC
3 0 00 00 x x x x x
139
Diagnostic Over CAN Tester ECU
N_PDU Definition – Flow Control
Arbitration Field Control Field Data Field
CRC
Field
ACK
Field
SF: 03 22 F1 90
SOF
EOF
Byte Byte Byte Byte Byte Byte Byte Byte Byte
Identifier RTR Res DLC Deli Ack Deli
#1 #2 #3 #4 #5 #6 #7 #8 #1
0 10 9 8 7 6 5 4 3 2 1 0 0 5 4 3 2 1 0 7-0 7-0 7-0 7-0 7-0 7-0 7-0 7-0 7-0 0 1 0 6 54 3 2 1 0
FF: 10 14 62 F1 90 31 48 47
N_PDU
N_PCI N_SDU
Byte Byte Byte Byte Byte Byte Byte FC: 30 00 00
Byte #1
#2 #3 #4 #5 #6 #7 #8
7-4 3-0 7-0 7-0 7-0 7-0 7-0 7-0 7-0
ST
FT FS BS N/A N/A N/A N/A N/A
min
3 0 00 00 x x x x x
140
Diagnostic Over CAN Tester ECU
N_PDU Definition – Consecutive Frame
Arbitration Field Control Field Data Field
CRC
Field
ACK
Field
SF: 03 22 F1 90
SOF
EOF
Byte Byte Byte Byte Byte Byte Byte Byte Byte
Identifier RTR Res DLC Deli Ack Deli
#1 #2 #3 #4 #5 #6 #7 #8 #1
0 10 9 8 7 6 5 4 3 2 1 0 0 5 4 3 2 1 0 7-0 7-0 7-0 7-0 7-0 7-0 7-0 7-0 7-0 0 1 0 6 54 3 2 1 0
FF: 10 14 62 F1 90 31 48 47
N_PDU
N_PCI N_SDU
Byte Byte Byte Byte Byte Byte Byte FC: 30 00 00
Byte #1
#2 #3 #4 #5 #6 #7 #8
7-4 3-0
7-0 7-0 7-0 7-0 7-0 7-0 7-0
FT SN CF: 21 42 48 34 31 58 4A 4D
2 1 42 48 34 31 58 4A 4D
2 2 4E 31 30 39 31 38 36
STmin CF: 22 4E 31 30 39 31 38 36
FT: Frame Type: 0x2 for Consecutive Frame
SN: Sequence Number, initial 0x1, range 0x0..0xF
141
Diagnostic Over CAN
N_PDU Definition - Summary
N_PDU
Byte Byte Byte Byte Byte Byte Byte
Byte #1
#2 #3 #4 #5 #6 #7 #8
7-4 3-0 7-0 7-0 7-0 7-0 7-0 7-0 7-0
Single Frame 0 DL Data
First Frame 1 DL Data
Consecutive Frame 2 SN Data
Flow Control 3 FS BS Stmin N/A
N_PCI
N_SDU
142
Diagnostic Over CAN Receiver Sender
Timing Parameters
Timing SF
Timeou Performance
Paramet Description
t (ms) (ms)
N_Ar
er
Time for transmission of the
N_As CAN frame (any N_PDU) on 1000 N/A FF
the sender side N_As
Time for transmission of the
N_Ar CAN frame (any N_PDU) on 1000 N/A N_Br
the receiver side FC N_Bs
Time until reception of the
N_Ar
N_Bs 1000 N/A
next FC N_PDU N_Cs
N_Br
Time until transmission of the
N/A
(N_Br + N_Ar) N_Cr CF
next FC N_PDU < (0.9 * N_Bs) N_As
Time until transmission of the (N_Cs + N_As)
N_Cs N/A < (0.9 * N_Cr) N_Cs
next CF N_PDU
N_Cr CF
Time until reception of the
N_Cr
next CF N_PDU
1000 N/A N_As
143
Thank you!
14
4