0% found this document useful (0 votes)
138 views23 pages

CAN Network: 29-Bit ID Overview

This document discusses Controller Area Network (CAN) frames and their structure. It describes the key fields in a CAN frame, including the identifier, data length code, data field, and checksum fields. It also discusses CAN frame formats, bit stuffing, message priorities, and layers in the CAN protocol stack according to ISO and SAE J1939 standards. Finally, it provides an example of setting up CAN timing parameters and decoding application data from a CAN message using a struct in an automotive application.

Uploaded by

Ravi Biradar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
138 views23 pages

CAN Network: 29-Bit ID Overview

This document discusses Controller Area Network (CAN) frames and their structure. It describes the key fields in a CAN frame, including the identifier, data length code, data field, and checksum fields. It also discusses CAN frame formats, bit stuffing, message priorities, and layers in the CAN protocol stack according to ISO and SAE J1939 standards. Finally, it provides an example of setting up CAN timing parameters and decoding application data from a CAN message using a struct in an automotive application.

Uploaded by

Ravi Biradar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 23

CAN Controller Area Network 29BIT ID

Overview and Application

Timothy E. Jackson

CAN Frame

CAN Frame

IDENTIFIER

DLC

DATA FIELD
Identifier = 29 bits + MAC DLC = Data Length Code 4 bits Indicates number of data bytes Data Field = 0 to 7 bytes Depends on the DLC value

CAN Frame
Standard Format, 2.0A Max frame length with bit stuffing = 127 bits
Arbitration Field Control Field Data Field
CRC delimiter 1 bit

12 bits
S O F Identifier 11bits R T R I D E

6 bits
r 0 DLC 4bits

0 to 64 bits
Data Field CRC 15bits ACK Field 2bits No Bit Stuffing EOF 7bits

Bit Stuffing

SOF = Start Of Frame RTR = Remote Transmission Request IDE = Identifier Extension Bit DLC = Data Length Code CRC = Cyclic Redundancy Check ACK = Acknowledgement EOF = End Of Frame

CAN Frame
Extended Format, 2.0B Max frame length with bit stuffing = 150 bits
Arbitration Field Control Field Data Field
CRC delimiter 1 bit

32 bits
S O F Identifier 11bits SRR IDE Identifier Ext. 18bits RTR r1

6 bits
r2 DLC 4bits

0 to 64 bits
Data Field CRC 15bits ACK Field 2bits No Bit Stuffing EOF 7bits

Bit Stuffing

SOF = Start Of Frame SRR = Substitute Remote Request IDE = Identifier Extension Bit RTR = Remote Transmission Request DLC = Data Length Code CRC = Cyclic Redundancy Check ACK = Acknowledgement EOF = End Of Frame

CAN Frame

CRC delimiter 1 bit

Arbitration Field

Control Field

Data Field

32 bits
S O F Identifier 11bits SRR IDE Identifier Ext. 18bits RTR r1

6 bits
r2 DLC 4bits

0 to 64 bits
Data Field CRC 15bits ACK Field 2bits EOF 7bits

CAN Frame
Message Structure 29 Bit Identifier 29 bits PRI PGN SA DLC 4bits DATA FIELD 0 to 8 bytes

PRI= Priority 3 bits PGN = Parameter Group Number, 18 bits SA = Source Address, 8 bits

How do I start using CAN right now?


SAE J1939
Defined by the automotive industry Standards defined for the Layers 1,2,3,4, and 7

ISO Layers according to SAE J1939


Layer 7 Layer 6 Layer 5 Layer 4 Layer 3 Layer 2 Layer 1

Application Layer Presentation Layer Session Layer Transport Layer

SAE J1939/71 SAE J1939/73

SAE J1939/21

Network Layer Data Link Layer


Physical Layer

SAE J1939/31

SAE J1939/21

SAE J1939/11 SAE J1939/12

ISO Layers Used In EAMCS


Layer 7

Application Layer

Layer 2

Data Link Layer Physical Layer

Layer 1

Physical Layer
SAE J1939/11 High Speed Bus Connection Differential signal transmission Shielded twisted pair bus lines and ground 250k bits/sec 30 nodes max. Bus length = 40m max. or 131 ft. max.

