CAN Controller Area Network docx

36 243 1
CAN Controller Area Network docx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

10/14/2012 CAN Controller Area Network 10/14/2012 10/14/2012 Gesellschaft mit beschränkter Haftung (abbreviated GmbH (most common), GesmbH or Ges.m.b.H.), German for "company with limited liability" Carrier Sense Multiple Access (CSMA) is a probabilistic Media Access Control (MAC) protocol in which a node verifies the absence of other traffic before transmitting on a shared transmission medium CAN uses a nondestructive bitwise arbitration, which means that messages remain intact after arbitration is completed even if collisions are detected All the arbitration takes place without corruption or delay of the message that wins the arbitration 10/14/2012 CAN Standards The Layered ISO 11898:1993 Standard Architecture CAN ISO Standardization: – ISO PRF 16845 : CAN Conformance Test Plan – ISO PRF 11898-1: CAN Transfer Layer – ISO PRF 11898-2: CAN High Speed Physical Layer – ISO DIS 11898-3: CAN Fault Tolerant Physical Layer – ISO DIS 11898-4: TTCAN Time Triggered CAN CAN bus Cables and Connectors Bus speed Cable type Cable resistance/m Terminator Bus Length 50 kbit/s at 1000 m 0.75 0.8 mm2 AWG18 70 mOhm 150 300 Ohm 600 1000 m 100 kbit/s at 500 m 0.5 0.6 mm2 AWG20 < 60 mOhm 150 300 Ohm 300 600 m 500 kbit/s at 100 m 0.34 0.6 mm2 AWG22, AWG20 < 40 mOhm 127 Ohm 40 300 m 1000 kbit/s at 40 m 0.25 0.34 mm2 AWG23, AWG22 < 26 mOhm 124 Ohm 40 m Pin Descri ption V- Black CAN_L Red CAN_H Green V+ Yellow Description Colour nc - V- Black CAN_L Red Colour Pin CAN_H Green V+ Yellow nc - Pin Description Color Drain Bare V+ Red V- Black CAN_H White CAN_L Blue 10/14/2012 CAN bus Cables and Connectors Shielded twisted pair Unshielded twisted pair Pin Signal CAN_L CAN_GND (CAN_SHLD) GND CAN_H (CAN_V+) Description Reserved CAN_L bus line dominant low CAN Ground Reserved Optional CAN Shield Optional Ground CAN_H bus line dominant high Reserved Optional CAN external supply ISO11898 NOMINAL BUS LEVELS 10/14/2012 CAN bus Nominal ISO 11992 Bus Levels CAN COMPARISON 10/14/2012 MCP2551 High-Speed CAN Transceiver Dual in-line package Small-outline integrated circuit AN228 MCP2510 Stand-Alone CAN Controller with SPI™ Interface BLOCK DIAGRAM TYPICAL SYSTEM IMPLEMENTATION 10/14/2012 10/14/2012 Collision Avoidance S R O Identifier T Control F 10 R Field Node (Tx) Node (Tx) Node (Tx) Node (Tx) Data Field Listening Mode Listening Mode DLC Data Listening Mode recessive Bus (4 x Rx) dominant 10/14/2012 CAN bus Bit-Stuffing Rule • One characteristic of Non-Return-to-Zero code is that the signal provides no edges that can be used for resynchronization if transmitting a large number of consecutive bits with the same polarity Therefore bit-stuffing is used to ensure synchronization of all bus nodes??? • This means that during the transmission of a message, a maximum of five consecutive bits may have the same polarity • The bit-stuff area in a CAN bus frame includes the SOF, Arbitration field, Control field, Data field and CRC field 10 10/14/2012 Cyclic Redundancy Check Arithmetic Modulo The addition rules are as follows: The subtraction table: 0-0=0 0-1=1 1-0=1 1-1=0 Find the sum of 10112 and 1102 modulo The multiplication table is equally simple: 0*0=0 0*1=1*0=0 1*1=1 Cyclic Redundancy Check Modulo division can be performed in a manner similar to arithmetic long division Subtract the denominator (the bottom number) from the leading parts of the enumerator (the top number) Proceed along the enumerator until its end is reached Remember that we are using modulo subtraction For example, we can divide 100100111 by 10011 as follows: 22 10/14/2012 CRC CRC The key used by the Ethernet is 0x04c11db7 It corresponds to the polynomial: x32 + x26 + + x2 + x + Data 1 0 With 16 bit CRC (detecting error) 216  65535   99.998% 216 65536 23 10/14/2012 24 10/14/2012 25 10/14/2012 26 10/14/2012 27 10/14/2012 28 10/14/2012 29 10/14/2012 30 10/14/2012 31 10/14/2012 32 10/14/2012 CAN Programming Given: • CPU oscillator frequency = 32 MHz • Bit rate = 800 Kbps • Prescaler = • Nominal bit time = 10 TQ • prop-seg = TQ • sync-seg = TQ • phase-segl = TQ • phase-seg2 = TQ • RJW = TQ • Oscillator tolerance = 0.78% Write a program to configure the CAN module with the given timing parameters, disable all interrupts, and set the ECAN module to receive all messages with standard identifiers 33 10/14/2012 #include org 0x00 goto start org 0x08 ; the interrupt vector addresses are at 0008h retfie ;Return from interrupt enable org 0x18 ;and 0018h retfie; start movlw 0x80 movwf CANCON, A ; Request Configuration mode conf_wait movf CANSTAT, W, A andlw 0x80 bz conf_wait ; if not configuration mode, branch clrf ECANCON,F,A ; select mode movlw 0x4 ; set RJW to 2, prescaler set to movwf BRGCON1,A movlw 0x8C ; take one sample, set phase-segl to and movwf BRGCON2,A ; set prop-seg to movlw 0x4 ;enable wakeup feature, set phase-seg2 to movwf BRGC0N3,A movlw 0x20 ;RXBO and RXBl receive any standard messages movff WREG,RXB0CON conf-w1 movff movlw movff movff movff movff clrf movf andlw bnz end WREG,RXB1CON 0x00 WREG,RXM0SIDH WREG,RXM0SIDL WREG,RXMlSIDH WREG,RXMlSIDL CANCON,A CANSTAT,W,A 0xE0 conf-w1 ; clear receive mask registers ; to receive all standard format messages ; set to normal mode ; read current mode state ;check bits 7-5 for current mode ; if not normal mode, branch 34 10/14/2012 35 10/14/2012 CAN Bus Interface Circuit RS232 interface circuit 36 ... 10/14/2012 CAN bus Cables and Connectors Shielded twisted pair Unshielded twisted pair Pin Signal CAN_ L CAN_ GND (CAN_ SHLD) GND CAN_ H (CAN_ V+) Description Reserved CAN_ L bus line dominant low CAN Ground... V- Black CAN_ L Red CAN_ H Green V+ Yellow Description Colour nc - V- Black CAN_ L Red Colour Pin CAN_ H Green V+ Yellow nc - Pin Description Color Drain Bare V+ Red V- Black CAN_ H White CAN_ L Blue... 10/14/2012 CAN Standards The Layered ISO 11898:1993 Standard Architecture CAN ISO Standardization: – ISO PRF 16845 : CAN Conformance Test Plan – ISO PRF 11898-1: CAN Transfer Layer – ISO PRF 11898-2: CAN

Ngày đăng: 18/03/2014, 06:20

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan