Site Information

 Loading... Please wait...

CAN, SAE J1939, NMEA 2000 Projects with the Arduino Due - Source Code Included

Arduino-Based ECU Development Board With Dual CAN Bus Interface

Leverage the power of an ARM Cortex M3 32-bit processing capability in combination with a dual CAN Bus interface to create your next CAN Bus or SAE J1939 application or prototype. By combining our dual CAN port interface, the Arduino DUE microcontroller, an OBD2 or SAE J1939 cable, and open-source software libraries you are ready to go with powerful a turn-key Arduino-based dual CAN bus solution.

Use the vast resources of Arduino software (sketches) and hardware components (shields) to create your CAN Bus, OBD2, or SAE J1939 application.

Arduino Due Resources:

SAE J1939 250k/500k Baudrate Converter with Arduino Due - Source Code Included

There are scenarios where automatic baud rate detection does not apply, e.g., attempts to connect a 250k supporting device into an existing 500k network or vice versa, assuming that the device does not support baud rate detection. For such cases, one will require a baud rate converter. This post describes the implementation of such a converter using our Arduino-Based ECU Development Board with Dual CAN Interface. Read More...

CAN Bus Bridge (CAN-to-CAN) Application with Arduino Due

Basically, there are two scenarios where a CAN Bridge application is of use: 1. Connecting two separate CAN Bus networks, and 2. Network length extension. While the first scenario is more or less self-explanatory, let's look a little closer into the network length extension: The physical CAN network length depends primarily on the CAN baud rate, i.e. the higher the transmission speed the shorter the usable network length. 

Our application using the Arduino Due utilizes this by using a simple CAN message ID mapping table. This method also allows to assign new message IDs when it comes to preventing message ID collisions between two networks. Read More...

Arduino Due: Dual CAN Port Test Sketch with LED CAN Traffic Indicators

The post explains that the two CAN ports on the Arduino Due are practically useless without their respective CAN transceivers. CAN transceivers convert a regular TTL signal from the CAN controller into a differential voltage, which in turn contributes to the vast reliability of a Controller Area Network.

In the following, I used our Dual CAN Bus Interface for Arduino Due (as seen in above image) out of mere convenience, because the board fits directly onto the Arduino Due and does not require as much external wiring than with the breakout boards. Read More...

SAE J1939 Protocol Stack Sketch for Arduino Due

The availability of Controller Area Network (CAN) interfaces in combination with other interface technologies explains the vast popularity of the ARM Cortex-M3 processor in the CAN and SAE J1939 industry. The processor provides the means to easily and quickly create applications like CAN/J1939 gateways, CAN Bridges, J1939 ECUs, J1939 Data Logger, and many more. 

