ebook img

Understanding and Using the Controller Area Network Communication Protocol: Theory and Practice PDF

239 Pages·2012·12.131 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Understanding and Using the Controller Area Network Communication Protocol: Theory and Practice

Understanding and Using the Controller Area Network Communication Protocol Marco Di Natale • Haibo Zeng (cid:129) Paolo Giusto Arkadeb Ghosal Understanding and Using the Controller Area Network Communication Protocol Theory and Practice 123 MarcoDiNatale HaiboZeng ScuolaSuperioreS.Anna McGillUniversity RETISLab. Montreal,Quebec,CanadaH3A2A7 Pisa56124,Italy ArkadebGhosal PaoloGiusto NationalInstruments GeneralMotorsCorporation Berkeley,CA94704,USA PaloAlto,CA94306,USA ISBN978-1-4614-0313-5 e-ISBN978-1-4614-0314-2 DOI10.1007/978-1-4614-0314-2 SpringerNewYorkDordrechtHeidelbergLondon LibraryofCongressControlNumber:2011944254 ©SpringerScience+BusinessMedia,LLC2012 Allrightsreserved.Thisworkmaynotbetranslatedorcopiedinwholeorinpartwithoutthewritten permission of the publisher (Springer Science+Business Media, LLC, 233 Spring Street, New York, NY10013, USA),except forbrief excerpts inconnection with reviews orscholarly analysis. Usein connectionwithanyformofinformationstorageandretrieval,electronicadaptation,computersoftware, orbysimilarordissimilarmethodologynowknownorhereafterdevelopedisforbidden. Theuseinthispublicationoftradenames,trademarks,servicemarks,andsimilarterms,eveniftheyare notidentifiedassuch,isnottobetakenasanexpressionofopinionastowhetherornottheyaresubject toproprietaryrights. Printedonacid-freepaper SpringerispartofSpringerScience+BusinessMedia(www.springer.com) Preface This book is the result of several years of study and practical experience in the design and analysis of communication systems based on the Controller Area Network (CAN) standard. CAN is a multicast-based communication protocol characterizedbythedeterministicresolutionofthecontention,lowcost,andsimple implementation.TheCAN [16]wasdevelopedinthemid1980sbyBoschGmbH, toprovideacost-effectivecommunicationsbusforautomotiveapplications.Today itiswidelyusedalsoinfactoryandplantcontrols,inrobotics,medicaldevices,and alsoinsomeavionicssystems. ControllerAreaNetworkisabroadcastdigitalbusdesignedtooperateatspeeds from 20kbit/s to 1Mbit/s, standardized as ISO/DIS 11898 [6] for high speed applications(500kbit/s)and ISO 11519-2 [7] for lowerspeed applications(upto 125kbit/s).Thetransmissionratedependsonthebuslengthandtransceiverspeed. CAN is an attractive solution for embedded control systems because of its low cost,lightprotocolmanagement,thedeterministicresolutionofthecontention,and the built-in featuresfor error detection and retransmission. Controllerssupporting the CAN communication standard, as well as sensors and actuators that are manufacturedforcommunicatingdataoverCAN,aretodaywidelyavailable.CAN networksaresuccessfullyreplacingpoint-to-pointconnectionsinmanyapplication domains. Commercial and open source implementation of CAN drivers and middleware softwareistodayavailablefromseveralsources,andsupportforCAN is included in automotive standards, including OSEKCom and AUTOSAR. The standard has been developed with the objective of time determinism and support for reliable communication. With respect to these properties, it has been widely studied by academiaandindustry,andmethodsand toolshave beendevelopedforpredicting thetimeandreliabilitycharacteristicsofmessages. The CAN standard has originally been proposed for application to automotive systems, but with time emerged as a quite appropriate solution for other control systems as well. This book tries a general approach to the subject, but in many placesitreferstoautomotivestandardsandsystems.Automotivearchitecturesand functionsare also often used as examples and benchmarks. We hope this is not a v vi Preface problemforthereaderandhopefully,thegeneralizationoftheproposedapproaches andmethodstootherdomainsshouldnotbetoohard.Ontheotherside,automotive systems are today an extremely interesting context for whoever is interested in complex and distributed embedded systems (including of course those using the CAN bus). They offer complex architectures with multiple buses and nodes with gateways,realtimeandreliabilityconstraintsandallthechallengesthatcomewith ahighbusutilizationandthedemandforincreasedfunctionalcomplexity. Thisbookattemptsatprovidinganencompassingviewonthestudyanduseof theCANbus,withreferencestotheoryandanalysismethods,andadescriptionof theissuesinthepracticalimplementationofthecommunicationstackforCANand theimplicationsofdesignchoicesatalllevels,fromtheselectionofthecontroller, toSW developmentandarchitecturedesign.We believesuchanapproachmaybe of advantage to those interested in the use of CAN, from students of embedded system courses, to researchers, architecture designers, system developers, and all practitionersthatareinterestedinthedeploymentanduseofaCANnetworkandits nodes. As such, the book attempts at covering all aspects of the design and analysis of a CAN communication system. Chapter 1 contains a short summary of the standard,withemphasisonthebusaccessprotocolandontheprotocolfeaturesthat are related to or affect the reliability of the communication. Chapter 2 describes the functionality, the design, the implementation options, and the management policies of the hardware controllers and software layers in CAN communication architectures. Chapter 3 focuses on the worst case time analysis of the message responsetimesorlatencies.Chapters4and5presentsthestochasticandstatistical timing analyses. Chapter 6 addresses reliability issues. Chapter 7 deals with the analysis of message traces. Chapter 8 describescommercialtools for configuring, analyzing and calibrating a CAN communication system. Chapter 9 contains a summaryofthemaintransportlevelandapplication-levelprotocolsthatarebased onCAN. Pisa,Italy MarcoDiNatale Montreal,QC,Canada HaiboZeng PaloAlto,CA,USA PaoloGiusto Berkeley,CA,USA ArkadebGhosal Contents 1 TheCAN2.0bStandard..................................................... 1 1.1 PhysicalLayer........................................................... 2 1.1.1 BitTiming....................................................... 2 1.1.2 Transceivers,NetworkTopologyandBusLength ............ 6 1.1.3 PhysicalEncodingofDominantandRecessiveStates........ 10 1.1.4 Connectors...................................................... 10 1.1.5 ThePhysicalLayerinISOandSAEStandards............... 11 1.2 MessageFrameFormats................................................ 13 1.2.1 DATAFrame.................................................... 14 1.2.2 RemoteFrame .................................................. 17 1.2.3 ErrorFrame ..................................................... 17 1.2.4 OverloadFrame................................................. 17 1.3 BusArbitration.......................................................... 17 1.4 MessageReceptionandFiltering....................................... 19 1.5 ErrorManagement...................................................... 20 1.5.1 CRCChecks .................................................... 20 1.5.2 Acknowledgement.............................................. 21 1.5.3 ErrorTypes...................................................... 21 1.5.4 ErrorSignalling................................................. 21 1.5.5 FaultConfinement.............................................. 22 2 ReferenceArchitectureofaCAN-BasedSystem......................... 25 2.1 CANControllerandBusAdapter...................................... 27 2.2 CANDeviceDrivers.................................................... 29 2.2.1 Transmission.................................................... 29 2.2.2 Reception........................................................ 31 2.2.3 Bus-OffandSleepModes...................................... 32 2.3 InteractionLayer........................................................ 32 2.3.1 DirectTransmissionMode ..................................... 35 2.3.2 PeriodicTransmissionMode................................... 36 2.3.3 MixedTransmissionMode..................................... 37 vii viii Contents 2.3.4 DeadlineMonitoring............................................ 38 2.3.5 MessageFiltering............................................... 38 2.4 ImplementationIssues.................................................. 38 2.4.1 DriverLayer..................................................... 39 2.4.2 InteractionLayer................................................ 41 3 Worst-CaseTimeAnalysisofCANMessages............................. 43 3.1 IdealBehaviorandWorst-CaseResponse-TimeAnalysis............ 45 3.2 AnalysisFlawandCorrection.......................................... 48 3.3 AnalysisofMessageSystemsWithOffsets ........................... 50 3.4 MessageBufferingInsidethePeripheral .............................. 51 3.5 AnIdealImplementation ............................................... 52 3.6 SourcesofPriorityInversion:WhentheAnalysisFails............... 57 3.6.1 MessageQueueNotSortedbyPriority........................ 57 3.6.2 MessagesSentbyIndexoftheCorrespondingTxObject..... 57 3.6.3 ImpossibilityofPreemptingtheTxObjects ................... 58 3.6.4 Polling-BasedOutput........................................... 60 3.7 FromtheTimingAnalysisofMessagestoEnd-to-End Response-TimesAnalysis .............................................. 62 3.8 Conclusions ............................................................. 65 4 StochasticAnalysis........................................................... 67 4.1 Introduction ............................................................. 67 4.2 ReferenceWork......................................................... 69 4.3 SystemModelandNotation............................................ 71 4.4 StochasticAnalysisofMessageResponse-Times..................... 72 4.4.1 AModelingAbstractionforCANMessages.................. 72 4.4.2 StochasticAnalysisoftheApproximateSystem.............. 77 4.5 AnalysisonanExampleAutomotiveSystem ......................... 84 5 StatisticalAnalysis........................................................... 89 5.1 Introduction ............................................................. 89 5.2 DerivingandFittingtheModel......................................... 90 5.2.1 CommonCharacteristicsofMessageResponse-Times....... 91 5.2.2 FittingtheMessageResponse-Times.......................... 93 5.3 EstimateoftheDistributionParameters ............................... 98 5.3.1 Parametersxoffandy........................................... 98 5.3.2 ParametersyD andy(cid:2) ......................................... 98 5.3.3 ParametersaandboftheGammaDistribution............... 100 5.4 PredictingMessageResponse-Times .................................. 108 5.4.1 PredictionofResponse-TimecdfsforMessages ontheReferenceBus........................................... 110 5.4.2 PredictionofResponse-TimecdfsforMessages onOtherBuses.................................................. 112 5.5 ComparisonofStochasticandStatisticalAnalyses ................... 117 5.5.1 InputInformation............................................... 117 Contents ix 5.5.2 AnalysisAccuracy.............................................. 118 5.5.3 AnalysisComplexity ........................................... 119 6 ReliabilityAnalysisofCAN................................................. 121 6.1 ErrorRatesinCAN..................................................... 122 6.2 DeviationPointsintheStandard....................................... 124 6.2.1 IncorrectValuesintheDLCField ............................. 124 6.2.2 DominantSRRBitValue....................................... 125 6.3 FaultConfinementandTransitiontoBusOff ......................... 125 6.4 InconsistentOmissionsorDuplicateMessages ....................... 126 6.5 ProtocolVulnerability .................................................. 128 6.6 BusTopologyIssues.................................................... 131 6.7 BabblingIdiotFaultsandBusGuardians.............................. 132 7 AnalysisofCANMessageTraces .......................................... 133 7.1 Notation ................................................................. 134 7.2 CaseStudies............................................................. 134 7.3 TraceAnalysis........................................................... 135 7.3.1 IdentificationofReferenceMessages.......................... 136 7.3.2 BaseRateMessage ............................................. 137 7.3.3 Reconstructionofthe TrueMessage Periods andArrivalTimes............................................... 137 7.3.4 QueuingJitterBecauseofTxTaskSchedulingDelays........ 139 7.3.5 ClockDriftsandActualMessagePeriods..................... 139 7.3.6 Finding the Message Phase with Respect totheBaseRateMessage ...................................... 141 7.4 AnalysisofAutomotiveCaseStudies.................................. 142 7.4.1 Overwrite Error at the Destination Node forMessage0x1F3inV ....................................... 144 1 7.4.2 AperiodicMessageTransmission.............................. 148 7.4.3 LocalPriorityInversion ........................................ 148 7.4.4 RemotePriorityInversion...................................... 152 7.4.5 MessageLossatSourceNode ................................. 153 7.4.6 ReconstructionofMessage-to-ECURelation inaHybridVehicle ............................................. 155 8 CANTools .................................................................... 157 8.1 SystemConfiguration................................................... 158 8.2 SystemAnalysis......................................................... 160 8.2.1 NetworkBusSimulationandRest-BusSimulation........... 160 8.2.2 TrafficLoggingandAnalysis .................................. 167 8.2.3 NetworkBusWorst/BestCaseAnalysis....................... 169 8.3 ProtocolStackImplementationandConfiguration.................... 175 8.3.1 CANDriverDevelopmentandIntegration.................... 175 8.4 ProtocolStack/ApplicationCalibration................................ 178 x Contents 9 Higher-LevelProtocols...................................................... 181 9.1 J1939 .................................................................... 181 9.1.1 PhysicalLayer .................................................. 182 9.1.2 ParametersandParameterGroups............................. 183 9.1.3 ProtocolDataUnits(PDUs).................................... 185 9.1.4 TransportProtocol.............................................. 186 9.1.5 NetworkManagement.......................................... 188 9.2 CANopen................................................................ 190 9.2.1 CANopenArchitectureandStandards......................... 190 9.2.2 PhysicalLevel................................................... 190 9.2.3 ObjectDictionary............................................... 192 9.2.4 TimeServices................................................... 195 9.2.5 CommunicationProtocols...................................... 197 9.2.6 Service-OrientedCommunicationandSDO .................. 197 9.2.7 MessageIdentifierAllocation.................................. 203 9.2.8 NetworkManagement.......................................... 204 9.3 CCP...................................................................... 206 9.3.1 ProtocolDefinition ............................................. 206 9.3.2 CommandReceiveObject...................................... 207 9.3.3 DataTransmissionObject...................................... 208 9.3.4 ListofCCPCommands ........................................ 208 9.3.5 ListofPacketIDsandCommandReturnCodes.............. 210 9.4 TTCAN.................................................................. 210 9.4.1 MotivationandGoal............................................ 211 9.4.2 SynchronizationMechanismsinTTCAN ..................... 211 9.4.3 SchedulingofTTCANNetworks.............................. 212 9.4.4 ReliabilityofTTCANandAdditionalNotes.................. 214 Symbols ........................................................................... 215 References......................................................................... 217 Index............................................................................... 221

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.