46
Controller Area Network part 1

part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

  • Upload
    lyque

  • View
    217

  • Download
    3

Embed Size (px)

Citation preview

Page 1: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

Controller Area Network

part 1

Page 2: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

We will talk about:

• General features• CAN messages• Bitwise arbitration• CAN synchronisation

Page 3: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

Controller Area Network

General features

Page 4: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

CAN features• Bus-access by message priority

– CSMA/CRCarrier Sense Multiple Access / Collision Resolution

• Bus access conflicts resolved by arbitration– Bit-wise– Non-destructive– Allows for guaranteed latency time

• Message identifier– CAN has no node addresses

Every node receive every message and decides itself whether to use it or not

Page 5: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

CAN features• Extensive ERROR checking

– Five different checks– Every connected node participate

• Data consistency secured– A message is accepted by all nodes or none

• Different Bus Management Methods can be applied for CAN systems, e.g.,– Bit-wise arbitration– Master/Slave– Daisy Chain– TDMA

Page 6: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

CAN features• A Higher Layer Protocol is always

required– CAN is only a low level specification

• The capability of CAN is restricted by the Higher Layer Protocol chosen– Market segment– Real-time requirements– Product Administration requirements– etc

Page 7: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

Controller Area Network

Page 8: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

CAN message

Data Frame

CAN Id/Priority

11 or 29 bits 0 - 8 bytes

DLC4bits

Page 9: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

CAN Data Frame Std

1 4 0 - 64 15 1 1 7 311

IdentifierField

Start OfFrame

RTR-bit

Data Field CRCField

CRC Delimiter

1

ACK DelimiterACK Slot

End Of Frame Intermission

min. 2

Inter-framespace

Inter-framespace

DLC

00/11

Bit values

ControlField

r1 r0

1 2

TransmitterReceiver

10

Page 10: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

1 4 0 - 64 15 1 1 7 311

IdentifierField Data Field CRC

Field

1

ACKfield

Inter-framespace

Inter-framespace

DLC

ControlField

1 2

A CAN frame

•Priority and Identification field.•Control field.•Data field.•CRC field.•Acknowledgement field.•Fixed part.

Page 11: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

1 4 0 - 64 15 1 1 7 311

IdentifierField Data Field CRC

Field

1

ACKfield

Inter-framespace

Inter-framespace

DLC

ControlField

1 2

Priority and/or Identification

Identifier Field•11 bit or 29 bit. 11 bit is shown above•Arbitration is done in this part•This part sets the priority of the message in case of collision•The Remote Transmit Request bit (RTR) is a part of this field•CAN-controllers support this part of the message as an identification by which filtration can be made

Page 12: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

Control and Data length field

1 4 0 - 64 15 1 1 7 311

IdentifierField Data Field CRC

Field

1

ACKfield

Inter-framespace

Inter-framespace

DLC

ControlField

1 2

Control Field•Main function Data Length Code DLC•DLC can have the value 0..8 (Values above 8 are interpreted as 8)•Two bits are reserved and used to indicate Extended frames•In Standard frames the reserved bits are fix dominant bits

Page 13: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

Data field

1 4 0 - 64 15 1 1 7 311

IdentifierField Data Field CRC

Field

1

ACKfield

Inter-framespace

Inter-framespace

DLC

ControlField

1 2

Data Field•The field can be from zero up to eight byte•It is always full 8 bit bytes•The bytes can have any value•Some CAN controllers can extend ID filtration into the data field

Page 14: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

CRC field

1 4 0 - 64 15 1 1 7 311

IdentifierField Data Field CRC

Field

1

ACKfield

Inter-framespace

Inter-framespace

DLC

ControlField

1 2

CRC Field•A Checksum of the bits in the message•The CRC is optimised for this short type of message•The CRC check is only one of the error checks in the CAN communication

Page 15: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

Acknowledgement field

1 4 0 - 64 15 1 1 7 311

IdentifierField Data Field CRC

Field

1

ACKfield

Inter-framespace

Inter-framespace

DLC

ControlField

1 2

Acknowledgement Field•It is an acknowledgement of reception, securing at least one receiver has got the message OK•The transmitter sets the ACK bit to 1•Any receiver set the ACK bit to 0 when the message is found OK

Page 16: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

Fixed value bits

1 4 0 - 64 15 1 1 7 311

IdentifierField Data Field CRC

Field

1

ACKfield

Inter-framespace

Inter-framespace

DLC

ControlField

1 2

•These bits have a fixed value for all message frames•There is additional rules for the intermission bits

