Site Information

 Loading... Please wait...

SAE J1939 Programming with Arduino - Arduino Code (Sketch)

Posted by Wilfried Voss on

This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino.

SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino

The Arduino code is quite simple and virtually self-explanatory. However, let me lose a few words on the program’s structure.

First of all, depending on the CAN Bus shield used for this programming sample, please make sure you set the proper CS (Chip Select) for the CAN Bus controller as described in module can.cpp (See also my remarks in the chapter about the CAN-BUS Shield by Seeed Studio).

In the main program module J1939_Data_Traffic_simulation I defined two messages, msgVehiclePosition and msgAmbientConditons, and filled them with random data.

In the main loop I use the delay function to create a one-second timer by means of the variable nCounter. The content of nCounter triggers the transmission of the corresponding messages.

The actual program code is fairly simple:

Note: This Arduino project is available through the download page at ARD1939 - SAE J1939 Protocol Stack for Aduino.


A Comprehensible Guide to J1939

SAE J1939 has become the accepted industry standard and the vehicle network technology of choice for off-highway machines in applications such as construction, material handling, and forestry machines. J1939 is a higher-layer protocol based on Controller Area Network (CAN). It provides serial data communications between microprocessor systems (also called Electronic Control Units - ECU) in any kind of heavy duty vehicles. The messages exchanged between these units can be data such as vehicle road speed, torque control message from the transmission to the engine, oil temperature, and many more.

A Comprehensible Guide to J1939 is the first work on J1939 besides the SAE J1939 standards collection. It provides profound information on the J1939 message format and network management combined with a high level of readability.

Read more...