In-vehicle networks: CAN, LIN and FlexRay

How CAN (differential bus, bitwise arbitration, frame format, stuffing and fault confinement), LIN (single-wire master-slave) and FlexRay (time-triggered dual-channel) carry data between ECUs, with frame-time, bus-load, bit-timing and LIN numericals.

Drafted with Aria, reviewed by the AiCanCode.org team. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

A modern car has dozens of ECUs — engine, gearbox, ABS/ESC, airbags, body, instruments, ADAS — that must share data such as engine speed, wheel speeds and torque requests. Running a separate wire for every signal would make the harness impossibly heavy, so ECUs share serial networks. CAN carries most of this traffic, LIN connects cheap switches and motors, and FlexRay (and now automotive Ethernet) handles time-critical or high-bandwidth data. Diagnosis, ECU integration and EV battery work all require reading these networks.

Key ideas

Multiplexing. Instead of point-to-point wires, each ECU broadcasts messages on a shared bus and others take what they need. Benefits: fewer wires and connectors, one sensor used by many ECUs, easy addition of features, and diagnostics through one connector. A gateway ECU connects networks with different speeds and filters messages between them.

CAN (Controller Area Network, ISO 11898).

  • Physical layer: a twisted pair, CAN_H and CAN_L, with differential signalling. Recessive bit (logic 1): both lines near 2.5 V, difference about 0 V. Dominant bit (logic 0): CAN_H about 3.5 V and CAN_L about 1.5 V, difference about 2 V. A 120 Ω resistor terminates each end, so a healthy bus measures about 60 Ω between CAN_H and CAN_L with power off.
  • Speeds: classical CAN up to 1 Mbit/s (500 kbit/s typical for powertrain and chassis, 125 kbit/s for body). Maximum bus length falls as bit rate rises (roughly 40 m at 1 Mbit/s). CAN FD allows up to 64 data bytes and a faster data phase (commonly 2–5 Mbit/s).
  • Multi-master and message-oriented: there are no node addresses. Each frame carries an identifier that names the content (e.g. "engine speed"), and the identifier also sets priority.
  • Arbitration (CSMA/CR): a node may start when the bus is idle. While sending the identifier, each node reads back the bus. Dominant overwrites recessive, so a node that sends recessive but sees dominant has lost and stops; the frame with the lowest identifier wins without being damaged (non-destructive bitwise arbitration).
  • Frame (standard, 11-bit ID): start of frame, identifier, RTR, IDE, reserved bit, 4-bit data length code, 0–8 data bytes, 15-bit CRC and delimiter, 2-bit ACK, 7-bit end of frame, then 3 bits of inter-frame space. Extended frames use a 29-bit identifier.
  • Bit stuffing: after five identical bits the transmitter inserts one opposite bit, so receivers can keep their clocks synchronised; this lengthens frames.
  • Error handling: five checks — bit monitoring, stuff check, form check, CRC check and ACK check. Any node finding an error sends an error frame and the transmitter retries automatically. Transmit and receive error counters move a node from error-active to error-passive and finally bus-off, so a faulty node removes itself instead of jamming the bus.

LIN (Local Interconnect Network, ISO 17987).

  • Single wire referenced to the 12 V supply, up to about 20 kbit/s (19.2 kbit/s common), typically up to 16 nodes, low-cost transceivers.
  • Single master, multiple slaves: the master runs a schedule table and sends a header (break, sync byte 0x55, protected identifier); the addressed slave answers with 1–8 data bytes and a checksum. Each byte is sent as 10 bits (start, 8 data, stop). Timing is deterministic because the master schedules everything.
  • Used for door modules, window and mirror motors, seat motors, rain/light sensors, HVAC flaps — usually a LIN sub-bus hanging off a CAN body ECU.

FlexRay (ISO 17458).

  • Up to 10 Mbit/s on each of two channels, used for redundancy or extra bandwidth.
  • Time-triggered: a repeating communication cycle with a static segment of fixed time slots (TDMA, guaranteed latency) and a dynamic segment for event-driven messages; all nodes share a synchronised global time.
  • Suited to chassis control and x-by-wire functions that need guaranteed timing; more expensive and complex than CAN.

Automotive Ethernet. Single twisted-pair Ethernet (100 Mbit/s and 1 Gbit/s versions) now carries camera, radar, infotainment and ADAS data and software updates, and is taking over high-bandwidth backbones.

Formulas

t_bit = 1 / R_b

  • t_bit: bit time (s), R_b: bit rate (bit/s).

N_frame = 47 + 8n (classical CAN, 11-bit ID, including 3-bit inter-frame space, no stuff bits)

  • n: number of data bytes (0–8). Without inter-frame space it is 44 + 8n.

