DMC, Inc.
LIN Communication in LabVIEW with NI-XNET

LIN Communication in LabVIEW with NI-XNET

Modern vehicles rely on dozens of low-cost embedded nodes to control everything from window lifts to seat heaters. Many of these devices communicate over LIN (Local Interconnect Network) a simple, deterministic serial bus designed for low-bandwidth automotive applications.

For engineers working in test and validation, LIN presents a unique challenge: it’s easy to wire up but not always straightforward to automate, especially when diagnostic messages (UDS) come into play. Fortunately, NI XNET provides a unified way to manage both standard broadcast LIN communication and higher-level diagnostic protocols with minimal effort.

NI XNET Hardware Setup for LIN Communication

In the simplest test scenario, we have a PC based bus master and a device under test (slave device).

LIN Bus

The bus master is a PC connected to the LIN bus through an NI compactDAQ chassis, NI-9860 XNET module, and a TRC-8456 LIN dongle.

BUS Master Hardware

Configuring Broadcast LIN Communication in LabVIEW

Configuring broadcast LIN starts by loading the LIN Definition File (LDF) into the NI-XNET Database Editor and assigning it an alias. For this example, we’ll use an example LDF from NI.

Alias Manager

Once the LDF is loaded, a simple VI can start communication with the Device Under Test. Here’s what’s happening in the below VI.

  1. Create Input and Output Sessions
    • These are RX (input) and TX (output) sessions for receiving and sending data to the Device Under Test.
    • On a test bench, it’s often necessary to enable termination at the TRC-8456 and configure the PC as the bus master.
    • Signal Single-Point Sessions handle signals rather than raw frames, so there’s no need to manually unpack frame data. “Single-Point” means XNET maintains a current-value table of signals for both input and output.
    • The front panel controls input signal list and output signal list are linked to the database, providing dropdowns to select signals to read and write.
  2. Start Sessions
  3. Assert a Schedule
    • Schedules are defined by the LDF, and the XNET controls will provide a drop-down to select a schedule to assert.
  4. While Loop
    • Continuously write and read signals
  5. Cleanup Logic
    • Stop and clear both input and output sessions
Configuring Broadcast LIN Communication in LabVIEW

Performing UDS (Unified Diagnostic Services) over LIN in LabVIEW

UDS (Unified Diagnostics Services) is another common test engineering use case. Here’s another VI showing how to talk UDS with XNET.

  1. Open Frame input and output sessions.
    • Instead of working with signals, UDS communication has more variability making reading and writing frames easier
    • Queued Sessions are used here, which store every frame seen on the bus, unlike Single-Point sessions that only track the most recent value
  2. Start Sessions
  3. Assert a Diagnostic event on the bus Master Request
  4. Write a UDS frame e.g. 0x22 ReadDataByIdentifier
  5. Wait for the transmission to complete
  6. Assert a Diagnostic event on the bus Slave Response
    • Allowing the device under test to respond
  7. Read the frames sent by the device under test
  8. For clarity, closing and clearing the sessions is not shown
Performing UDS over LIN in LabVIEW

If you’re talking LIN to devices and are ready to take your Test and Measurement project to the next level, contact us today to learn more about our solutions and how we can help you achieve your goals.