Prezentace se nahrává, počkejte prosím

Prezentace se nahrává, počkejte prosím

CAN Bus and its Applications in Vehicles J. Novák Czech Technical University in Prague Faculty of Electrical Engineering Dept. Of Measurement.

Podobné prezentace


Prezentace na téma: "CAN Bus and its Applications in Vehicles J. Novák Czech Technical University in Prague Faculty of Electrical Engineering Dept. Of Measurement."— Transkript prezentace:

1 CAN Bus and its Applications in Vehicles J. Novák Czech Technical University in Prague Faculty of Electrical Engineering Dept. Of Measurement

2 Distributed Systems in Vehicles n CAN n LIN n MOST n Byteflight n D2B n K-line n … n FlexRay

3 Application Areas of Distributed Systems in Vehicles – Power Train n Communicating units –engine, brake, gear, ABS/ESP –steering wheel position, steering booster –light control, damper … n High-speed and reliability are required –running only when the ignition is on –in future the technologies for X by wire will be applied n Today standards –CAN (high-speed) –Byteflight n Future: the FlexRay standard

4 Application Areas of Distributed Systems in Vehicles – Comfort Functions n Communicating units –seat position control, mirrors control, windows control –air condition, vehicle top, –tires pressure control, parking assistant –wiper control, door control … n Lower-speed is enough n Low-power mode is required –units wake-up by data transmission –running also when ignition is off n Today standards –CAN (low-speed) –LIN

5 Application Areas of Distributed Systems in Vehicles – Infotainment and Telematics n Communicating units –sound system, CD player, changer, tuner –TV set, mobile phone, navigation –inter-vehicle communication, traffic info reception … n Different communication speeds –low speed for control transfers –high speed for user data transfers (audio, video) n Low power mode required –unit wake-up by data communication –running if ignition is off n Today standards –CAN (low-speed) –MOST

6 Application Areas of Distributed Systems in Vehicles – Diagnostics n Communicating units –all (use their native interface) … n Different interfaces –today often so called K-line with diagnostics protocols –gateway unit often translates diagnostics protocols of particular ECUs –in future the wireless diagnostics is expected using bluetooth ??? … security is the issue

7 CAN and ISO-OSI Model n Physical layer –transmission line parameters, signaling levels, transmission speed, … n Link Layer = CAN –medium access control –frame coding and decoding –addressing –data security –error states behavior

8 n Application layer –defines the data content of link layers frames –defines when (under which conditions) the frames are transmitted –in automotive industry there are only company standards –standards do exist for diagnostics n Application protocols are defined e.g. in industrial automation field (CANopen) –effort to use them in vehicles too CAN and ISO-OSI Model

9 n Inter-layer communication –each protocol layer adds some information that allows the layer protocols to provide the required service for the layer above CAN and ISO-OSI Model

10 CAN – Physical Layer Requirements n The basic requirement for the physical layer is to provide so called wired OR functionality n Two basic signaling levels  recessive  dominant  available e.g. in fiber optics

11 CAN – Link Layer, MAC and LLC n MAC – Medium Access Control –provides the physical channel access for the units, prevents destructive collisions –provides priority transmission –implements the channel coding –provides the data security by means of CRC check –solves high error rate problem for particular nodes in network –provides mechanism for acknowledgement of correctly received frames n LLC – Logical Link Control –allows filtering of received frames –solves the overload condition

12 CAN – Communication Principle n All nodes within the systems are equal (from the communication point of view) – peer to peer n Frames, (sometimes called messages) are broadcasted into the network and received by all nodes simultaneously n There is no node oriented addressing –frame always starts with identifier, which must provide a unique frame content identification n In case the frame is received correctly by receiving nodes, the acknowledge is sent to the transmitting node n In case there is an error detected during the transmission, the error identification sequence is sent and frame has to be transmitted again

13 CAN – Medium Access Control n Any node can start transmitting only if the bus idle state is detected n In case that more than one node start transmitting simultaneously –there is no physical contention on the bus, as the dominant bit transmission „beats“ the recessive one n Each node receives back the transmitted bit value –if a node transmitting the recessive bit value receives back the dominant bus state, it stops transmitting immediately n This method is called CSMA/CR –Carrier Sense Multiple Access with Collision Resolution –sometimes it is also less correctly called CSMA/CA (…Collision Avoidance)

14 CAN – Medium Access Control n 3 nodes start transmitting simultaneously –Start of Frame (SOF) bit is always dominant –11 bits of identifier follow –identifier must be unique within the system

15 CAN – Frame Identifier n Identifies the frame content –It is not the sender nor the receiver address usually one node transmits frames with different identifiers each node receives frames with identifiers it is interested in –Identifier must be unique within the system two different nodes are not allowed to transmit frame with the same identifier (because of arbitration) In case the information source redundancy is required, identifiers usually differ in low significant bit –Identifier is transmitted from the most significant bit log. 0 is transmitted as a dominant state, log. 1 as a recessive the lower identifier value, the higher frame priority

16 CAN – Frame Format n Current standard version is CAN 2.0 –Bosch, 1990 –it defines only the link layer protocol –there are two parts (variants) A and B CAN2.0A is backward compatible with older CAN versions, it uses 11-bit identifier CAN2.0B defines two data frame types – standard and extended –standard frame offers 11-bit identifier –extended frame offers 29-bit identifier n Accepted as ISO standard –next standard parts define the physical layer protocols too

17 CAN – Frame Format n 4 frame types are defined –data frame used for data transfer variable length (0 – 8 data bytes) –remote request frame used to request the data frame with the same identifier it contains no data –error frame consists of six consequent dominant or recessive bits it is transmitted to indicate the error –overload frame the same format like the error frame nodes transmit it to delay the next data frame transmission

18 CAN 2.0A – Data Frame Format n bus idle – recessive state n SOF – start of frame n arbitration field (identifier + RTR bit) n control field (dedicated bits + data length) –Both dedicated bits have a dominant value n data (0 – 8 bytes) n CRC (15-bit CRC, 1 recessive bit as a delimiter) n acknowledge (1 bit acknowledge, 1 bit delimiter) n end of frame (7 recessive bits) n inter-frame space (3 recessive bits)

19 CAN 2.0B – Standard Data Frame Format n In fact the same like CAN 2.0A frame format n Only the formal difference –bit r1 name changed to IDE (identifier extended) n The IDE bit is always dominant in a standard data frame

20 CAN 2.0B – Extended Data Frame Format n Allows higher number of frames in particular system n RTR bit is replaced by SRR bit (substitute remote request) –always recessive n IDE bit is always recessive –standard frame with the same first 11 bits of identifier has higher priority n Following 18 identifier bits are used for arbitration among extended frames only n CAN controllers provide either active or passive compatibility with CAN2.0B

21 CAN 2.0A – RTR Frame Format n RTR bit is always recessive n RTR frame identifier is the same like the data frame identifier which transmission is requested n RTR frame has lower priority than the data frame with the same identifier –do you know WHY ??? n Data length is always 0 n Similarly it exists an extended RTR frame format according to the CAN 2.0B

22 CAN – Error Frame Format n Error frame consists of six dominant or recessive bits –it depends on error state of the node which transmits it n It is transmitted by the node (-s) that detect (-s) any communication error –it result in an immediate transmission stop and its later repetition –this is all controlled by the controller (implemented in silicon), not by application software

23 CAN – Overload Frame Format n Overload frame consists of six dominant bits n Its transmission is requested by the receiver in order to –delay the transmission of a next data frame –indicate a detection of a dominant value in a last bit of the end of frame field or in first two bits of inter-frame space n Its occurrence does not mean an error –previous frame is not retransmitted n Today controllers do not use it to delay the next transmission – they are fast enough

24 CAN – Error Detection Several simultaneously used mechanisms: n Monitoring –transmitter receives back the bus state and if it detects a different value, its behavior is: in case it detects a dominant bus state within the arbitration field while transmitting the recessive one, it stops transmitting in case it detects a recessive bus state within the arbitration field while transmitting the dominant one, or if it detects anywhere else (excluding the ACK bit) opposite bus state than that one it is currently transmitting, it sends the error frame n CRC (Cyclic Redundancy Check) –in case the locally evaluated CRC is different from the received one, the error frame is transmitted

25 n Bit stuffing –transmitter transmits particular bits using NRZ (not return to zero) coding –if there is a sequence of 5 consecutive bits of the same level, one bit of the opposite level is inserted –during the reception an inverse process takes place, it means after five received bits of the same level the next bit must be of the opposite level (check) and it is known it is an inserted bit – it is thus removed CAN – Error Detection

26 n Error frame transmission violates bit stuffing rule –all nodes thus detect the error –it is thus ensured that the frame is received either by all nodes or by no node data consistency CAN – Bit Stuffing

27 n Frame format check –some bits have predefined level CRC or ACK delimiters are always recessive end of frame field is whole recessive –if there is a dominant bit detected, an error frame is sent –data length field can contain value higher than 8 length of 8 is expected error frame is not sent n Frame receive acknowledge –by the dominant level in the ACK bit –if there is no acknowledge, transmitting node sends an error frame –data frame transmission is repeated CAN – Error Detection

28 CAN – Node Error States n One node encountering communication problems could block complete communication within the system –it detects an error in each received frame and transmits an error frame –it is necessary to limit this possibility n There are two so called error counters in each CAN controller (and thus in each network node) –one for errors during transmission, one during reception –at the beginning they are reset –if there is an error during transmission, transmission error counter value is increased, the same is tru for reception n If the transmission or reception have passed without error, the respective value is decremented (up to zero) n According to the error counters values particular node is in one of three error states

29 n Error active –value of each of both error counters has to be lower than 128 –in case the error is detected during the frame transmission or reception, an active error flag (6 consecutive dominant bits) is generated –it breaks communication and all other nodes within the system detect error as well –the number the respective error counter is increased (0, 1 or 8) depends on the error context, it means the situation and conditions of error detection –if any of error counters reaches the value higher than 127, the respective node goes into the error passive state CAN – Node Error States

30 n Error passive –the value of at least one error counter is higher than 127 –if the node detects communication error, it generates a passive error flag (6 consecutive recessive bits) –if the error passive node is the only one who detects error (probably incorrectly), the communication is not broken and can be finished and acknowledged by other nodes –in case of successful reception the respective counter is either decremented (if its value was lower than 128) or set between 119 and 127 (if its value was higher 127) –if the values of both counters fall under 128, the node goes back to error active state –if the value of transmission error counter gets over 255, the controller enters bus-off state CAN – Node Error States

31 n Bus-off state –transmission error counter value is higher than 255 –reception error counter value has no influence on entering into the bus-off state –bus-off node is completely disconnected from the network (logical not physical disconnect) it is not possible to transmit frames nor to influence the bus communication by any way (no ACK, error frame..) reception is possible (depends on implementation) –from the point of view of other nodes the bus-off node disappears from the network (like switched off) –to leave the bus-off state only the controller hardware or software reset is available then after the detection of 128 recessive 11-bit sequences the controller enters an error active state incorrect software implementation can make global problems in communication CAN – Node Error States

32 CAN – Error States Servicing CAN controller Status register usually contains: n Error warning flag –set if any error counter reaches some limit usually 96 sometimes this limit can be preset –controller can generate an interrupt service request –application software (node firmware) may or may not service this event n Error passive flag –set by entering the error passive state –interrupt service request possible –Application software should také into account possible data inconsistency within the local node and the rest of a network n Bus-off flag –controller reinitialization is necessary

