CAN通讯协议介绍_第1页
CAN通讯协议介绍_第2页
CAN通讯协议介绍_第3页
CAN通讯协议介绍_第4页
CAN通讯协议介绍_第5页
已阅读5页,还剩50页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

会计学1CAN通讯协议介绍2Agenda

Part1:LearnthehighlevelCANfeatures

Part2:UnderstandtheCANmessage

Part3:UnderstandhowmessagesarecommunicatedbetweenCANnodes第1页/共62页3Part1:

TheBigPicture第2页/共62页4WhatisCAN?Standsfor:Controller–AreaNetwork

DevelopmentoftheCAN-busstartedoriginallyin1983atRobertBoschGmbH

Theprotocolwasofficiallyreleasedin1986attheSocietyofAutomotiveEngineers(SAE)congressinDetroit第3页/共62页5CANKeyFeaturesSpeedupto1MbpsNon-destructivemessagearbitrationAllnodesreceiveallmessagesNoguaranteedmessagelatency第4页/共62页6CostvsDataRateLINCANFlexRayMOST12510RelativecostpernodeDatarate[bps]20K1M10M25M第5页/共62页7CANvsLINCANismuchfaster:upto1MbpsLINoffersatimedeterministicmodelCANoffersamorepowerfulchecksumUsesLDFinsteadofDBCfilesfordatabases第6页/共62页8CANvsFlexRayFlexRaynetworkstartupmorecomplicatedFlexRayofferstimedeterministiccommunicationsFlexRayoffersfaulttoleranceusingvariousmechanismsFlexRayofferslargerdataframesUsesFIBEXinsteadofDBCfiles第7页/共62页9CANvsMOSTMOSTistargetedatinfotainmentapplicationsMOSToffersdedicatedtransfersinaringnetworkat25MbpsOptical,50MbCopper,and150Mbpsopticalphysicallayers第8页/共62页10CANHardwareFeaturesModeratecostsiliconimplementationRequireshardwareCANcontrollerandCANtransceiverRequireshardwareCANtransceiverMicroprocessorCAN

TransceiverCANControllerCANHighCANLowGround第9页/共62页11Quiz11.CANguaranteesmessagelatency.

(TrueorFalse)‏2.CANrequireshardwarecontrollers.

(TrueorFalse)‏3.CANissimilartoLIN:bothhaveverydefinedmessagestructure.

(TrueorFalse)‏4.Whatisthemaximumnumberofbytes

canbeinaCANmessage?第10页/共62页12CANPhysicalLayersHighSpeedCAN:upto1MbpsLowSpeedFaultTolerantCAN:

upto125kbpsSingleWireCAN:upto83.3kbps第11页/共62页132.53.5V1.5tCANHighCANLowRecessiveDominantCANDualWirePhysicalLayers

第12页/共62页14CANNode1CANNode2CANNode3120Ohm120OhmCANDualWireTermination第13页/共62页15SingleWirePlusGroundTwo120OhmterminationresistorsBuslengthto40meters@1Mbps,Slower=longer.SWPhysicalLayer第14页/共62页16DW/LSFTPhysicalLayerTwistedPair(CANH/CANL)plusGroundTwo120OhmterminationresistorsBuslengthto40meters@1Mbps,Slower=>longer.第15页/共62页17CANSupportMultipleversionsofCANaresupportedinValueCANandneoVIFIRE:HighSpeedCAN,LSFTCAN,SingleWireCANVehicleSpyprovidesfullCANsupport:

CANmessageandsignaldecoding,

logging,CANnodesimulation第16页/共62页18Lab1:ObjectivesGetfamiliarwithIntrepidCAN/LINboardFindUSBpowerconnectorFindCANandneoVIpowerconnectorLocateLINandCANtransceiverson

theboardConnectUSBandpowercablesConnectneoVItotheboard第17页/共62页19IntrepidCAN/LINBoardTwoidenticalconnectedCANnodesPowerissuppliedthroughUSBCANconnectorsforneoVIandValueCANPowerconnectorforneoVI第18页/共62页20IntrepidBoardTwoCANtransceiverswithtestpointsTworesetbuttons第19页/共62页21Quiz21.CANbusrequiresterminationof1200Ohm

(TrueorFalse)‏2.CANrequiresthreelines:CANlow,CANHighandground

(TrueorFalse)‏3.SinglewireCANisingeneraltheslowestCANtype.

(TrueorFalse)‏第20页/共62页22Part2:

TheCANmessage第21页/共62页23CANDataFrameTypicalCANmessageiscalleddataframeNumberofdatabytes:0-8CANDataFrameProtocolOverheadDataBytesProtocolOverhead第22页/共62页24CANFrameFieldsArbitrationfieldrepresentsframeIDControlfieldhasdefinesframelengthCRCstandsforCyclicRedundancyCheck:

thisisCANframechecksumACKisacknowledgefield:confirmsframereceptionCANDataFrameDataBytesArbitrationFieldControl

FieldCRCACK第23页/共62页25ArbitrationFieldIdentifierassigns11bitIDtoCANframesRemoteTransmitRequest(RTR)bitCANnodesendsCANframewithrecessiveRTRbit(logical1)whenthenoderequestsdatafrom

othernodesDataBytesControl

FieldIdentifierRTR111ArbitrationFieldCRCACK第24页/共62页26CANRemoteFrameIdenticaltotheDataFrame,except

thereisnodatabytesRTRbitisrecessive(logical1)‏Control

FieldCRCACKArbitrationField第25页/共62页27ControlFieldDLCspecifiesnumberofdatabytes:0-8RB0bitissettological0andreservedforthefutureprotocolsIDEbitdefinesdataframetype:standardIDorextendedIDdataframeIDEbits:dominantforstandardandrecessiveforextendeddataframeDataBytesIdentifierIDEControlField114RB0DLCCRCACK第26页/共62页28ExtendedDataFrameSimilartostandarddataframeIdentifieris29bitslongIdentifierissplitintotwoparts:ID1andID2Data

BytesSRR1111181IDEID1CRCACKID2RTRArbitrationFieldControl

Field第27页/共62页29StandardandExtendedFramesDataBytesControl

FieldIdentifierRTR111CRCACKData

BytesSRR1111181IDEID1CRCACKID2RTRArbitrationFieldControl

FieldArbitrationField第28页/共62页30CRCFieldCRC:CyclicRedundancyCheckCRCiscalculatedandputonthebusbytransmittingnodeCRCiscomputedagainbythereceivingnode:ifitdoesnotmatch,thenanerrorframeissentandthedataframeissentagainbythetransmitter.CRCfieldis15bitlongandhas1bitdelimiterDelimiteralwaysshouldbelogical1DataBytesArbitrationFieldControl

FieldCRCACKDel第29页/共62页31ACKFieldACK:AcknowledgefieldIfCANnodereceivedthemessagecorrectlyitshouldsetACKbitasdominantbit(logical0)AtleastonereceivershouldsetACKtodominantbit.Ifnot,anerrorframeifgeneratedand

thetransmitterresendstheframeACKdelimiter:1bitalwaysshouldbelogical1DataBytesArbitrationFieldControl

FieldCRCACKDelDel第30页/共62页32Lab2:ObjectivesGetfamiliarwithWaveBPSsoftwareConnectedWaveBPStoIntrepidboardusingtheoscilloscopeRunWaveBPSandmonitorCANwaveformscomingfromtheboardIdentifyCANhighandCANlowlinesMeasureonebitlengthintimeandcomputecorrespondingCANbaudrate第31页/共62页33Quiz3Whatisthemaindifferencebetweenaremoteframeandadataframe?ControlfieldcontainsthenumberofCANdatabytes(TrueorFalse)‏3.WhatisthemaindifferencebetweenastandardandextendedCANframes?4.IfanodereceivedaCANframecorrectly,howwouldthisaffectACKfieldoftheframe?第32页/共62页34Part3:

Messagesendingandreceiving第33页/共62页35CANArbitrationAnynodecantransmitwhenbusisfreeMultiplenodetransmissionisresolvedbybitwisearbitrationusingIDfieldNondestructiveframearbitration第34页/共62页36CANArbitrationHigherpriorityframeswinarbitrationDataframeswinarbitrationoverremoteframesNodesalwaysmonitorthebusIfthereisadominantbitonthebus,andanodewantstosendarecessivebit,thenodelosesarbitration第35页/共62页371011001101110110010011LSBMSBNodewantstosendCANframewiththisID:OthernodeID:CANArbitrationExample第36页/共62页38StartandEndofFrameAlldataandremoteframeshavestartand

endwaveformsStartofframeis1dominantbitEndofframe(EOF)is7recessivebitsIntermissionfieldis3recessivebits:overloadframecanbesentduringthefirstintermissionbitCANDataorRemoteFrameStartBitEOFINTIdle

Bus第37页/共62页39OverloadFrameOverloadframeissentwhenreceiverrequires

adelay,orDominantbitwasdetectedduringintermissonAtmosttwooverloadframescanbegeneratedtodelaynextdataorremoteframeOverloadflagfromnodesis6bitshighOverloadframeSuperpositionofoverloadflagsfromnodes(6bitsdom.)‏Delimiter6-12bits8bitsHighEOF第38页/共62页40ErrorFrameErrorframeissentwhenanodedetects

errorconditiononthebusActiveErrorflagfromnodesis6bitshighErrorframeSuperpositionofoverloadflagsfromnodes(6bitsdom.)‏Delimiter6-12bits8bitsHighEOF第39页/共62页41ChecksumErrorCRCiscomputedbytransmitterandputonthebusReceivingnodecalculatesCRCandcomparesit

withCRCfieldIfCRCdoesnotmatch,errorframeisgeneratedandtransmitterresendsthemessageCANDataFrameDataBytesArbitrationFieldControl

FieldCRCACK第40页/共62页42AcknowledgeErrorAtleastonereceivermustsetACKbitdominantIfnot,anerrorframeisgeneratedandthetransmitterresendsthemessageDataBytesArbitrationFieldControl

FieldCRCDelACK第41页/共62页43FormErrorCondition:fixedformfieldshaveillegalbits:dominantbit(logical0)isdetectedinthedelimiters,EndofFrame(EOF)orinter-framespaceTransmitterthensenderrorframeandresendsthemessageCANDataorRemoteFrameEOFINTIdle

BusDelDel第42页/共62页44StuffErrorCondition:6consecutivebitsofthesamestateinnon-fixedformfieldsCANbitstuffingalgorithminsertsadditionalbitsintoCANframetomakesurethereisnomorethan5consecutivebitsofthesamelevelThetransmitterresendsthemessageCANDataFrameDataBytesArbitrationFieldControl

FieldCRCACK第43页/共62页45BitErrorCondition:transmittermonitorswhatitsendsanddetectsabitstateoppositetowhatitputonthebusExcludeArbitrationandACKfieldCANDataFrameDataBytesArbitrationFieldControl

FieldCRCACK第44页/共62页46FaultConfinement

Whathappenswhentransmitterdetectsanerrorandkeepssendingerrorframes?Endlessloopproblem:transmittersendsbadframeandthereceivererrorframesitSolution:nodefaultconfinement.ItmaintainsCANTXandRXerrorcounters,andisolatenodesfromthecommunicationaftercertainnumbersoferrors第45页/共62页47FaultConfinementStatesThreestatesErroractivenodes:takepartinthecommunicationandsenderroractiveflagswhenerrorsaredetectedErrorpassivenodes:takepartinthecommunicationbutcanonlysenderrorpassiveflagsAftertransmission,errorpassivenodessendadditional8recessivebitsafterintermissionfield–itiscalled“SuspendTransmission”fieldBusoffnodes:noinfluenceonthebus第46页/共62页FaultConfinementErrorCountersTEC:000REC:000ErrorActiveErrorActiveREC:001TEC:000REC:002TEC:001REC:003TEC:002REC:004TEC:004REC:010TEC:011REC:018TEC:026REC:029TEC:052REC:029TEC:097REC:031TEC:129REC:033TEC:185REC:042TEC:211REC:047TEC:233REC:051TEC:256ErrorCountersTEC:000REC:000REC:000TEC:000ErrorCountersTEC:000REC:000REC:001TEC:000REC:000TEC:000REC:001TEC:000REC:002TEC:000REC:001TEC:000REC:002TEC:0003ErrorStates:ErrorActive,ErrorPassive,BusOffCANNode1CANNode2CANNode3ErrorActiveErrorPassiveBUSOFF第47页/共62页49ReceiveErrorCounterIfreceiversendsanerrorframe:REC+1

Ifreceiverwasfirsttostartanerrorframe:

REC+8

IfreceivermonitorsaBITERRORwhilesendinganerrorframe:

REC+8

Aftersuccessfullyreceivingamessage:

REC-1

第48页/共62页50TransmitErrorCounterIftransmittersendsanerrorframe:TEC+8

IftransmittermonitorsaBITERRORwhilesendinganerrorframe:

TEC+8

Aftersuccessfullytransmittingamessage:

TEC-1

IfTECreaches127:

CannotsendErrorFrames,butcanTx/Rx第49页/共62页51Lab3:ObjectivesGetfamiliarwithVehicleSpysoftwareCreateamessagethatissentperiodicallyPutthatmessageintothe2ndnodeontheEVBFindourmessageamongstallthemessages第50页/共62页52Quiz4Overloadframeissentwhenreceiverrequiresadelay.

(TrueorFalse)‏2.Underwhatconditionsdoesaformerroroccur?3.Stuffbitsareinsertedonlyifthereare5consecutivebitsofthesamestateonthebus.

(TrueorFalse)‏第51页/共62页53CANArbitrationAnynodecantransmitwhenbusisfreeMultiplenodetransmissionisresolvedbybitwisearbitrationusingIDfieldNondestructiveframearbitration第52页/共62页54CANArbitrationHigherpriorityframeswinarbitrationDataframeswinarbitrationoverremoteframesNodesalwaysmonitorthebusIfthereisadominantbitonthebus,andanodewantstosendarecessivebit,thenodelosesarbitration第53页/共62页551011001101110110010011LSBMSBNodewantstosendCANframewiththisID:OthernodeID:CANArbitrationExampl

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论