《CAN通讯协议介绍.ppt》由会员分享,可在线阅读,更多相关《CAN通讯协议介绍.ppt(63页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、CAN Bus Hands-On CoursePresented by:Intrepid Control Systems,Inc.Qin WenSales EngineerTel:+86-137-6464-99561Objectives Learn the basics of the CAN protocol Understand what makes up a CAN network Understand what makes up a CAN node Learn how CAN compares to competitive protocols Learn how to use a CA
2、N test tool and a CAN Database(DBC)file to monitor and transmit CAN messages and signals2Agenda Part 1:Learn the high level CAN features Part 2:Understand the CAN message Part 3:Understand how messages are communicated between CAN nodes3What is CAN?Stands for:ControllerArea Network Development of th
3、e CAN-bus started originally in 1983 at Robert Bosch GmbH The protocol was officially released in 1986 at the Society of Automotive Engineers(SAE)congress in Detroit 5CAN Key FeaturesSpeed up to 1MbpsNon-destructive message arbitrationAll nodes receive all messagesNo guaranteed message latency6Cost
4、vs Data RateLINCANFlexRayMOST1 2 5 10Relative cost per nodeData rate bps20K1M10M25M7CAN vs LINCAN is much faster:up to 1 MbpsLIN offers a time deterministic modelCAN offers a more powerful checksumUses LDF instead of DBC files for databases8CAN vs FlexRayFlexRay network startup more complicatedFlexR
5、ay offers time deterministic communicationsFlexRay offers fault tolerance using various mechanismsFlexRay offers larger data framesUses FIBEX instead of DBC files9CAN vs MOSTMOST is targeted at infotainment applicationsMOST offers dedicated transfers in a ring network at 25 Mbps Optical,50 Mb Copper
6、,and 150 Mbps optical physical layers10CAN Hardware FeaturesModerate cost silicon implementationRequires hardware CAN controller and CAN transceiverRequires hardware CAN transceiverMicroprocessorCAN TransceiverCAN ControllerCAN High CAN Low Ground11Quiz 11.CAN guarantees message latency.(True or Fal
7、se)2.CAN requires hardware controllers.(True or False)3.CAN is similar to LIN:both have very defined message structure.(True or False)4.What is the maximum number of bytes can be in a CAN message?12CAN Physical Layers High Speed CAN:up to 1 MbpsLow Speed Fault Tolerant CAN:up to 125 kbpsSingle Wire
8、CAN:up to 83.3 kbps132.53.5V1.5tCAN HighCAN LowRecessiveDominantCAN Dual Wire Physical Layers 14CAN Node 1CAN Node 2CAN Node 3120 Ohm120 OhmCAN Dual Wire Termination15Single Wire Plus GroundTwo 120 Ohm termination resistorsBus length to 40 meters 1 Mbps,Slower=longer.SW Physical Layer 16DW/LSFT Phys
9、ical LayerTwisted Pair(CANH/CANL)plus GroundTwo 120 Ohm termination resistorsBus length to 40 meters 1 Mbps,Slower=longer.17CAN SupportMultiple versions of CAN are supported in Value CAN and neoVI FIRE:High Speed CAN,LSFT CAN,Single Wire CANVehicle Spy provides full CAN support:CAN message and signa
10、l decoding,logging,CAN node simulation18 Lab 1:ObjectivesGet familiar with Intrepid CAN/LIN boardFind USB power connectorFind CAN and neoVI power connectorLocate LIN and CAN transceivers on the boardConnect USB and power cablesConnect neoVI to the board19 Intrepid CAN/LIN BoardTwo identical connecte
11、d CAN nodesPower is supplied through USBCAN connectors for neoVI and ValueCANPower connector for neoVI20Intrepid BoardTwo CAN transceivers with test pointsTwo reset buttons21Quiz 21.CAN bus requires termination of 1200 Ohm(True or False)2.CAN requires three lines:CAN low,CAN High and ground(True or
12、False)3.Single wire CAN is in general the slowest CAN type.(True or False)22CAN Data FrameTypical CAN message is called data frameNumber of data bytes:0-8CAN Data FrameProtocol OverheadData BytesProtocol Overhead24CAN Frame FieldsArbitration field represents frame IDControl field has defines frame l
13、engthCRC stands for Cyclic Redundancy Check:this is CAN frame checksumACK is acknowledge field:confirms frame receptionCAN Data FrameData BytesArbitration FieldControlFieldCRCACK25Arbitration FieldIdentifier assigns 11 bit ID to CAN frames Remote Transmit Request(RTR)bitCAN node sends CAN frame with
14、 recessive RTR bit(logical 1)when the node requests data from other nodesData BytesControlFieldIdentifierRTR111Arbitration FieldCRCACK26CAN Remote FrameIdentical to the Data Frame,except there is no data bytesRTR bit is recessive(logical 1)ControlFieldCRCACKArbitration Field27Control FieldDLC specif
15、ies number of data bytes:0-8RB0 bit is set to logical 0 and reserved for the future protocols IDE bit defines data frame type:standard ID or extended ID data frameIDE bits:dominant for standard and recessive for extended data frameData BytesIdentifierIDEControl Field1 1 4RB0DLCCRCACK28Extended Data
16、FrameSimilar to standard data frameIdentifier is 29 bits longIdentifier is split into two parts:ID1 and ID2Data BytesSRR11 1 1 18 1IDEID1CRCACKID2RTRArbitration FieldControlField29Standard and Extended FramesData BytesControlFieldIdentifierRTR111CRCACKData BytesSRR11 1 1 18 1IDEID1CRCACKID2RTRArbitr
17、ation FieldControlFieldArbitration Field30CRC FieldCRC:Cyclic Redundancy CheckCRC is calculated and put on the bus by transmitting nodeCRC is computed again by the receiving node:if it does not match,then an error frame is sent and the data frame is sent again by the transmitter.CRC field is 15 bit
18、long and has 1 bit delimiterDelimiter always should be logical 1Data BytesArbitration FieldControlFieldCRCACKDel31ACK FieldACK:Acknowledge fieldIf CAN node received the message correctly it should set ACK bit as dominant bit(logical 0)At least one receiver should set ACK to dominant bit.If not,an er
19、ror frame if generated and the transmitter resends the frameACK delimiter:1 bit always should be logical 1Data BytesArbitration FieldControlFieldCRCACKDelDel32 Lab 2:ObjectivesGet familiar with WaveBPS softwareConnected WaveBPS to Intrepid board using the oscilloscopeRun WaveBPS and monitor CAN wave
20、forms coming from the boardIdentify CAN high and CAN low linesMeasure one bit length in time and compute corresponding CAN baudrate33Quiz 31.What is the main difference between a remote frame and a data frame?2.Control field contains the number of CAN data bytes(True or False)3.What is the main diff
21、erence between a standard and extended CAN frames?4.If a node received a CAN frame correctly,how would this affect ACK field of the frame?34CAN Arbitration Any node can transmit when bus is free Multiple node transmission is resolved by bitwise arbitration using ID field Non destructive frame arbitr
22、ation36CAN Arbitration Higher priority frames win arbitration Data frames win arbitration over remote frames Nodes always monitor the bus If there is a dominant bit on the bus,and a node wants to send a recessive bit,the node loses arbitration 371011001101110110010011LSBMSBNode wants to send CAN fra
23、me with this ID:Other node ID:CAN Arbitration Example38Start and End of FrameAll data and remote frames have start and end waveformsStart of frame is 1 dominant bit End of frame(EOF)is 7 recessive bitsIntermission field is 3 recessive bits:overload frame can be sent during the first intermission bit
24、CAN Data or Remote FrameStart BitEOF INTIdle Bus39Overload FrameOverload frame is sent when receiver requires a delay,orDominant bit was detected during intermissonAt most two overload frames can be generated to delay next data or remote frameOverload flag from nodes is 6 bits highOverload frameSupe
25、rposition of overload flags from nodes(6 bits dom.)Delimiter6-12 bits8 bits HighEOF40Error FrameError frame is sent when a node detects error condition on the busActive Error flag from nodes is 6 bits highError frameSuperposition of overload flags from nodes(6 bits dom.)Delimiter6-12 bits8 bits High
26、EOF41Checksum ErrorCRC is computed by transmitter and put on the busReceiving node calculates CRC and compares it with CRC fieldIf CRC does not match,error frame is generated and transmitter resends the messageCAN Data FrameData BytesArbitration FieldControlFieldCRCACK42Acknowledge Error At least on
27、e receiver must set ACK bit dominant If not,an error frame is generated and the transmitter resends the message Data BytesArbitration FieldControlFieldCRCDelACK43Form Error Condition:fixed form fields have illegal bits:dominant bit(logical 0)is detected in the delimiters,End of Frame(EOF)or inter-fr
28、ame space Transmitter then send error frame and resends the messageCAN Data or Remote FrameEOF INTIdle BusDelDel44Stuff Error Condition:6 consecutive bits of the same state in non-fixed form fields CAN bit stuffing algorithm inserts additional bits into CAN frame to make sure there is no more than 5
29、 consecutive bits of the same level The transmitter resends the messageCAN Data FrameData BytesArbitration FieldControlFieldCRCACK45Bit Error Condition:transmitter monitors what it sends and detects a bit state opposite to what it put on the bus Exclude Arbitration and ACK fieldCAN Data FrameData By
30、tesArbitration FieldControlFieldCRCACK46Fault Confinement What happens when transmitter detects an error and keeps sending error frames?Endless loop problem:transmitter sends bad frame and the receiver error frames it Solution:node fault confinement.It maintains CAN TX and RX error counters,and isol
31、ate nodes from the communication after certain numbers of errors47Fault Confinement States Three states Error active nodes:take part in the communication and send error active flags when errors are detected Error passive nodes:take part in the communication but can only send error passive flags Afte
32、r transmission,error passive nodes send additional 8 recessive bits after intermission field it is called“Suspend Transmission”field Bus off nodes:no influence on the bus48Fault ConfinementErrorCounters TEC:000 REC:000Error ActiveError Active REC:001 TEC:000 REC:002 TEC:001 REC:003 TEC:002 REC:004 T
33、EC:004 REC:010 TEC:011 REC:018 TEC:026 REC:029 TEC:052 REC:029 TEC:097 REC:031 TEC:129 REC:033 TEC:185 REC:042 TEC:211 REC:047 TEC:233 REC:051 TEC:256ErrorCountersTEC:000REC:000 REC:000 TEC:000ErrorCountersTEC:000REC:000 REC:001 TEC:000 REC:000 TEC:000 REC:001 TEC:000 REC:002 TEC:000 REC:001 TEC:000
34、 REC:002 TEC:000 3 Error States:Error Active,Error Passive,Bus OffCAN Node 1CAN Node 2CAN Node 3Error ActiveError PassiveBUS OFFReceive Error CounterIf receiver sends an error frame:REC+1If receiver was first to start an error frame:REC+8If receiver monitors a BIT ERROR while sending an error frame:
35、REC+8After successfully receiving a message:REC-150Transmit Error CounterIf transmitter sends an error frame:TEC+8If transmitter monitors a BIT ERROR while sending an error frame:TEC+8After successfully transmitting a message:TEC-1If TEC reaches 127:Cannot send Error Frames,but can Tx/Rx51 Lab 3:Obj
36、ectivesGet familiar with Vehicle Spy softwareCreate a message that is sent periodicallyPut that message into the 2nd node on the EVBFind our message amongst all the messages52Quiz 41.Overload frame is sent when receiver requires a delay.(True or False)2.Under what conditions does a form error occur?
37、3.Stuff bits are inserted only if there are 5 consecutive bits of the same state on the bus.(True or False)53CAN Bit Timing Issues All nodes must receive TX waveform“simultaneously”for arbitration Varying Delays for different nodes Resynchronization:no common clock between nodes57CAN Bit Timing Issu
38、es Each bit has four parts and the sampling point Each part of the bit consists of a number of time quantas Sample point at 70-80%of bitSYNC_SEGPROP_SEGPHASE_SEG1PHASE_SEG21 bit in CAN frameSample point58High Level Protocols Examples:Ford SCP is a HLP to J1850 and so is Class 2 CAN HLP:J1939,GMLAN a
39、re on top of CAN CAN HLP:CAN Calibration Protocol(CCP)CAN HLP:DeviceNet59DBC Files Industry standard DBC file format DBC files describe the structure for signals that CAN frames could contain Vehicle Spy supports DBC files for message decoding60Quiz 51.CAN frame arbitration takes into account frame ID and frame data bytes.(True of False)2.During CAN arbitration a dominant bit(logical 0)always wins arbitration vs a recessive bit(logical 1)(True or False)3.What is bit sampling point?Can we change it?62Thank you for your attentionQuestions?63
限制150内