SAE J1939/12 Variant Bus Connection Bus constructed using active termination

For bus load = 1 (Using 29bit ID and 8 data bytes per frame, approx. 135bits/message) At a bitrate of 250kbps 1850 messages per second

Node A (EAMCS)

Node B (UQM Inverter)

120

120

Example MSCAN Timing


SAE J1939/11 re quire s a bitrateR 250kbps , Using the ADAPT9S12 from Technological Arts, AL 16MHz XT If PLL is used, always sele ct the oscillator clock
fCANCLK XT AL

Pick Tq 16 Use the equation be low to solv e for the Prescale Value
bit rat e PrescaleValue fCANCLK Tq

250kbps

PrescaleValue 16MHz

16Tq

PrescaleValue 4

Cont. Example MSCAN Timing


16Tq = SYNC_SEG + PropagationDelaySeg + TimeSeg1 + TimeSeg2

SYNC_SEG = 1Tq PropagationDelaySeg = 2Tq Pick, TimeSeg2 = 5Tq TimeSeg1 = 8Tq This gives a SJW range 03 so, I picked 2
(Determined by bus characteristics)

Once values are determined, then apply to MSCAN registers

Data Link Layer SAE J1939/21


29 Bit ID

PRI
2826 PRI 25 r 24 DP

PGN
2316 PF 158 DA/GE
PRI= Priority 3 bits

SA
70 SA

PGN = Parameter Group Number, 18 bits


r = Reserved Bit, always 0 or dominant DP = Data Page PF = PDU format, (Protocol Data Unit) DA = Destination Address

GE = Group Extension
SA = Source Address, 8 bits

Example: EAMCS
Message sent to UQM Inverter 29 Bit ID

PRI
2826 0x06 0x04

r
25 0

DP
24 0

PDU
2316 0xEF

Dest. Addr
158 0x02

Source Addr
70 0x01

Priority

Defined by SAE

Reserved for future use Defined by SAE

PDU

DA

SA

Defined by SAE

Defined by User

Defined by User

Application Layer SAE J1939/71


Defines the bytes in the data field

SAE HANDBOOK DATA

Example: Parameter Group Definition


Electric Drive State
Transmission Repetition Rate: 100ms Data Length: 8 bytes Byte Data Page: 0 PDU format: 239 1 PDU specific: DA 2,3 Default Priority: 4 4
5 6

Definitions Command 0x10

Actual Speed
Torque Voltage Current

7,8

System Error

Cont. Example: Parameter Group Definition


Byte 1 2,3 4 5 6 7,8 Actual Speed Torque Voltage Current System Error Definitions Command 0x10

Definitions
Command Byte 1 Actual Speed Byte 2 Byte 3 Torque Byte 4 Voltage Byte 5 Current Byte 6 System Error Byte 7 Byte 8

Data Field

Cont. Example: Parameter Group Decoding Using MSCAN


(The Easy Way)

Define a struct
typedef struct{ INT8U command; INT16U actual_speed; INT8U torque; INT8U voltage; INT8U current; INT16U system_error; }ELEC_DRIVE_STATE;

CANRXFG[4]

Command
Actual Speed (MSB) Actual Speed (LSB) Torque Voltage

D
a t a F i e l d

Create an Instance
ELEC_DRIVE_STATE elec_drive_data;

Current System Error (MSB) System Error (LSB)

Take advantage of Struct copying routines


elec_drive_data = *(ELEC_DRIVE_STATE*)(CANRXFG + 4);

Now access the data fields using the corresponding struct member outhexw(&elec_drive_data.actual_speed); /* Print the 16bit hex value */

References
Motorola Documentation
MSCAN Block Guide V02.14, S12MSCANV2.pdf

Bosch Documentation
CAN Specification Version 2.0, can2spec.pdf

Reference Texts
Konrad Etschberger,Controller Area Network. Weingarten, Germany: IXXAT Automation GmbH, 2001 1997 SAE Handbook, Volume 2 Parts and Components. Warrendale, PA: Society of Automotive Engineers, 1997

You might also like