00125e51c2910abdf4d7b330a3cb6784.ppt
- Количество слайдов: 80
Controller Area Network bus Department of Electrical Engineering, National Taiwan Ocean University 2/23/2016 Richard Kuo Assistant Professor www. ee. ntou. edu. tw
Outline Department of Electrical Engineering, National Taiwan Ocean University 12. Nu. Micro_CAN. ppt CAN bus introduction ► Exercises: CAN Bus Transmission ► Lab. smpl_CAN_Basic. Mode_Tx & Rx ► Lab. smpl_CAN_Normal. Mode_Tx & Rx ► Lab. Smpl_CAN_Basic. Mode_Keypad ► Project : Elevator Control OBD-II Introduction ► ISO 15765 ► SAE J 1979 www. ee. ntou. edu. tw
CAN Network Structure Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw MCU CAN 2. 0 controller CAN Transceiver CAN+ CAN-
CAN transceiver & waveform Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
CAN Bus Access & Arbitration Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw CSMA/CD and AMP Carrier Sense Multiple Access/Collision Detection and Arbitration by Message Priority
CAN Bit Coding & Bit Stuffing Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw Bit Coding : NRZ (Non-Return-To-Zero code) does not ensure enough edges for synchronization ► Stuff Bits are inserted after 5 consecutive bits of the same level ► Stuff Bits have the inverse level of the previous bit ► No deterministic encoding, frame length depends on transmitted data ► Number of consecutive bits with same polarity
CAN basic specification Department of Electrical Engineering, National Taiwan Ocean University ► ► ► ► ► www. ee. ntou. edu. tw Prioritization of messages Guarantee of latency times Configuration flexibility Multicast reception with time synchronization System wide data consistency Multimaster Error detection and signaling Automatic retransmission of corrupted messages as soon as the bus is idle again Distinction between temporary errors and permanent failures of nodes and autonomous switching off of defect nodes Reference : Bosch CAN 2. 0 specification
Layered Structure of CAN node Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw Application Layer Object Layer - Message Filtering Message and Status Handling Cortex-M 0 MCU Transfer Layer - Fault Confinement Error Detection and Signaling Message Validation Acknowledgement Arbitration Message Framing Transfer rate and Timing Physical Layer - Signal Level and Bit Representation Transmission Medium Reference : Bosch CAN 2. 0 specification CAN 2. 0 b Controller CAN Transceiver CAN Bus Line
ISO standard CAN protocol Department of Electrical Engineering, National Taiwan Ocean University ► www. ee. ntou. edu. tw ISO 11898 is a standard for high-speed CAN communication. – Formerly, both the data link and the physical layers were stipulated in ISO 11898. It was then separated into – ISO 11898 -1, the standard for only the data link layer and – ISO 11898 -2, the standard for only the physical layer. – On that occasion, several specifications were added to ISO 11898 -1. ► ISO 11519 is a standard for low-speed CAN communication for communication speeds up to 125 kbps.
Difference between ISO 11898 and ISO 11519 -2 Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
OSI Layer Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
CAN layers mapping to OSI reference layers Department of Electrical Engineering, National Taiwan Ocean University Reference : ISO 11898 -1: 2003 spec www. ee. ntou. edu. tw
CAN properties Department of Electrical Engineering, National Taiwan Ocean University ► Transfer www. ee. ntou. edu. tw rate: 1 Mbps max. ► Max. message length: 8 bytes ► Carrier Sense Multiple Access/Bitwise Arbitration (CSMA/BA) ► Fault tolerance: 15 bits CRC + ACK ► Media: twisted pair
Data Rate vs. Bus Length Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw Data Rate Length 1 Mbit/s 40 m 500 kbit/s 100 m 250 kbit/s 200 m 125 kbit/s 500 m 50 kbit/s 1 km 10 kbit/s 6 km
Frame format Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
Nu. Micro built-in Bosch CAN 2. 0 b controller Department of Electrical Engineering, National Taiwan Ocean University ► ► ► ► ► www. ee. ntou. edu. tw Support CAN protocol version 2. 0 part A and B Bit rate up to 1 M bit/s 32 Message Objects Each Message Object has its own identifier mask Programmable FIFO mode (concatenation of Message object) Maskable interrupt Disable Automatic Re-transmission mode for Time Triggered CAN application Programmable loop-back mode for self-test operation 16 -bit module interface to AMBA APB bus Support wake-up function
CAN controller block diagram Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw CAN Core Message RAM Registers Message Handler CAN_RX CAN_TX Module Interface CAN_WAKEUP 16 -bit APB CAN Interrupt
Nu-LB-NUC 140 connector for CAN Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw CAN 2. 0 b pin 6 CAN+, pin 8 CAN-
CAN transceiver circuit on Nu-LB-NUC 140 Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
LIN circuit on Nu-LB-NUC 140 Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
MCU_Init. h Department of Electrical Engineering, National Taiwan Ocean University //Define Clock source #define MCU_CLOCK_SOURCE_HXT // HXT, LXT, HIRC, LIRC #define MCU_CLOCK_SOURCE_LXT #define MCU_CLOCK_FREQUENCY 50000000 //Hz //Define MCU Interfaces #define MCU_INTERFACE_CAN #define PIN_CAN 0_RX_PD 6 #define PIN_CAN 0_TX_PD 7 #define MCU_INTERFACE_SPI 3 #define SPI 3_CLOCK_SOURCE_HCLK // HCLK, PLL #define PIN_SPI 3_SS 0_PD 8 #define PIN_SPI 3_SCLK_PD 9 #define PIN_SPI 3_MISO 0_PD 10 #define PIN_SPI 3_MOSI 0_PD 11 www. ee. ntou. edu. tw
CAN_Basic. Mode Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw Both boards running the same program with CAN connected RX received and display message (an incrementing number) TX keep sending standard ID 0 x 701 and data =“CAN nnnn” n is incrementing from 0 to 9999
CAN_Basic. Mode Department of Electrical Engineering, National Taiwan Ocean University // // smpl_CAN_Basic. Mode_Rx (without Message RAM) // // EVB : Nu-LB-NUC 140 // MCU : NUC 140 VE 3 CN // #include <stdio. h> #include "NUC 100 Series. h" #include "MCU_init. h" #include "SYS_init. h" #include "can. h" #include “LCD. h" #define CAN_SPEED 500000 // 500 Kbps #define CAN_MODE CAN_BASIC_MODE // BASIC, NORMAL #define CAN_MSG_NO 0 // 0~31 void CAN_Show. Msg(STR_CANMSG_T* Msg); STR_CANMSG_T r. Msg; //Declare a CAN message structure char Text[16]; volatile uint 16_t count =0; www. ee. ntou. edu. tw TX Type = Standard ID Id = 0 x 701 DLC = 8 (message byte count) DATA=“NUC 0000” RX Show. Message display Id & Data
CAN_Msg. Interrupt Department of Electrical Engineering, National Taiwan Ocean University // ISR to handle CAN interrupt event void CAN_Msg. Interrupt(CAN_T *t. CAN, uint 32_t u 32 IIDR) { if(u 32 IIDR == 1) { sprintf(Text, "Msg-0 INT "); print_Line(3, Text); CAN_Receive(t. CAN, 0, &r. Msg); CAN_Show. Msg(&r. Msg); } if(u 32 IIDR == 5 + 1) { sprintf(Text, "Msg-5 INT "); print_Line(3, Text); CAN_Receive(t. CAN, 5, &r. Msg); CAN_Show. Msg(&r. Msg); } if(u 32 IIDR == 31 + 1) { sprintf(Text, "Msg-31 INT "); print_Line(3, Text); CAN_Receive(t. CAN, 31, &r. Msg); CAN_Show. Msg(&r. Msg); } } www. ee. ntou. edu. tw
CAN 0_IRQHandler Department of Electrical Engineering, National Taiwan Ocean University // CAN 0 interrupt handler void CAN 0_IRQHandler(void) { uint 32_t u 8 IIDRstatus; u 8 IIDRstatus = CAN 0 ->IIDR; if(u 8 IIDRstatus == 0 x 00008000) { // Check Status Interrupt Flag (Error status Int and Status change Int) */ if(CAN 0 ->STATUS & CAN_STATUS_RXOK_Msk) { // check CAN RX status CAN 0 ->STATUS &= ~CAN_STATUS_RXOK_Msk; // clear Rx. OK status sprintf(Text, "Rx. OK INT "); print_Line(3, Text); } if(CAN 0 ->STATUS & CAN_STATUS_TXOK_Msk) { // check CAN TX status CAN 0 ->STATUS &= ~CAN_STATUS_TXOK_Msk; // clear Tx. OK status sprintf(Text, "Tx. OK INT "); print_Line(3, Text); } www. ee. ntou. edu. tw if(CAN 0 ->STATUS & CAN_STATUS_EWARN_Msk) { // check CAN Error status sprintf(Text, "EWARN INT "); print_Line(3, Text); } if(CAN 0 ->STATUS & CAN_STATUS_BOFF_Msk) { // check CAN Bus Off sprintf(Text, "BOFF INT "); print_Line(3, Text); } } else if(u 8 IIDRstatus != 0) { sprintf(Text, "Int Ptr=%d", CAN 0 ->IIDR - 1); print_Line(3, Text); CAN_Msg. Interrupt(CAN 0, u 8 IIDRstatus); CAN_CLR_INT_PENDING_BIT(CAN 0, ((CAN 0 ->IIDR) - 1)); // Clear Interrupt Pending } else if(CAN 0 ->WU_STATUS == 1) { sprintf(Text, "Wake up!!! "); print_Line(3, Text); CAN 0 ->WU_STATUS = 0; // Write '0' to clear } }
CAN_Show. Msg Department of Electrical Engineering, National Taiwan Ocean University // Show Message Function void CAN_Show. Msg(STR_CANMSG_T* Msg) { uint 8_t i; sprintf(Text, "ID =0 x%X", Msg->Id); print_Line(0, Text); sprintf(Text, "Type=%s", Msg->Id. Type ? "EXT" : "STD"); print_Line(1, Text); for(i = 0; i < Msg->DLC; i++) sprintf(Text+i, "%c", Msg>Data[i]); print_Line(2, Text); } www. ee. ntou. edu. tw // Reset message interface parameters void CAN_Reset. IF(CAN_T *t. CAN, uint 8_t u 8 IF_Num) { if(u 8 IF_Num > 1) return; t. CAN->IF[u 8 IF_Num]. CREQ = 0 x 0; // set bit 15 for sending t. CAN->IF[u 8 IF_Num]. CMASK = 0 x 0; t. CAN->IF[u 8 IF_Num]. MASK 1 = 0 x 0; // useless in basic mode t. CAN->IF[u 8 IF_Num]. MASK 2 = 0 x 0; // useless in basic mode t. CAN->IF[u 8 IF_Num]. ARB 1 = 0 x 0; // ID 15~0 t. CAN->IF[u 8 IF_Num]. ARB 2 = 0 x 0; // Msg. Val, e. Xt, xmt, ID 28~16 t. CAN->IF[u 8 IF_Num]. MCON = 0 x 0; // DLC t. CAN->IF[u 8 IF_Num]. DAT_A 1 = 0 x 0; // data 0, 1 t. CAN->IF[u 8 IF_Num]. DAT_A 2 = 0 x 0; // data 2, 3 t. CAN->IF[u 8 IF_Num]. DAT_B 1 = 0 x 0; // data 4, 5 t. CAN->IF[u 8 IF_Num]. DAT_B 2 = 0 x 0; // data 6, 7 }
Init_CAN Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw void Init_CAN(void) { int 32_t i 32 Err = 0; GPIO_Set. Mode(PB, 12, GPIO_MODE_OUTPUT); // CAN Transceiver setting PB 12=0; CAN_Open(CAN 0, CAN_SPEED, CAN_MODE); // CAN Frequency = 500 KHz if(i 32 Err < 0) sprintf(Text, "CAN FAIL TO SET"); else sprintf(Text, "CAN=%7 d bps", CAN_SPEED); print_Line(0, Text); // Enable CAN interrupt CAN_Enable. Int(CAN 0, CAN_CON_IE_Msk | CAN_CON_SIE_Msk); // Set Interrupt Priority NVIC_Set. Priority(CAN 0_IRQn, (1 << __NVIC_PRIO_BITS) - 2); // Enable External Interrupt NVIC_Enable. IRQ(CAN 0_IRQn); }
CAN_Tx() & CAN_Rx() Department of Electrical Engineering, National Taiwan Ocean University void CAN_Tx(void) { STR_CANMSG_T msg 1; // declare a CAN message structure msg 1. Frame. Type = CAN_DATA_FRAME; msg 1. Id. Type = CAN_STD_ID; // CAN_EXT_ID msg 1. Id = 0 x 701; // 0 x 7755 msg 1. DLC = 8; // Data Length Count = 8 bytes msg 1. Data[0] = 'C'; msg 1. Data[1] = 'A'; msg 1. Data[2] = 'N'; msg 1. Data[3] = ' '; msg 1. Data[4] = 0 x 30+count/1000; msg 1. Data[5] = 0 x 30+count%1000/100; msg 1. Data[6] = 0 x 30+count%1000%100/10; msg 1. Data[7] = 0 x 30+count%1000%10; count++; if (count>9999) count=0; CAN_Transmit(CAN 0, CAN_MSG_NO, &msg 1); //Send CAN message CLK_Sys. Tick. Delay(100000); } www. ee. ntou. edu. tw void CAN_Rx(void) { while(CAN_Receive(CAN 0, CAN_MSG_NO, &r. Msg)== FALSE); CAN_Show. Msg(&r. Msg); }
main() of TX/RX Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw int main(void) { SYS_Init(); init_LCD(); clear_LCD(); Init_CAN(); while(1) { CAN_Tx(); } CAN_Close(CAN 0); // Disable CAN_Stop(); // Disable CAN Clock and Reset it while(1) { CAN_Rx(); } CAN_Close(CAN 0); // Disable CAN_Stop(); // Disable CAN Clock and Reset it } }
CAN_Normal. Mode Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw Both boards running the same program with CAN connected RX received and display message (an incrementing number) TX keep sending standard ID 0 x 701 and data =“CAN nnnn” n is incrementing from 0 to 9999
CAN_Normal. Mode Department of Electrical Engineering, National Taiwan Ocean University // // smpl_CAN_Basic. Mode_Rx (with Message RAM) // // EVB : Nu-LB-NUC 140 // MCU : NUC 140 VE 3 CN // #include <stdio. h> #include "NUC 100 Series. h" #include "MCU_init. h" #include "SYS_init. h" #include "can. h" #include “LCD. h" #define CAN_SPEED 500000 // 500 Kbps #define CAN_MODE CAN_NORMAL_MODE // BASIC, NORMAL #define CAN_MSG_NO 0 // 0~31 void CAN_Show. Msg(STR_CANMSG_T* Msg); STR_CANMSG_T r. Msg; //Declare a CAN message structure char Text[16]; volatile uint 16_t count =0; www. ee. ntou. edu. tw TX Type = Standard ID Id = 0 x 701 DLC = 8 (message byte count) DATA=“NUC 0000” RX Show. Message display Id & Data
Same function calls as Basic. Mode Department of Electrical Engineering, National Taiwan Ocean University ► CAN_Msg. Interrupt ► CAN 0_IRQHandler ► CAN_Show. Msg ► CAN_Tx ► CAN_Rx www. ee. ntou. edu. tw
Init_CAN Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw void Init_CAN(void) { int 32_t i 32 Err = 0; GPIO_Set. Mode(PB, 12, GPIO_MODE_OUTPUT); // CAN Transceiver setting PB 12=0; CAN_Open(CAN 0, CAN_SPEED, CAN_MODE); // CAN Frequency = 500 KHz if(i 32 Err < 0) sprintf(Text, "CAN FAIL TO SET"); Interrupt is disable, else sprintf(Text, "CAN=%7 d bps", CAN_SPEED); because Tx will print_Line(0, Text); cause message // Enable CAN interrupt to itself // CAN_Enable. Int(CAN 0, CAN_CON_IE_Msk | CAN_CON_SIE_Msk); // Set Interrupt Priority // NVIC_Set. Priority(CAN 0_IRQn, (1 << __NVIC_PRIO_BITS) - 2); // Enable External Interrupt // NVIC_Enable. IRQ(CAN 0_IRQn); }
Elevator System Diagram Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
Emulated Elevator System Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw CAN bus Elevator Floor Elevator Control Printer Scanner (emulate Elevator) Elevator Cabinet Using NUC 140 CAN bus to communicate between floors!
Emulated Elevator System Department of Electrical Engineering, National Taiwan Ocean University CAN 2. 0 bus www. ee. ntou. edu. tw CAN 2. 0 bus
Elevator Control Functions Department of Electrical Engineering, National Taiwan Ocean University ► www. ee. ntou. edu. tw Elevator Cabinet – CAN_TX : Id = 0 x 700, Data[0] = requested floor_no – CAN_RX : display floor_no sent by ID=0 x 777 ► Elevator Floor – CAN_TX : Id = 0 x 700+floor_no, Data[0] = ‘U’ or ‘D’ or ‘-’ – CAN_RX : display floor_no sent by ID=0 x 777 ► Elevator Control – CAN_TX : Id = 0 x 777 – CAN_RX : see flow chart – Timer 0_IRQHandler : determine floor_no & direction every second and drive the motor Note: 3 sample codes modified from Smpl_CAN_Keypad
Elevator_Cabinet flowchart Department of Electrical Engineering, National Taiwan Ocean University CAN_TX CAN_Id = 0 x 700 www. ee. ntou. edu. tw CAN_RX CAN_Id==0 x 777 CAN_Data[0] = requested floor_no print floor_no on LCD return print floor_movement on LCD return
Elevator_Floor flowchart Department of Electrical Engineering, National Taiwan Ocean University CAN_TX CAN_Id = 0 x 700 + floor_no CAN_Data[0] = ‘U’ for Up ‘D’ for Down ‘-’ for No Move www. ee. ntou. edu. tw CAN_RX CAN_Id==0 x 777 print floor_no on LCD print floor_movement on LCD return
Elevator_Control CAN_RX flowchart Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw Elevator panel CAN_Id = 0 x 700 CAN_Data[0] = floor_no request Floor panel CAN_Id = 0 x 700 + floor_no CAN_Data[0] = Up/Down request CAN_RX Y CAN_Id==0 x 700 f = CAN_Id - 0 x 700 f = CAN_Data[0] - 0 x 30 Request[f]++ Request[f]+=10 If (floor_no<f) direction[f] = 1 else if (floor_no>f) direction[f] = -1 else direction[f] = 0 N If (CAN_Data[0]==‘U’) direction[f]=1 else if (CAM_Data[0]==‘D’) direction[f]=-1 else direction[f] = 0 return
Elevator_Control CAN_RX Department of Electrical Engineering, National Taiwan Ocean University void CAN_Show. Msg(STR_CANMSG_T* Msg) { int 8_t i, f; sprintf(TEXT 1+6, "%x", Msg->Id); print_Line(1, TEXT 1); for(i=0; i<Msg->DLC; i++) sprintf(TEXT 2+6+i, "%c", Msg->Data[i]); print_Line(2, TEXT 2); if (Msg->Id==0 x 700) { f = Msg->Data[0] - 0 x 30; request[f]+=10; if (floor_no<f) direction[f]=1; else if (floor_no>f) direction[f]=-1; else direction[f]=0; } else { f = Msg->Id - 0 x 700; request[f]++; if (Msg->Data[0]=='U') direction[f]=1; else if (Msg->Data[0]=='D') direction[f]=-1; else direction[f]=0; } } www. ee. ntou. edu. tw
Elevator_Control Timer 0 IRQ Handler Department of Electrical Engineering, National Taiwan Ocean University Timer 0_IRQHandler www. ee. ntou. edu. tw For (i=1; i<floor_no; i++) down_weigth += request[i]; For (i=floor_no+1; i<MAX_FLOOR+1; i++) up_weight += request[i] Up If (up_wt <>0) floor_dir = Up Else if (down_wt<>0) floor_dir = Down Else floor_dir = No_move floor_dir Down If (down_wt <>0) floor_dir = Down Else if (up_wt<>0) floor_dir = Up Else floor_dir = No_move If (down_wt >up_wt) floor_dir = Down Else if (up_wt<down_wt) floor_dir = Up Else if (up_wt==down_wt && up_wt<>0) floor_dir = no_move Else floor_dir = No_move floor_no = floor_no + floor_dir Elevator_move(floor_dir) request[floor_no<>0 && floor_dir N CAN_TX() return Y Elevator_open()
Elevator_Control IRQHandler Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw void TMR 0_IRQHandler(void) // Timer 0 interrupt subroutine { int 8_t i; int 16_t up_wt, down_wt; floor_no = floor_no + floor_dir; Elevator_move(floor_dir); if (request[floor_no]!=0 && floor_dir==0) Elevator_open(); up_wt = 0; down_wt = 0; for (i=1; i<floor_no; i++) down_wt = down_wt + request[i]; for (i=floor_no+1; i<(MAX_FLOOR+1); i++) up_wt = up_wt + request[i]; // To decicde motor moving direction if (floor_dir==1) { if (up_wt !=0) floor_dir=1; else if (down_wt!=0) floor_dir=-1; else floor_dir=0; } else if (floor_dir==-1) { if (down_wt!=0) floor_dir=-1; else if (up_wt !=0) floor_dir=1; else floor_dir=0; } else { if (down_wt!=0) floor_dir=-1; else if (up_wt !=0) floor_dir=1; else floor_dir=0; } CAN_TX(); // send counter value to CAN bus TIMER 0 ->TISR. TIF = 1; //Write 1 to clear for safty }
J 1939 Overview Department of Electrical Engineering, National Taiwan Ocean University ► ► ► www. ee. ntou. edu. tw J 1939 is based on CAN 2. 0 B Just as CAN is centered around the ID, J 1939 is centered around PGN is defined by the CAN ID. PGN: Parameter Group Number For example, PGN 65215 is “Wheel Speed Information”. Data comes in data field. Most PGNs are 8 bytes long. Multibyte variables are sent least significant byte first. Typically 0 x. FF means “data isn‟t available”, 0 x. FE means “error”. Valid range is 0 -250. Check MSB for multibyte variables.
CAN ID Mapping Department of Electrical Engineering, National Taiwan Ocean University ► ► ► www. ee. ntou. edu. tw P: Message priority. Must come first. EDP: Extended data page. J 1939 devices must set to 0. DP: Data page. Used to create a second page of PGNs. PF: PDU format: < 240, PS is destination address. (PDU 1 format) >= 240, PS is group extension. (PDU 2 format) PS: PDU specific. Either destination address or group extension. SA: Source address of controller application (CA).
J 1939 PGN Mapping Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw If PF < 240, then PGN = (DP << 9)+(PF<<8), else PGN = (DP << 9)+(PF<<8)+PS ► ► Max number of PGNs: (240 + (16 x 256)) x 2) = 8, 672
Example J 1939 PGN Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw ► Bytes 1 -2: Byte 3: Byte 4: Byte 5: Byte 6: Byte 7: J 1939 Wheel Speed Information 65215(0 x. FEBF) 6 (default) 8 100 ms SPN Front axle speed 904 Relative, front axle #1, left 905 Relative, front axle #1, right 906 Relative, rear axle #1, left 907 Relative, rear axle #1, right 908 Relative, rear axle #2, left 909 ► Byte 8: Relative, rear axle #2, right PGN: ► Priority: ► Length: ► TX Rate: ► ► ► 910
J 1939 Request PGN Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw ► PGN: 59904 (0 x. EA 00) ► Priority: 6 (default) ► Length: 3 ► Destination: Global or specific ► Bytes 1 -3: PGN which is being requested
J 1939 Proprietary A PGN Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw ► PGN: 61184(0 x. FEBF) ► Priority: 6 (default) ► Length: 0 to 1785 ► Destination: Specific ► Bytes ► 0 - 1785: Manufacture specific Usage should not exceed 2% of network utilization
J 1939 Proprietary B PGN Department of Electrical Engineering, National Taiwan Ocean University ► PGN: www. ee. ntou. edu. tw 65280 to 65535 (0 x. FF 00 to 0 x. FFFF)) ► Priority: 6 (default) ► Length: 0 to 1785 ► Destination: Global ► Bytes ► 0 - 1785: Manufacture specific Usage should not exceed 2% of network utilization
OBD-II connector in Vehicle Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
OBD-II (On-Board Diagnosis) Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
OBD-II protocols Department of Electrical Engineering, National Taiwan Ocean University ► www. ee. ntou. edu. tw ISO 15765 -4 (CAN bus) – – – Most modern protocol, mandatory for all 2008+ vehicles sold in US, use pin 6 & 14 ISO 15765 -4 CAN (11 bit ID, 500 Kbaud) ISO 15765 -4 CAN (29 bit ID, 500 Kbaud) ISO 15765 -4 CAN (11 bit ID, 250 Kbaud) ISO 15765 -4 CAN (29 bit ID, 250 Kbaud) ISO 14230 -4 (KWP 2000) – Common protocol for 2003+ vehicles using IOS 9141 K-Line (pin 7) ► SAE J 1850 VPW – Diagnostic bus used mostly on GM vehicles, use pin 1 comm speed 10. 4 k. B/sec ► SAE J 1850 PWM ► – Diagnostic bus used mostly on Ford vehicles, use pin 1 & 2, comm speed 41. 6 k. B/sec
OBD 2 to DB 9 Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
車輛診斷系統 (OBD-II) Department of Electrical Engineering, National Taiwan Ocean University ► Digimoto www. digimoto. com ► Easy. OBDII www. easyobdii. com ► PCMSCAN ► Pro. Scan http: //www. proscan. org/ ► Scan. Master-ELM http: //www. wgsoft. de/ ► Scan. Tool. net http: //www. scantool. net/ www. ee. ntou. edu. tw
OBD-II Simulator Department of Electrical Engineering, National Taiwan Ocean University ► ► ► www. ee. ntou. edu. tw 支援 ISO 15765 -4 (CAN 250/500 kbps, 11/29 bit) OBD-II 協定 具備符合 SAE J 1962 標準的 OBD-II 母頭 可模擬車輛引擎 ECU,產生符合 SAE J 1979 規範之 OBD-II 診斷資料數據,涵蓋車速、 引擎轉速、冷卻水水溫、含氧感知器電壓、節氣門位置. . . 等, 總數超過50種以上之 Live Data , Data 數值可由使用者自行設定 可模擬車輛引擎 ECU,產生符合 SAE J 2012 規範之 OBD-II 故障碼 (DTC) 資料數據, 涵蓋B類(車身)、C類(底盤)、P類(動力傳輸)、U類(車身網路)等OBD-II標準故障碼(DTC) 共 5000組以上,可模擬超過5000種的 DTC,包含 Stored DTC 與 Pending DTC 等 可模擬車輛ECU,執行SAE J 1979規範的Mode 01~Mode 04操作: – Mode 01: 目前OBD-II Live Data讀取 – Mode 02: 凍結OBD-II Data讀取 (每組DTC會產生一組凍結OBD-II Data,至少包含冷 卻水溫度、進氣壓力、點火正時提前、燃油控制狀態、節氣閥角度、引 擎計算負載值、引擎轉速、車速、 A/F修正補償量等) – Mode 03: 讀取Stored或是Pending DTC – Mode 04: 清除DTC OBD Live Data 及 DTC 之 PID 與定義內容可由軟體設定擴充
ISO 15765 Department of Electrical Engineering, National Taiwan Ocean University ► ISO 15765 -2 CAN Message Format ► ISO 15765 -3 UDS on CAN ► ISO 15765 -4 www. ee. ntou. edu. tw
CAN Message Frame Format Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
Protocol Control Information (PCI) Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
Protocol Control Information Types Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
Single Frame Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
First Frame Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
Consecutive Frame Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
Protocol Control Information – Flow Control Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
Protocol Control Information – Flow Control Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
CAN Message Frame Timing Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
CAN Message Frame Timing Parameters Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
Flow Control Requirement Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
Timeout Error Handling Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
Unified Diagnostic Services Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw ► https: //en. wikipedia. org/wiki/Unified_Diagnostic_Services ► UDS (Unified Diagnostic Service) is based on the standards KWP 2000 for K -Line and CAN
OSI protocols of the wireless diagnostic system Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
ISO 14229 – Diagnostic Service List Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw ISO 14299 is a set of standards specifying the implementation of UDS
Screenshot of the HMI on the diagnostic tester Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
Software Architecture Department of Electrical Engineering, National Taiwan Ocean University Software architecture of the diagnostic tester www. ee. ntou. edu. tw Software architecture of the on-vehicle ECU
The network architecture of self build electric vehicle Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
SAE J 1979 define 10 modes Department of Electrical Engineering, National Taiwan Ocean University ► ► ► www. ee. ntou. edu. tw 0 x 01. Show current data 0 x 02. Show freeze frame data 0 x 03. Show stored Diagnostic Trouble Codes 0 x 04. Clear Diagnostic Trouble Codes and stored values 0 x 05. Test results, oxygen sensor monitoring (non CAN only) 0 x 06. Test results, other component/system monitoring (Test results, oxygen sensor monitoring for CAN only) 0 x 07. Show pending Diagnostic Trouble Codes (detected during current or last driving cycle) 0 x 08. Control operation of on-board component/system 0 x 09. Request vehicle information 0 x 0 A. Permanent DTC's (Cleared DTC's) Vehicle manufactures are not required to support
SAE J 1979 standard PIDs Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw
SAE J 2012 Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw SAE J 2012 offer Diagnostic Trouble Code (DTC) and Failure Type Byte (FTB) ► SAE J 2012 was originally developed to meet U. S. OBD requirements for 1996 and later model year vehicles. ISO 15031 -6 was based on SAE J 1962 and was intended to meet European OBD requirements for 2000 and later model year vehicles. ► This document is technically equivalent to ISO 15031 -6, with new and revised fault codes included. ►
SAE J 1939 map to CAN frame Department of Electrical Engineering, National Taiwan Ocean University PGN www. ee. ntou. edu. tw
Important Notice ! Department of Electrical Engineering, National Taiwan Ocean University www. ee. ntou. edu. tw This educational material are neither intended nor warranted for usage in systems or equipment, any malfunction or failure of which may cause loss of human life, bodily injury or severe property damage. Such applications are deemed, “Insecure Usage”. ► Insecure usage includes, but is not limited to: equipment for surgical implementation, atomic energy control instruments, airplane or spaceship instruments, the control or operation of dynamic, brake or safety systems designed for vehicular use, traffic signal instruments, all types of safety devices, and other applications intended to support or sustain life. ► All Insecure Usage shall be made at user’s own risk, and in the event that third parties lay claims to the author as a result of customer’s Insecure Usage, the user shall indemnify the damages and liabilities thus incurred by using this material. ► Please note that all lecture and sample codes are subject to change without notice. All the trademarks of products and companies mentioned in this material belong to their respective owners. ►
00125e51c2910abdf4d7b330a3cb6784.ppt