Arduino sketches (software projects) include a J1939 network scanner, and a simple SAE J1939 to USB Gateway application with associated Windows GUI (Visual Studio C# project). The collection of sketches is concluded by the ARD1939 project, a fully functional SAE J1939 protocol stack for the Arduino Uno, Mega 2560, and Due. Read More...

CAN Bus Data Traffic Simulation with Arduino Due

When working on a CAN bus or SAE J1939 project, it can be extremely helpful when the expected CAN Bus data traffic can be simulated rather than connecting your system to a running vehicle or automation control. The following project does exactly that with little effort for designing CAN data frames and their frequency.

As a hardware I have been using our Arduino-Based ECU Development Board With Dual Bus Interface. The board is not an Arduino shield in the common sense. It incorporates dual CAN transceivers required by the two integrated CAN ports on the Arduino Due while allowing the operation with any Arduino-compatible shield that supports the necessary 3.3 VDC power requirements. Read More...

SAE J1939 GPS Application with Arduino Due Delivers PGN 65267 (Vehicle Position)

I am repeating myself over and over, but the Arduino Due is my preferred choice when it comes to quick prototyping of SAE J1939 and CAN Bus applications. It is the ease of programming and the great performance that makes it all possible. In fact, I created this application in only a few hours, mostly by copying and pasting existing code.

In order to read GPS information, I added our UART GPS Module and connected it to the Arduino Due's RX1, TX1 (Serial1) port. The GPS sensor provides data according to NMEA 0183 (as does any standard GPS sensor), and decoding the data is fairly easy to accomplish with the appropriate information, the so-called NMEA output sentences, at hand. Read More...

More projects will be added over time...


CAN Gateway Design with the Arduino DueCAN Bus Development with the Arduino Due

Prototyping Controller Area Network (CAN) interfaces used to be tedious, but recent years have seen the emergence of low-cost yet easy-to-use embedded development platforms such as the Arduino, BeagleBone, Raspberry Pi, and others. This has opened the door to a myriad of applications for budget-sensitive engineers and hobbyists.

For a long time, the major misconception about Controller Area Network (CAN) was that it is merely used in automobiles. The truth is that CAN, since its introduction in 1986, has proved to be a robust, simple, and versatile technology. Consequently, CAN has found its way into all areas of applications where microprocessors need to communicate with each other.

Along with its undeniably dominant use in automobiles, CAN applications include industrial automation tasks, and any application where distributed control is advantageous and/or a serial bus system will eliminate excessive wiring. The CAN technology proved superior to any other field-bus system regarding low cost, the ability to function in a difficult electrical environment, a high degree of real-time capability, excellent error detection and fault confinement capabilities, and, almost contradictive to the previously mentioned features, ease of use.

Nowadays there is no special niche for CAN; its use is universal from any industrial application, space and aviation, maritime, medical, down to household appliances such as washers, dryers and even coffee machines.

The performance and price tag of such CAN applications depends primarily on processor power and memory resources. An 8-bit system such as the Arduino Uno may be sufficient for simple CAN applications, but the core question is, why limit the project’s performance from the get-go?

After all, the 32-bit ARM Cortex-M3 processor series is the preferred choice for Controller Area Network applications due to its internal CAN controllers, sufficient memory (Flash and SRAM), and great CPU clock speed. And yet, ARM prototyping boards are very affordable, and most IDEs are free of charge.

For this book, I have chosen one very popular system that matches my selection criteria, which are low cost and ease of programming:

The Arduino Due is the first ARM-based Arduino development board. The microcontroller is programmed through the familiar Arduino IDE (Windows, OS-X), keeping the programming as backward compatible as possible with other Arduino systems, thus allowing a smooth migration between processor systems.

In the following, I will address the aspects of Controller Area Network (CAN) prototyping using ARM Cortex M3 systems (Arduino Due and mbed NXP LPC1768). My focus will be primarily on providing the reader with the basic means, which includes describing available resources, hardware and software, and some special insights.

I will explain the basic technical aspects of Controller Area Network and higher-layer protocols such as CANopen, DeviceNet, SAE J1939, the ARM Cortex-M3 Processor, and the Arduino Due. While a detailed description of all these technologies is outside the scope of this book, I will provide references in each chapter that will enable you to gather further details.

The information provided will enable you to write your CAN applications within the shortest time.


Arduino-Based ECU Development Board With Dual CAN Bus InterfaceArduino-Based ECU Development Board with Dual CAN Bus Interface

Leverage the power of an ARM Cortex M3 32-bit processing capability in combination with a dual CAN Bus interface to create your next CAN Bus or SAE J1939 application or prototype. By combining our dual CAN port interface, the Arduino DUE microcontroller, an OBD2 or SAE J1939 cable, and open-source software libraries you are ready to go with powerful a turn-key Arduino-based dual CAN bus solution.

Use the vast resources of Arduino software (sketches) and hardware components (shields) to create your CAN Bus, OBD2, or SAE J1939 application. More Information...


The Arduino Due

There are a great number of ARM Cortex M3 developing and prototyping boards available in the marketplace. As mentioned, I have chosen one very popular system that matches my selection criteria: low-cost and easy programming. The Due is the first ARM-based Arduino development board. The programming of the microcontroller is accomplished through the familiar Arduino IDE (Windows, Mac, Linux), keeping the programming as backward compatible with other Arduino systems as possible, thus allowing a smooth migration between processor systems. However, the ease of programming often comes hand-in-hand with limited debugging capabilities, and that is also the case here for the Due and other similar systems, such as the mbed LPC1768 or the Teensy. However, I provide working programming samples, giving you a head start on any extensions and modifications.

Another downside (related to the low-cost aspect) is that such boards are useless without additional hardware components. To save costs while enabling the user to pay only for the interfaces needed for the project, the board design is limited to providing the processor with the bare necessities while routing all interfacing signals “as is” to onboard connectors.

For instance, serial interfaces such as Controller Area Network (CAN) and UART (RS-232/422/485) provide only TTL levels, and you will need additional hardware (transceivers) to make them hardware-compliant with their respective standards.

Development and breakout boards are solutions to overcome these restrictions. In addition, so-called Arduino shields can extend the Due’s functionality. Still, in the case of the previously mentioned serial interfaces, shields don’t make much sense since the serial ports are already integrated into the board.

System Description

According to the official Arduino website, the Arduino Due is a microcontroller board based on the Atmel SAM3X8E ARM Cortex-M3 CPU. It is the first Arduino board based on a 32-bit ARM core microcontroller. It has 54 digital input/output pins (of which 12 can be used as PWM outputs), 12 analog inputs, 4 UARTs (hardware serial ports), an 84 MHz clock, a USB OTG capable connection, 2 DAC (digital to analog), 2 TWI, a power jack, an SPI header, a JTAG header, a reset button, and an erase button.

The board contains everything needed to support the microcontroller; to get started, simply connect it to a computer with a micro-USB cable or power it with an AC-to-DC adapter or battery. The Due is compatible with all Arduino shields that work at 3.3V and are compliant with the 1.0 Arduino pinout.

The Arduino Due has two USB ports available. The Native USB port (which supports CDC serial communication using the SerialUSB object) is connected directly to the SAM3X MCU. The other USB port is the Programming port. It is connected to an ATMEL 16U2, which acts as a USB-to-Serial converter. This Programming port is the default for uploading sketches and communicating with the Arduino.

The programming port's USB-to-serial converter is connected to the SAM3X's first UART. The Arduino programming language allows communication over this port using the Serial object.

The Native port's USB connector is directly connected to the SAM3X's USB host pins. Using the Native port enables you to use the Due as a client USB peripheral (acting as a mouse or keyboard connected to the computer) or as a USB host device so that devices can be connected to the Due (like a mouse, keyboard, or Android phone). This port can also be used as a virtual serial port using the SerialUSB object in the Arduino programming language.

CAN Bus Hardware Interface

The Arduino Due provides two CAN communication ports whose pins are referred to as CANRX0, CANTX0, CANRX1, and CANTX1. While these pins support the CAN communication protocol, they are not supported by the Arduino APIs.

As I explained previously, the Arduino Due needs the corresponding CAN transceivers to be fully CAN compliant. The solution is additional hardware, which is available in various variations from various electronics vendors.

There are two basic variations of CAN transceiver boards for the Due:

  1. CAN Breakout Boards
  2. CAN Shields

CAN Breakout boards may require breadboards to allow for proper wiring. The advantages of breakout boards are primarily low pricing and the option of using only one CAN port.

While more expensive, CAN shields will fit right onto the Arduino Due and require no further wiring beyond the CAN Bus connection.