Case Studies

SAE J1939 Controller Area Network (CAN) Drivers for LabVIEW Applications

Posted in Aerospace and Defense, Automotive, Battery Pack Test Systems, Embedded Development & Programming, Energy and Utilities, Green Technology, LabVIEW, Manufacturing Automation and Intelligence, Test & Measurement Automation


DMC developed a set of J1939 protocol drivers for LabVIEW which are based on the NI-CAN channel API provided by National Instruments (NI).  DMC needed to interface to a customer's automotive ECU over CAN using the SAE J1939 protocol as part of an automated test application.  Since the application was written in LabVIEW and the test station used NI-CAN hardware, the drivers were entirely written in NI LabVIEW.  The drivers provide functions at a layer above the base CAN channel layer, allowing the simultaneous capture of data from both poll-and-response J1939 packets, and broadcast CAN frames.


Background of CAN and SAE J1939 Protocol

Controller–area network (CAN or CAN-bus) is a vehicle bus standard designed to allow microcontrollers and devices to communicate with each other within a vehicle without a host computer.  CAN is a message packet based protocol, designed specifically for automotive applications, but also found in other areas such as industrial automation and medical equipment.

NI-Can PXI Card

As the CAN standard does not specify functionality of the application layer (such as flow , device addressing, or transportation of data blocks larger than one message frame) many implementations of higher layer application protocols have been created to meet different user needs.

One example of such a higher level CAN protocol is specified by the Society of Automotive Engineers (SAE) as J1939.  The SAE J1939 protocol is widely used for communication between components of medium and heavy duty trucks, busses, agricultural implements, and construction equipment.


The J1939 standard is defined in multiple documents corresponding to five of the seven OSI layers.  J1939-11 defines the physical layer, J1939-21 defines the data link and transport layer, J1939-31 defines the network layer, and J1939-71/73 defines the application layer.  J1939-81 describes network management.  J1939 messages are built on top of CAN 2.0b and make specific use of extended frames, which use a 29-bit CAN identifier.

Basic NI-CAN Drivers for LabVIEW

National Instruments provides a variety of CAN hardware which works seamlessly with the NI-CAN drivers provided within LabVIEW.  The basic LabVIEW CAN drivers are divided into two different groups.  The NI-CAN Frame API drivers collect and output CAN data at the frame level.  Using these drivers, the programmer has to convert raw binary data into engineering units directly within their LabVIEW application.  The NI-CAN Channel drivers collect the same CAN frame data, but converted directly into engineering units using parameters stored inside a referenced CAN database file (*.dbc or *.ncd).  Most importantly, these two flavors of CAN driver cannot be used simultaneously to read and/or write data on the same physical port.

While NI provides LabVIEW several tool-kits and add-ons for a variety of other higher level CAN protocols such as ISO-15765, UDS, KWP2000, ODB, and CCP/xCP, they do not provide direct LabVIEW support for SAE J1939.  NI provides several partial application examples for J1939 on; however, these examples are built on top of the NI-CAN Frame API.  While using the example code, a programmer would not be allowed to use the Channel API, which provides obvious advantages for converting between broadcast CAN frames and engineering data.

Third-party J1939 protocol stacks written in other programming languages are available from a variety of vendors.  While LabVIEW would support their integration into a application, this approach is not seamless and would require additional licenses and associated reproduction costs.

SAE J1939 Drivers for LabVIEW using NI-CAN Channel API

With the above limitations in mind, DMC wanted to leverage the power and flexibility of the NI-CAN Channel API to read, write, and request J1939 protocol data.  By using the Channel API to perform higher level J1939 transactions, simultaneous use of the Channel API and the J1939 protocol fully supported.  This allows the simultaneous capture of data over both transaction-based J1939 packets, and simple broadcast CAN frames.  Moreover, the integration of J1939 CAN drivers with LabVIEW is seamless, leading to higher reliability and robustness.

NI-CAN J1939 LabVIEW Drivers

While the entire SAE J1939 specification is not fully implemented, the most critical aspects have been completely written and tested.  For this particular project, DMC specifically required the use of the Parameter Group Number PGN request service, and the diagnostic message (DM) commands, DM1, DM2, DM3, DM11, and the very important DM14 /DM15 / DM16 exchange.  Broadcast Area Announcement (BAM) transactions are supported along with multi-frame transport packets, enabling the exchange of long data sets.  These base functions could easily be used to implement any missing or custom functionality required within the J1939 specification.

With these tools, DMC was able to fully communicate with the customers ECU using high level J1939 transactions, while simultaneously reading and writing broadcast engineering data with the ease of the NI-CAN channel API.

LabVIEW Block Diagram

More information on the LabVIEW J1939 Drivers, including a free download.

Customer Benefits

  • Robust Performance:  Provided by seamless integration of J1939 CAN drivers directly into LabVIEW.
  • Lower Cost:  Additional third party Licenses are not required to reproduce the application.
  • Flexibility:  Additional J1939 functionality is easily incorporated since code is entirely LabVIEW based.


  • NI LabVIEW Developer Suite
  • NI-CAN Channel API
  • NI-CAN Hardware
  • SAE-J1939 Standards