33 CAN – Persisting communication problems n It always depends on the error type, direction of communication (reception, transmission) where it takes place as well as the physical layer protocol version –e.g. tolerance to some shorts n Fatal errors (e.g. Short connection of both CAN lines to ground) always finishes in bus-off state –only in case the node tries to transmits n The node which is alone in the network (or disconnected by cable interrupt), enters after 16 unacknowledged frame transmissions into an error passive state n If the software service of error states is not correctly implemented, serious communication problems may occur n Under the standard conditions all nodes within the system are in the error active state and there are no error frames generated

34 CAN – Physical Layer Standards n CAN standard (Bosch) defines the link layer protocol only n It is also standardized by ISO as ISO n Physical layers are defined in standards ISO –high-speed CAN –up to 1 Mbit/s n and ISO –low-speed CAN –up to 125 kbit/s –particular fault tolerance n Both these physical standards are widely used in today vehicles n For trucks there are othe standards available with higher degree of immunity n They are all defined as SAE standards too

35 CAN – ISO Physical Layer n Bus structure with terminators n Line impedance of 120 ohm n Communication speed up to 1 Mbit/s n Differential signaling (logical level defined by voltage difference) –CAN_H and CAN_L lines

36 n The recessive level is provided by terminators and „wake“ voltage sources in transceivers –CAN_H – CAN_L difference is near 0 n The dominant state is driven by the transceiver – CAN_H – CAN_L difference is about 2 volts CAN – ISO Physical Layer

37 n The transceiver contains the temperature, short circuit and ESD protection n Low load in power off state n Some offer low power states CAN – ISO Physical Layer

38 n Bus structure n Sleep mode with remote wake-up by CAN communication n Communication speed up to 125 kbit/s n Differential signaling CAN – ISO Physical Layer

39 n Particular fault tolerance, transceiver enters so called single wire mode –CAN_H or CAN_L wire broken –short connection of CAN_H or CAN_L to ground –short connection of CAN_H or CAN_L to +5V –short connection of CAN_H or CAN_L to +12V –short connection of CAN_H to CAN_L n Single wire mode is indicated by the transceiver output –after the fault is removed transceiver automatically enters standard two wire mode CAN – ISO Physical Layer

40 n RTH and RTL resistors provide termination –their values depend on number of nodes in system n Transceiver supports node wake-up when the CAN activity is examined, or by he local signal n Sleep mode is controlled by the local microprocessor –if the whole bus is in sleep (low power) mode, CAN_H voltage is near 0 and CAN_L voltage is near the battery one CAN – ISO Physical Layer

41 CAN – Immunity to External Disturbances n Information is transferred by the voltage difference –if both wires are close the induced disturbance is the same, difference stays the same –the absolute value of the induced disturbance can be further decrease with utilization of twisted pair wire

42 CAN – Transmission Timing n všechny uzly v síti musí mít nastavenu shodnou nominální přenosovou rychlost n skutečné rychlosti se mírně liší (tolerance oscilátorů) n vzhledem k faktu, že v průběhu arbitráže může vysílat více uzlů najednou, že arbitráž probíhá bit po bitu a že šíření informace z jednoho uzlu do druhého je zatíženo zpožděním (budič – vedení – přijímač), je třeba: –kompenzace statických zpoždění –průběžné synchronizace kvůli odchylkám oscilátorů

43 CAN – časování komunikace n příklad „současného“ vysílání dvou uzlů –maximální zpoždění, s nímž je nutno počítat, je dáno dvojnásobkem zpoždění řetězce budič, vedení, přijímač

44 CAN – časování komunikace n konstrukce délky bitu –programovatelná dělička generuje signál s délkou označovanou jako časové kvantum –z celistvého počtu časových kvant je poté složen bitový interval

45 CAN – časování komunikace n bitový interval se skládá z 8 až 25 časových kvant, která jsou rozdělena do 4 segmentů –synchronizační segment je dlouhý 1 časové kvantum –„propagation“ segment slouží ke kompenzaci zpoždění mezi uzly –„phase buffer“ segmenty 1 a 2 určují bod, kde řadič vzorkuje, zda je na sběrnici recesivní či dominantní úroveň

