Blog
Recent Posts
SAE J1939 Programming with Arduino - ARD1939 Function Overview
Posted by
onThis post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino.
The programming of every serial communication (such as RS232, CAN, Ethernet, just to name a few) should follow a very simple sequence:
- 1.Initialization
- 2.Read data
- 3.Write data
- 4.Check status
These four function calls should be everything a programmer needs to access the serial protocol, and there is no reason why an SAE J1939 protocol stack implementation should not follow the same scheme. Digging inside complex code in order to understand how to access protocol functions is simply a waste of time.
Unfortunately, most commercially available protocol stacks shine through complexity and/or lack of documentation. To mention it upfront, the ARD1939 protocol stack requires only very few function calls and thus enables the programmer to put the protocol into use in a very short time.
The functions available to the SAE J1939 application layer (i.e. your program) are:
Initialization
- j1939.Init – Initializes the protocol stack settings
- j1939.SetPreferredAddress – Sets the preferred node (source) address
- j1939.SetNAME – Sets the ECU’s NAME using the individual parameters
- j1939.SetMessageFilter – Sets the PGNs to be processed in your application
Read/Write – Check Status
- j1939.Operate – Handles the address claim process, reads PGNs from the vehicle network, and delivers the current protocol status (Address Claim in progress, Address Claim successful, Address Claim failed)
- j1939.Transmit – Transmits data to the vehicle network and handles the Transport Protocol (TP)
Other Application Functions
- j1939.Terminate – Resets the protocol stack settings
- j1939.GetSourceAddress – Delivers the negotiated node address
- j1939.DeleteMessageFilter – Deletes a message filter
For a detailed description of these function calls, please refer to the appendix “ARD1939 Protocol Stack Reference.”
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.
SAE J1939 Programming with Arduino - J1939 Data Traffic Simulation
This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino. In a previous project (see chapter SAE J1939 Simulation Example) I demonstrated the simulation of SAE J1939 data traffic. However, the messages in that example were transmitted within a certain frequency. In the following, we will transmit messages according to user input. As before, [...]
SAE J1939 Programming with Arduino - J1939 Data Traffic Monitoring
This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino. In the following Arduino sketch, “data traffic monitoring” means nothing else but receiving and displaying SAE J1939 data messages (Refer also to chapter Receiving J1939 Message Frames). Rather than creating a new project, we will only need to add a few code lines [...]
SAE J1939 Programming with Arduino - J1939 Network Scanner
This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino. Just like the previous project (See chapter Receiving and Responding to J1939 Request Frames) we will be using the SAE J1939 Request Message, in this case to inquire node addresses from the vehicle network. The Request Message (a.k.a. the Request for Address Claimed [...]
SAE J1939 Programming with Arduino - A Simple SAE J1939 to USB Gateway
This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino. I deem it necessary to provide a definition of “SAE J1939 to USB Gateway,” because there are several variants of gateway applications.If you browse through the Internet in search for J1939 gateways, you will primarily find CAN gateways that support the [...]
SAE J1939 Programming with Arduino - Receiving J1939 Message Frames
This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino. This Arduino project provided a bit of a challenge after I had forgotten my own advice.Note: In order to test a CAN/J1939 application, you need at least two CAN/J1939 nodes to establish a network communication. The second node can be another Arduino [...]
SAE J1939 Programming with Arduino - SAE J1939 Monitoring Examples
This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino. The following chapter is primarily about SAE J1939 data monitoring, i.e. the Arduino projects as described work mainly in “Listen-Only” mode. Any bidirectional communication with the vehicle bus requires an SAE J1939 protocol stack implementation, specifically the address claim process. Without a node (source) [...]
SAE J1939 Programming with Arduino - SAE J1939 Stress Simulator
This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino. The increased flexibility in combination with the finer timer resolution we reached in the previous project allows us the easy implementation of another task, namely a stress simulator.Stress simulator, in this case, means increasing the vehicle bus load and thus “stress testing” [...]
SAE J1939 Programming with Arduino - Arduino Code (Sketch) Advanced Program Version
This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino. While the previous programming sample proves the simplicity of developing an SAE J1939 data traffic simulator, I deemed it necessary to improve the code in way that makes simulation extensions and modifications easier. The two elements that needed improvement were the message [...]
SAE J1939 Programming with Arduino - Arduino Code (Sketch) Proof of Concept
This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino. The result was tested with an ADFweb CAN-to-USB Gateway in combination with its Windows-based CAN Bus analyzer tool. As the screen shot below shows, the PGN 65267 (Vehicle Position: 0x18FEF320) is received every 5 seconds, while PGN 65269 (Ambient Conditions: 0x18FEF530) appears every [...]