Additional Information

Site Information

 Loading... Please wait...

SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino - Serial Interface And CAN Bus Timing Considerations

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 hardware configuration as introduced in this book, namely the Arduino board plus CAN Bus shield, suggests that it may be well suitable for a CAN-to-USB or J1939-to-USB gateway application. However, the Arduino’s USB baud rate is limited to 115,200 baud, which is roughly half the speed of a 250 Kbit/sec J1939 connection, and roughly 11% of a full-blown 1Mbit/sec CAN application.

A reliable gateway application with the Arduino is only possible when the maximum CAN Bus baud rate is not higher than 100 Kbit/sec, otherwise there is the risk of losing messages.

All this is under the assumption that the application is supposed to catch every single data frame in the network. One way to get around the timing problem is the use of message filters, i.e. the application allows only a set of application-specific message IDs or PGNs, respectively.

The reliability of an application using message filters depends heavily on the busload, i.e. the average frequency of CAN Bus messages on the bus.

That being said, using the Arduino as a CAN-to-USB gateway comes with a potential of losing messages. Even the use of large CAN Bus message buffers does not guarantee that all messages are being received.

The situation is different with J1939 applications, because:

  • The SAE J1939 standard dictates a 250 or 500 Kbit/sec baud rate.
  • A typical J1939 application will only use a small subset of all available PGNs, which makes the use of message filters a logical choice.
  • The highest message frequency in the SAE J1939/71 standard is 10 milliseconds.
  • A busload of 60% is considered extremely high (100% would be continuous data flow).

It is therefore possible to create a full J1939-to-USB gateway with the Arduino, provided that some functionality such as effective message buffering is applied. Another measure would be to create interrupt service routines for receiving CAN Bus and USB data.

Another aspect is the communication protocol between the Arduino’s USB interface and the host system that receives the USB data. After all, in such a gateway application the CAN Bus data is being converted into USB messages (and vice versa) and these messages must have a certain format. The protocol describes the conversion of these messages.

The more information is packaged into the protocol (for instance, stuffing bytes and checksum), the longer the message will be and the longer it takes to transmit it.

The average J1939 message takes roughly 540 microseconds to transmit. It will take the Arduino’s USB port roughly 700 microseconds to transmit the same message in the best-case scenario (through stripping away CAN Bus protocol overhead and ignoring any safety features such as a checksum). Any additions to the protocol (= protocol overhead) will result in transmission times in the range of 1,000 to 2,000 microseconds.

While all this results into a slower transmission of data frames by a factor of roughly 1.4 to almost 4, the Arduino will still be suitable for a basic gateway application.

Note: Industrial-strength CAN-to-USB or J1939-to-USB gateways with their higher USB transmission rates in the Mbit/sec range use the luxury of extensive protocols that include, for instance, CAN frame time stamps.


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...