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” a certain SAE J1939 device. The question for many developers is whether or not their device can handle increased busload and still function according to specification.
As a fair warning upfront, the following project has its limits in terms of reaching maximum busload (100%) due to hardware limitations (Arduino clock time) and the maximum timer resolution of 1 millisecond. The average J1939 message takes roughly 540 microseconds to transmit, and sending it every one millisecond will result in a busload of maximal 50%.
Sending two consecutive messages within one millisecond cycle can easily increase the busload, but this is also the case where we reach the hardware limitations. Further improvements could be accomplished through implementing an interrupt service routine for message transmission and a timer resolution finer than that provided by the delay() function. This would, however, result in a great deal of code tweaking, and the efforts would not be worth the result.
The easiest solution to maximum busload is actually running the same program on two Arduinos connected to the same bus.
Note: An SAE J1939 busload of 60% is considered extremely high (100% would be continuous data flow) and is thus sufficient for a stress test.
In the J1939_Stress_Test project, I have simply copied the previous project and use the same PGNs to transmit. However, in the loop() function I have decreased the timer values to 1 millisecond, meaning the program will send two messages within one millisecond. According to my ADFweb CAN Bus analyzer software, this creates a busload of 57%.
In another variant, I loaded the same program onto another Arduino simultaneously connected to the same network, however, played with the number of transmitted PGNs and their frequency:
- 1 message every 2 milliseconds: Busload = 76%
- 1 message every 1 millisecond: Busload = 79%
- 2 messages every 1 millisecond: Busload = 79%
My assumption is that the ADFweb interface’s limit is at 79%, which is not a bad value. Due to internal latency times, you will hardly find any CAN Bus gateway that comes close to 100%, unless you are willing to spend some major money.
I will refrain from posting any of the project’s code here, since it is almost identical to the previous one.
Note: This Arduino project is available through the download page at ARD1939 - SAE J1939 Protocol Stack for Aduino.
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.