N_stuff,max = ⌊(34 + 8n − 1) / 4⌋

  • Worst-case number of stuff bits in a standard frame (only the 34 + 8n bits from start of frame to the end of CRC are stuffed).

t_frame = N / R_b

U = Σ (N_i / T_i) / R_b

  • U: bus load (fraction), N_i: bits in message i, T_i: period of message i (s).

R_b = f_clk / (BRP × N_tq)

  • f_clk: CAN controller clock (Hz), BRP: baud-rate prescaler, N_tq: time quanta per bit.

N_LIN = 34 + 10 × (n + 1), T_frame,max = 1.4 × N_LIN / R_b

  • Nominal LIN frame bits (34-bit header; n data bytes plus a checksum byte at 10 bits each); the specification allows 40 % extra time.

Worked examples

Example 1 (standard). A CAN bus runs at 500 kbit/s. For a standard frame with 8 data bytes, find (a) the bit time, (b) the frame length and time without stuffing, (c) the worst-case length and time with stuffing. (d) What resistance should be measured between CAN_H and CAN_L with the bus powered down?

  1. t_bit = 1 / 500,000 = 2 µs.
  2. N = 47 + 8 × 8 = 111 bits; t = 111 × 2 µs = 222 µs.
  3. N_stuff = ⌊(34 + 64 − 1) / 4⌋ = ⌊24.25⌋ = 24; N = 111 + 24 = 135 bits; t = 270 µs.
  4. Two 120 Ω terminations in parallel: R = 120 × 120 / 240 = 60 Ω.

Answer: 2 µs; 111 bits, 222 µs; 135 bits, 270 µs; about 60 Ω.

Example 2 (GATE level). (a) On the same 500 kbit/s bus, ten 8-byte messages are sent every 10 ms and twenty 8-byte messages every 100 ms. Using worst-case frame length, find the bus load. (b) A CAN controller has a 16 MHz clock, prescaler 2 and 16 time quanta per bit. Find the bit rate. (c) A LIN slave returns 8 data bytes at 19.2 kbit/s. Find the nominal and maximum frame times, and the nominal time to transfer 64 bytes.

  1. Frames per second = 10 × (1 / 0.010) + 20 × (1 / 0.100) = 1000 + 200 = 1200 /s.
  2. Bits per second = 1200 × 135 = 162,000 bit/s; U = 162,000 / 500,000 = 0.324.
  3. R_b = 16 × 10⁶ / (2 × 16) = 500,000 bit/s.
  4. N_LIN = 34 + 10 × 9 = 124 bits; t_nom = 124 / 19,200 = 6.46 ms; t_max = 1.4 × 6.46 = 9.04 ms.
  5. 64 bytes needs 64 / 8 = 8 frames: 8 × 6.46 = 51.7 ms nominal.

Answer: 32.4 % bus load; 500 kbit/s; 6.46 ms (max 9.04 ms) per frame, about 52 ms for 64 bytes.

Common mistakes

  • Dividing payload bits by bit rate and ignoring frame overhead and stuff bits — an 8-byte CAN frame has more than 100 bits for 64 bits of data.
  • Thinking CAN identifiers are node addresses. They identify message content and priority.
  • Saying the highest identifier wins arbitration; the lowest (most dominant zeros) wins.
  • Assuming a single faulty node always stops the bus. Fault confinement normally takes it bus-off; but a short between CAN_H and CAN_L, or to earth, does stop communication.
  • Forgetting that LIN carries at most 8 data bytes per frame and sends each byte as 10 bits.
  • Treating FlexRay as just "faster CAN"; its key feature is time-triggered, deterministic scheduling.

For GATE ME

Networks are outside the core GATE ME syllabus, but the numericals are simple rate and timing problems: bits to time, utilisation as a fraction of capacity, parallel resistors, and clock division. Practise careful counting of overhead and unit conversion between µs, ms and s.

Quick check

  1. Which logic level is dominant on CAN?
  2. Two nodes start sending identifiers 0x120 and 0x0F0 at the same time. Which wins?
  3. What is the bit time at 250 kbit/s?
  4. Why is bit stuffing needed?
  5. Give one application each for LIN and FlexRay.

Answers: 1. Logic 0 (dominant overwrites recessive 1). 2. 0x0F0, the lower identifier. 3. 4 µs. 4. To guarantee edges for receiver clock resynchronisation (and to make stuff errors detectable). 5. LIN: window or mirror motor; FlexRay: chassis or x-by-wire control.

