Protocol Learning Mode

Understand CAN/LIN frame structures, inspect messages, and test your knowledge.

CAN & LIN Protocol Basics
Learn about the fundamental concepts of Controller Area Network and Local Interconnect Network.

Introduction to CAN Bus

What is CAN?

Controller Area Network (CAN) is a robust vehicle bus standard designed to allow microcontrollers and devices to communicate with each other's applications without a host computer. It is a message-based protocol, not address-based.

Key Features

  • Message-based protocol, designed originally for multiplex electrical wiring within automobiles to save on copper, but is also used in many other contexts.
  • Prioritization of messages using identifiers (lower ID means higher priority).
  • Robust error detection (CRC, ACK, Form Error, Bit Error, Stuff Error) and fault confinement mechanisms.
  • Multi-master capabilities, any node can transmit if the bus is free.
  • Differential signaling for noise immunity.

CAN Frame Structure (Standard)

Standard CAN Frame (11-bit ID)

A standard CAN frame consists of several fields:

  • SOF (Start of Frame): 1 dominant bit. Marks the beginning of a message and allows synchronization.
  • Identifier (ID): 11 bits. Determines message priority; lower values have higher priority.
  • RTR (Remote Transmission Request): 1 bit. Dominant (0) for data frames, recessive (1) for remote frames (requesting data).
  • IDE (Identifier Extension): 1 bit. Dominant (0) for standard CAN (11-bit ID). Recessive (1) for extended CAN (29-bit ID).
  • r0 (Reserved Bit): 1 bit. Reserved, typically dominant (0).
  • DLC (Data Length Code): 4 bits. Number of data bytes (0-8). Values >8 are not standard for classical CAN.
  • Data Field: 0-8 bytes. The actual payload of the message.
  • CRC (Cyclic Redundancy Check): 15 bits for calculation + 1 recessive delimiter bit (CRC Delimiter). Used for error detection.
  • ACK (Acknowledge): 1 slot bit + 1 recessive delimiter bit (ACK Delimiter). Transmitter sends recessive, any receiving node can assert dominant if the frame was received correctly up to the CRC delimiter.
  • EOF (End of Frame): 7 recessive bits. Marks the end of the message.
  • IFS (Inter-Frame Space): Minimum of 3 recessive bits. Separates consecutive frames.

Extended CAN frames use a 29-bit identifier, with an SRR (Substitute Remote Request) bit and a different IDE bit usage.

Introduction to LIN Bus

What is LIN?

Local Interconnect Network (LIN) is a serial network protocol used for communication between components in vehicles. It is a simpler, slower (up to 19.2 kbit/s, commonly 9.6 or 19.2), and cheaper alternative to CAN, typically used for less critical functions like sensor data (e.g., rain sensor, light sensor) or actuator control (e.g., window lifts, mirror adjustment) in comfort electronics.

Key Features

  • Single master, multiple slaves (up to 15 slaves, plus the master).
  • Low cost due to single-wire implementation (+ ground and power) and UART/SCI-based communication (common in microcontrollers).
  • Deterministic signal transmission scheduled by the master.
  • Self-synchronization without a crystal in slave nodes (slaves synchronize on the master's break field).
  • Checksum for data integrity.

LIN Frame Structure

A LIN frame consists of a Header (sent by Master) and a Response (sent by a designated Slave or the Master itself):

  • Header:
    • Break Field: At least 13 dominant bits followed by a recessive delimiter. Signals start of frame.
    • Sync Byte: Fixed value 0x55. Allows slaves to measure bit time and synchronize.
    • Protected ID (PID): 6-bit identifier + 2 parity bits. Identifies the message content.
  • Response:
    • Data Bytes: 1 to 8 bytes of data.
    • Checksum: 1 byte. Calculated over data bytes (classic checksum) or data bytes + PID (enhanced checksum).