Page 17: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

IdentifierField

Start Of Frame

RTR-bit

CRCField

CRC Delimiter

ACK DelimiterACK Slot

End Of Frame Intermission

min. 2

Inter-framespace

Inter-framespace

DLC

00/11

Bit values

Control Fieldr1 r0

r1 = IDE

2 4 115 1 311 11 1 7

CAN Remote Frame Std

Page 18: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

1 4 0 - 64 15 1 1 7 311

Identifier Field

Start OfFrame RTR

-bit

Data Field CRCField

CRC Delimiter

1

ACK DelimiterACK Slot

End Of Frame

Intermissionmin. 2

Inter-framespace

Inter-framespace

DLC

ControlField

r1 r0

1 2

2 4 115 1 311 11 1 7

Remote compared to data frame, Std

NOTE: DLC in all remote requests must be identical to DLC in corresponding DATA Message!

Page 19: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

CAN Data Frame Ext.

1 11 4 0 - 64 15 1 7 318

Identifier FieldStart OfFrame

RTR-bit

Data Field CRC Field CRC Delimiter

1

ACK DelimiterACK Slot

End Of Frame Intermission

min. 2

Inter-framespace

Inter-framespace

DLC

SubstituteRemoteRequest

IdentifierExtensionBit

00/11

Bit values

Control Fieldr1, r0

2 1 2 1

Page 20: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

CAN Data Frame Ext. and Std

1 4 0 - 6411 1 1

1 4 0 - 64 15 1 1 7 311

IdentifierField

Start OfFrame

RTR-bit

Data Field CRCField

CRC Delimiter

1

ACK DelimiterACK Slot

End Of Frame Intermission

min. 2

Inter-framespace

DLC

ControlField

r1 r0

1 2

18

1

1 2

SubstituteRemoteRequest

IdentifierExtensionBit

Page 21: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

Controller Area Network

Page 22: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

0

1

Arbitration Lost

Module 1

Module 2

Bus Line

Bit-wise Arbitration

Page 23: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

Bit-wise arbitration

The green node starts transmissonof a recessive bit on the idle bus.

Page 24: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

Bit-wise arbitration

The wave from the green node has not yet reached the rednode. To this the bus is still free and the red node startstransmitting a dominant bit.

Termination Termination

Page 25: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

Bit-wise arbitrationNow the green node can see that there is a dominant bit onthe bus and that it has lost arbitration. Thus a transmitter has to wait until the wave has reached themost distant node and back (plus internal delays) beforejudging the bus-line level

TerminationTermination

Page 26: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

Maximum bit rate is depending on wave propagation delays

•Bus length•Opto couplers•Internal delays•Oscillator accuracy(Often not specified)

Bit-wise arbitration

Page 27: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

Arbitration field

1 11 4 0 - 64 15 1 7 318

Identifier FieldStart OfFrame

RTR-bit

Data Field CRC Field CRC Delimiter

1

ACK DelimiterACK Slot

End Of Frame Intermission

min. 2

Inter-framespace

Inter-framespace

DLC

00/11

Bit values

Control Fieldr1, r0

2 1 2 1

TransmitterReceiver

10

A Std has higher priority than anExt with the first 11 bits equal

But then a lot of Ext messages areinterlaced before the next Stdappears

CAN Data Frame Ext.

Page 28: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

Std Identifier wins over Ext. Identifierwhen the first 11 bits are equal

1 11 4 0 - 64 15 1 7 318 12 1 2 1

Inter-framespace

1 11 4 0 - 64 15 1 7 312 11

Std RTR wins the arbitration here

Std wins the arbitration here

Arbitration field

Start Of Frame

00/11

Bit values But then each Std isinterlaced by 218 Extmessages

Page 29: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

Std vs. Ext. priority

1 11 1 1

1 11

IdentifierField

Start OfFrame

RTR-bit

r1 r0

1 2

18

1

SubstituteRemoteRequest

IdentifierExtensionBit

Prio Bit -29 - -19 Bit -18 - -1Hi 0 std

0 00 10 …0 2621431 std1 01 1… …

Low 2047 262143

Page 30: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

Controller Area Network

Synchronisation

Page 31: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

BIT TIMINGA bit time is built up by four parts:Synch_Seg, Prop_Seg, Phase_Seg1 and Phase_Seg2

Those parts are built up by a number of time quantasBit Time = Synch_Seg + Prop_Seg + Phase_Seg1 + Phase_Seg2

