linbus.md 1.6 KB


title: Linbus categories: [cheatsheets]

tags: [automotive]

LIN Bus - Local Interconnect Network

  • Version 1.0 was published 1999
  • Used to connect ECU's
  • Master-Slave Principle with up to 16 Slaves
  • Transceiver is based on the UART protocol and LIN only has one cable
  • Baud rate of about 20kBaud (as defined in the standard)
  • Mostly 19.2kBaud are implemented in reality
  • maximum of 40m cable

Basic Connections

  • Only the master is able to initiate connections
  • Slaves can only answer to master-requests
  • Master needs to init. the communication between two slaves
  • Messages are send as in the scheduling table defined (in the master)

LIN-Frame

<-----[ Header ]-----> <-----[ Response ]----->
  • Sync-Break - used for Frame Synchronisation
  • Sync-Field - used for Bit Synchronisation (mostly 0x55)
  • ID - Unique Identifier (6 bytes + 2 parity bytes)

Reponse

  • Datafield - contains data
  • Checksum - modulo 256 checksum of the data-field

Special Frames

  • Diagnostic Frames are send via Broadcast
  • Event-Triggered Frames: Master asks for a Value, Slave only answers if the value changed. -> If two slaves answer: Buscollision -> Master requests the message with the higher priority first

Checksums

  • The checksum is calculated via a modulo 256 calculation
  • The Carry-Bit is added to the LSB bit of the checksum

Example

  Data | Checksum
  0x41   0x41
+ 0x55   0x9f
+ 0x93   0x132    // to big, carry bit = 1
         0x33     // added carrt bit to LSB checksum bit
         0x12     // inverted the checksum

The Checksum is 0x12 and gets appended to the data.