Try answering each one aloud before you open it.

  1. 1.What is a Controller Area Network (CAN) and why is it important in automotive electronics?Concept

    A Controller Area Network (CAN) is a robust vehicle bus standard designed to allow microcontrollers and devices to communicate with each other without a host computer. It is important in automotive electronics because it enables communication between various electronic components in a vehicle, such as the engine control unit, transmission, and antilock braking system, ensuring efficient and reliable operation.

  2. 2.Explain the main differences between CAN and LIN networks.Concept

    CAN is a two-wire differential, multi-master bus up to 1 Mbit/s (CAN FD faster) where any node may transmit and collisions are resolved by bitwise arbitration on message identifiers, backed by CRC, error frames, automatic retransmission and fault confinement. LIN is a single-wire, single-master bus up to about 20 kbit/s: the master polls slaves from a schedule table, and each frame carries at most 8 data bytes with a simple checksum. LIN is much cheaper, often just a UART and a transceiver, and is used as a sub-bus for motors, switches and sensors, while CAN carries powertrain, chassis and body data between ECUs.

  3. 3.What is FlexRay and how does it differ from CAN?Concept

    FlexRay is a high-speed communication network used in automotive applications that require deterministic data transmission, such as advanced driver-assistance systems (ADAS). Unlike CAN, which is event-triggered, FlexRay is time-triggered, allowing for more predictable communication. FlexRay supports higher data rates (up to 10 Mbps) and is more suitable for complex systems requiring synchronized data exchange.

  4. 4.Why is LIN used in automotive applications despite its lower speed compared to CAN?Application

    LIN is used in automotive applications because it is cost-effective and sufficient for non-critical communication tasks, such as controlling window lifts, seat adjustments, and climate control. Its lower speed is adequate for these applications, and its simplicity reduces the overall cost and complexity of the vehicle's electronic system.

  5. 5.What happens if a CAN bus experiences a fault in one of its nodes?Application

    CAN has fault confinement built in. Every node keeps transmit and receive error counters; a node that keeps causing errors moves from error-active to error-passive, where it can no longer disrupt frames with active error flags, and then to bus-off, where it stops transmitting altogether. The rest of the network keeps communicating, and other ECUs detect the missing messages with timeouts and set U-codes. However, a physical fault such as CAN_H shorted to CAN_L or to earth, or a missing termination, can stop or corrupt the whole bus.

  6. 6.How does the arbitration process work in a CAN network?Concept

    CAN uses non-destructive bitwise arbitration (CSMA/CR). Any node can start sending when the bus is idle; while sending its identifier, each node reads back the bus level. A dominant bit (0) overrides a recessive bit (1), so a node that sends recessive but reads dominant knows a higher-priority frame is on the bus and stops transmitting to become a receiver. The frame with the lowest identifier therefore wins and continues undamaged, and the losers retry automatically when the bus is free.

  7. 7.A CAN controller runs from a 16 MHz clock with a baud-rate prescaler of 2 and 16 time quanta per bit. What is the bit rate?Numerical

    The time quantum is BRP / f_clk = 2 / 16 MHz = 0.125 µs, and one bit is 16 quanta, so t_bit = 2 µs. The bit rate is f_clk / (BRP × N_tq) = 16 × 10⁶ / (2 × 16) = 500 kbit/s. The bit rate is not simply equal to the clock frequency: the controller divides its clock into time quanta and builds each bit from synchronisation, propagation and phase segments that set the sample point.

  8. 8.What are the advantages of FlexRay over CAN, and where is it used?Application

    FlexRay offers up to 10 Mbit/s on each of two channels, against 1 Mbit/s for classical CAN. Its time-triggered static segment gives each message a fixed slot, so latency is guaranteed and jitter is very low, and the second channel can provide redundancy. That suits safety-critical, synchronised control such as active suspension, chassis control and x-by-wire. It is more complex and costly than CAN, and for high-bandwidth sensor data in ADAS and automated driving, automotive Ethernet is now generally used instead.

  9. 9.Explain how error detection is handled in a CAN network.Concept

    CAN uses five error checks. The transmitter compares each bit it sends with the bus (bit monitoring), and receivers check the stuffing rule (no six identical bits), the fixed-format fields (form check), the 15-bit CRC, and the acknowledgement slot (ACK check). Any node that detects an error sends an error frame, which destroys the frame for everyone, and the transmitter retransmits automatically. Error counters then provide fault confinement, so a persistently faulty node goes error-passive and finally bus-off.

  10. 10.If a LIN network operates at 19.2 kbps, how long does it take to transmit a 64-byte message?Numerical

    A LIN frame carries at most 8 data bytes, so 64 bytes needs 8 frames. Each frame has a 34-bit header (break, sync, protected ID) and a response of 8 data bytes plus a checksum, each sent as 10 bits, so 34 + 90 = 124 bits. At 19.2 kbit/s one frame takes 124 / 19,200 = 6.46 ms, so 8 frames take about 51.7 ms nominally, not counting gaps between frames, which the schedule adds. Simply dividing 512 bits by the bit rate (26.7 ms) ignores framing overhead and badly underestimates the time.

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?