Often alternatively expressed asTBIT = TSYNC + TSEG1 + TSEG2where •TSYNC = 1•TSEG1 = [2..16]•TSEG2 = [1..8]•TBIT = [4..25]

Page 32: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

Sync_Seg 1Prop_Seg 1 - 8 (min)

Phase_Seg 1 1 - 8 (min)

Phase_Seg 2 1 - 8 (min)

Min timequantum(derivedfrom osc.)

1 - 32 (min)

Total 4 - 25 Time quanta (min)

Sample Point

Synch_Seg + Prop_Seg + Phase_Seg1 + Phase_Seg2

Bit Time =

Page 33: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

0 1 1 1 0 0 1 0 0 1

(Manchester Coding) CAN is NRZ which hasEMC advantagescompared with MC

NRZNon Return to Zero

Page 34: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

Bit Stuffing0

1

Stuff Bit

Stuff Bit

Five consecutive bits of samepolarity render a stuff bit

6

5 5 5 5 5

10 5

Page 35: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

0

1

29 bits

36 bits

Stuff Bit

Stuff Bit

36/29 = 1.24 !!

Five consecutive bits of samepolarity renders a stuff bit

5 4 4

5 5 5

Bit Stuffing

Page 36: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

CAN Data Frame Ext.

Bit stuffing fields

1 11 4 0 - 64 15 1 7 318

Identifier Field

Start OfFrame

RTR-bit

Data Field CRC Field CRC Delimiter

1

ACK DelimiterACK Slot

End Of Frame Intermission

min. 2

Inter-framespace

Inter-framespace

DLC

00/11

Bit values

Control Fieldr1, r0

2 1 2 1

TransmitterReceiver

10

Page 37: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

Synchronisation

6 10 12

Sync. flank at falling edges

Hardsync

Resync

deadreckoning

Dead reckoning betweensyncs. (Max 29 bits)

2 8

(At end of message)3

Page 38: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

Sync_Seg

1 Time quantum

Synchronize the various CAN nodeson the bus. An edge is expected withinthis segment.

Page 39: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

Prop_Seg

1 - 8 Time quanta (min)

Compensate for physical delaytimes on the bus and nodeinterfaces

Page 40: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

Phase_Seg1 & 2

Phase_Seg 1Phase_Seg 2

Phase_Seg1 1 - 8 Time quanta (min)Phase_Seg2 = Phase_Seg1 (or information

processing time)

Compensate for phase errors

Page 41: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

ResynchronisationSynch flank detected after samplingpoint (prematurely)

e = 0

e neg, shortenPhase_Seg2

e < 0e = Phase error

Bus level expected timefor synch flank

Resynchronized timer

Page 42: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

Resynchronisation

e > 0e = 0

e pos, lengthenPhase_Seg2

Expected sample pointe = Phase error

expected timefor synch flank

Bus level

Resynchronizedtimer

Synch flank detected before samplingpoint (later than expected)

Page 43: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

Sync Jump Width

SJW = Max phase correction

Max 4(min),Phase seg 2

Maximum synchcompensationallowed in one step

Page 44: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

Oscillator tolerance range

Conditions:•df min(Phase_Seg1, Phase_Seg2)/[2(13·TBIT - Phase_Seg2)]•df SJW/(20TBIT)•Max diff. between two osc. is 2dffnom

(1-df)·fnom fosc (1+df)·fnom

Page 45: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

CALCULATIONS•Tscl = Tclk * BRP * 2 = Tclk*(BRP + 1)*2

•BRP the value in CAN-controller•(clk = 16 MHz and BRP = 0: Tclk = 62.5ns and Tscl =125 ns )

•Tseg1 = Tscl * (TSEG1) = Tscl * (TSEG1 + 1)•TSEG1 the value in CAN-controller

•Tseg2 = Tscl * (TSEG2) = Tscl * (TSEG2 + 1)•TSEG2 the value in CAN-controller

•Tsjw = Tscl * (TSJW1) = Tscl * (TSJW + 1)•TSJW the value in CAN-controller

•SJW = [1..4]

Page 46: part 1 - UV · PDF file7 3 11 Identifier Field Start Of Frame RTR-bit ... TBIT = TSYNC + TSEG1 + TSEG2 where •TSYNC = 1 ... 8/23/2001 9:50:15 AM

RULES

•TProp_Seg > (All delays) * 2• TSeg2 >= 1 Tscl, CAN controller may demand minimum 2 Tscl.• TSeg2 >= Tsjw• TSeg1 >= Tsjw + TProp

Suggestion: Keep Phase segment Tsjw+1