Site Information

 Loading... Please wait...

Blog

SAE J1939 C Library - Including Source Code - for CAN-Enabled PICmicro Microcontrollers

Posted by Industry News on

A Comprehensible Guide to J1939

SAE J1939 is a series of SAE recommended practices that have been developed to provide a standard architecture by which various electronic systems on a vehicle can communicate. It was developed by the Truck and Bus Control and Communications Network Subcommittee of the Truck and Bus Electrical and Electronics Committee, but its application is not restricted to truck and bus applications. SAE J1939 has been implemented in a broad range of vehicles and transportation systems.

SAE J1939 implements a communication protocol over a CAN Bus network. The CAN Bus network spans two or more interconnected Electronic Control Units (ECUs). As per the SAE J1939-11 specification, the ECUs are connected using linear shielded twisted pair wiring, with a data rate of 250 or 500 Kbits/second.

Microchip’s CAN-enabled PICmicro devices provide a robust, adaptable and low-cost means of implementing the SAE J1939 protocol on a wide variety of electronic vehicle components. The J1939 C library handles the majority of network management aspects of SAE J1939, allowing the user to focus on the primary application. The library provides support for all SAE J1939 address configurations and is easily configurable through Microchip’s Application Maestro™ utility.

For details about the PIC18 family of microcontrollers, refer to one of the CAN-enabled PICmicro microcontroller data sheets, such as the “PIC18FXX8 Data Sheet” (DS41159), the “PIC18F6585/8585/6680/8680 Data Sheet” (DS30491), the “PIC18F2585/2680/4585/4680 Data Sheet” (DS39625) and the “PICmicro® 18C MCU Family Reference Manual” (DS39500).

For details about the SAE J1939 specification, refer to the various SAE J1939 specifications, or visit http://www.sae.org.


SAE J1939 ECU Simulator Board With USB Port

SAE J1939 ECU Simulator Board With USB Port

The  jCOM.J1939.USB gateway board is a high-performance, low-latency vehicle network adapter for SAE J1939 applications. It allows any host device with a USB COM port to monitor SAE J1939 data traffic and communicate with the SAE J1939 vehicle network.

The board supports the full SAE J1939 protocol according to J1939/81 Network Management (Address Claiming) and J1939/21 Transport Protocol (TP). It is also supported by an extensive programming interface for Windows and Linux/Ubuntu applications, including full C/C++/C# source code for short time-to-market developments.

The strength of the board lies in the fact that the entire SAE J1939 protocol, including all timing requirements, is stored on-chip, thus taking the burden off the main system. The board uses a USB COM port to communicate with the main system, i.e. all data transfer is handled through a standard COM port access. 

The communication protocol between the board and the main system is well documented and thus allows a porting to any computer system with a USB connection. Working source code libraries exist for Windows (C# under Visual Studio 2012/2013), Linux and its derivatives (C++ using Code::Blocks), and Raspberry Pi (C using the standard gcc compiler).

More Information...

SAE J1939 Programming with Arduino – Function Calls Description

This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino. j1939.Initvoid j1939.Init(int nSystemTime);Initializes the ARD1939’s memory, baud rate settings, etc.nSystemTime - This is the loop time of your application in milliseconds. This information will provide the ARD1939 protocol stack a time base to manage all timers required for various protocol tasks.Ideally, the system [...]

Read More »


SAE J1939 Programming with Arduino – Application Structure

This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino. As with every Arduino application, the initialization of data and the J1939 protocol takes place during the setup() function, while the actual application resides in loop(). setup() - The j1939.Init function is mandatory to operate ARD1939. [...]

Read More »


SAE J1939 Programming with Arduino – ARD1939 Protocol Stack Reference

This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino. 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.SetAddressRange– Sets the negotiable [...]

Read More »


SAE J1939 Programming with Arduino – RTS/CTS Session Test Program

This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino. Just for kicks, I extended the previously used Arduino sketch to simulate a fully functional RTS/CTS session (yet again, the code is highly tailored to the previous RTS/CTS session). Based on that sketch, I could simulate all error scenarios on the receiver’s side.This [...]

Read More »


SAE J1939 Programming with Arduino – Conclusion

This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino. With all previous programming examples installed and explained, you should now have a pretty good grip on programming your own SAE J1939 application with the Arduino Uno and/or the Mega 2560.Yet, there are still numerous, possible scenarios for J1939 applications and all [...]

Read More »


SAE J1939 Programming with Arduino – ARD1939 Sample Application

This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino. The typical SAE J1939 ECU application not only involves the protocol stack but also a good amount of input and/or output processing. This could involve reading sensors and sending the result in form of a PGN or reading a PGN and setting [...]

Read More »


SAE J1939 Programming with Arduino – End of Message Acknowledgment Timeout

This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino. In order to test all timeouts during an RTS/CTS session, I used a dedicated Arduino sketch to simulate all the “nasty” features that would trigger a communication breakdown. This method was easier to implement rather than using a full SAE J1939 stack. [...]

Read More »


SAE J1939 Programming with Arduino – Clear to Send Timeout

This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino. The simplest test for a Clear to Send timeout is accomplished by running the Mega 2560 ECU as the only node in the network.To test this scenario, I run the Mega 2560 at an address of 0x80 (128) and attempt to initiate [...]

Read More »


SAE J1939 Programming with Arduino – RTS/CTS Session Message Timing

This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino. Note the time stamps from line 3 through line 5 of the screen shot (look at the last four numbers indicating the time in tenth of milliseconds; for instance 352.4 milliseconds in line 3). SAE J1939/21 requires a packet frequency between 50 [...]

Read More »