46 CAN – časování komunikace n na začátku rámce dochází k tzv. tvrdé synchronizaci (hard synchronization) –sběrnice je vzorkována s periodou časového kvanta –je-li detekován přechod z recesivní do dominantní úrovně, pak je dané časové kvantum považováno za synchronizační segment n v průběhu vysílání rámce dochází k resynchronizaci –délka „phase buffer“ segmentů je měněna podle detekovaných hran tak, aby hrany vždy spadaly do synchronizačního segmentu jednotlivých bitů –využívá se pouze přechodů z recesivní do dominantní úrovně –velikost synchronizačního skoku je omezena –časový rozdíl mezi očekávaným a skutečným výskytem hrany se nazývá fázovou chybou –dvě varianty resynchronizace podle znaménka fáz. chyby

47 CAN – časování komunikace n při kladné fázové chybě je „phase buffer 1“ segment prodloužen ak, aby byl bod vzorkování správně zpožděn za příchozí hranou signálu –dojde vlastně k „dočasnému zpomalení“ taktu

48 CAN – časování komunikace n při záporné fázové chybě je „phase buffer 2“ segment zkrácen tak, aby byl příslušná hrana signálu ležela v synchronizačním segmentu následujícího bitu –dojde vlastně k „dočasnému zrychlení“ taktu

49 CAN – časování komunikace n z doposud uvedeného vyplývá, že maximální délka sběrnice závisí na přenosové rychlosti –musí být kompenzováno zpoždění

50 CAN – měření parametrů n fyzické vrstvy –úrovně signálů osciloskop –rychlosti hran osciloskop –hodnoty terminátorů multimetr, osciloskop –přenosová rychlost osciloskop –pozice vzorkovacího bodu v bitu vyžaduje specielní přístrojové vybavení není třeba, pokud je k dispozici zdrojový kód firmware jednotky

51 CAN – měření parametrů n spojové vrstvy –lze spoléhat na správnost implementace v řadiči –důležité jsou správné reakce firmware na výskyt chybových stavů –při bus-off stavu nelze jednoduše zinicializovat řadič a spoléhat na to, že se jednalo o náhodu obvykle stačí osciloskop na definované vynucení bus-off stavu je třeba specielní přístroj

52 CAN – měření parametrů n aplikační vrstvy –vysílání rámců se správnou periodou a obsahem za všech okolností –důležité jsou správné reakce firmware na výskyt chybových stavů zápisy do chybových pamětí –testování jednotky od vstupů k výstupům (hardware in the loop) CAN  fyzický výstup fyzický vstup  CAN –aplikační testy závisí na typu jednotky, aplikačních protokolech apod. automobilky obvykle přesně definují požadavky testů a testovací procedury –dle povahy aplikačních testů je obvykle nezbytný analyzátor a generátor rámců v sestavě s osciloskopem, případně multimetrem a funkčním generátorem

53 CAN – aktivní a pasivní monitoring n pro většinu aplikačních měření na CANu postačí monitoring komunikace v síti –aktivní monitoring spočívá v plném začlenění monitorovacího uzlu do komunikace v síti, včetně generování potvrzení, chybových rámců a případné účasti v arbitráži jediná možnost, pokud je měřený uzel jediný v síti –pasivní monitoring spočívá v pouhém odposlechu komunikace bez zásahu do ní nelze vysílat –některé řadiče (např. SJA1000) podporují oba režimy další využití je pro automatickou detekci přenosové rychlosti –řadič, který pasivní režim nepodporuje, lze pro jeho podporu snadno doplnit jednoduchou logikou, která zabrání vysílání na sběrnici, ale umožní zpětný příjem vysílaných dat


Stáhnout ppt "CAN Bus and its Applications in Vehicles J. Novák Czech Technical University in Prague Faculty of Electrical Engineering Dept. Of Measurement."

Podobné prezentace


Reklamy Google