Can
-
Upload
ravi-biradar -
Category
Documents
-
view
19 -
download
3
Transcript of Can
CANController Area Network
29BIT ID
Timothy E. Jackson
Overview and Application
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
Arbitration Field Control Field Data Field
12 bits 6 bits 0 to 64 bits
SOF
Identifier
11bits
RTR
IDE
r0
DLC
4bitsData Field
CRC
15bits
ACK
Field
2bits
EOF
7bits
Bit StuffingNo 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
Standard Format, 2.0A
Max frame length with bit stuffing = 127 bits
CRC delimiter
1 bit
CAN Frame
Arbitration Field Control Field Data Field
32 bits 6 bits 0 to 64 bits
SOF
Identifier
11bitsSRR IDE
Identifier Ext.
18bitsRTR r1 r2
DLC
4bitsData Field
CRC
15bits
ACK
Field
2bits
EOF
7bits
Bit StuffingNo 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
Extended Format, 2.0B
Max frame length with bit stuffing = 150 bits
CRC delimiter
1 bit
CAN Frame
Arbitration Field Control Field Data Field
32 bits 6 bits 0 to 64 bits
SOF
Identifier
11bitsSRR IDE
Identifier Ext.
18bitsRTR r1 r2
DLC
4bitsData Field
CRC
15bits
ACK
Field
2bits
EOF
7bits
CRC delimiter
1 bit
CAN Frame
29 Bit Identifier DLC DATA FIELD
29 bits 4bits 0 to 8 bytes
PRI PGN SA
PRI= Priority 3 bits
PGN = Parameter Group Number, 18 bits
SA = Source Address, 8 bits
Message Structure
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
Application Layer
Data Link Layer
Physical Layer
Layer 7
Layer 2
Layer 1
Presentation Layer
Session Layer
Transport Layer
Layer 6
Layer 5
Layer 4
Layer 3 Network Layer
SAE J1939/11
SAE J1939/12
SAE J1939/21
SAE J1939/31
SAE J1939/21
SAE J1939/71
SAE J1939/73
ISO Layers Used In EAMCS
Application Layer
Data Link Layer
Physical Layer
Layer 7
Layer 2
Layer 1
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.
Physical Layer
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 B(UQM Inverter)Node A
(EAMCS)
120Ω 120Ω
Example MSCAN TimingSAE J1939/11 requires a bitrate, R 250kbps
Using the ADAPT9S12 from Technological Arts,XTAL 16MHz
If PLL is used, always select the oscillator clock
fCANCLK XTAL
Pick Tq 16
Use the equation below to solve for the Prescale Value
bitratePrescaleValue
fCANCLKTq
250kbpsPrescaleValue
16MHz16 Tq
PrescaleValue 4
Cont. Example MSCAN Timing
16Tq = SYNC_SEG + PropagationDelaySeg + TimeSeg1 + TimeSeg2
SYNC_SEG = 1Tq
PropagationDelaySeg = 2Tq (Determined by bus characteristics)
Pick, TimeSeg2 = 5Tq
TimeSeg1 = 8Tq
This gives a SJW range 0…3 so, I picked 2
Once values are determined, then apply to MSCAN registers
29 Bit ID
PRI PGN SA
28…26 25 24 23…16 15…8 7…0
PRI r DP PF DA/GE SA
PRI= Priority 3 bits
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
Data Link Layer SAE J1939/21
Example: EAMCS
29 Bit ID
PRI r DP PDU Dest. Addr Source Addr
28…26 25 24 23…16 15…8 7…0
0x06
0x040 0 0xEF 0x02 0x01
Message sent to UQM Inverter
Priority
Defined by SAE
Reserved for future
use
Defined by SAE
PDU
Defined by SAE
DA
Defined by User
SA
Defined by User
Application LayerSAE 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
• Data Page: 0
• PDU format: 239
• PDU specific: DA
• Default Priority: 4
Byte Definitions
1 Command 0x10
2,3 Actual Speed
4 Torque
5 Voltage
6 Current
7,8 System Error
Cont. Example: Parameter Group DefinitionByte Definitions
1 Command 0x10
2,3 Actual Speed
4 Torque
5 Voltage
6 Current
7,8 System Error
Command Actual Speed Torque Voltage Current System Error
Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7 Byte 8
Definitions
Data Field
Cont. Example: Parameter Group Decoding Using MSCAN (The Easy Way)
Command
Actual Speed (MSB)
Actual Speed (LSB)
Torque
Voltage
Current
System Error (MSB)
System Error (LSB)
CANRXFG[4]
Define a structtypedef struct{ INT8U command; INT16U actual_speed; INT8U torque; INT8U voltage; INT8U current; INT16U system_error; }ELEC_DRIVE_STATE;
ELEC_DRIVE_STATE elec_drive_data;
Create an Instance
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 */
D
a
t
a
F
i
e
l
d
ReferencesMotorola 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