Additional Information

Site Information

 Loading... Please wait...

Blog

Four Channel CAN Bus to USB Gateway Using The Arduino Due

Posted by Wilfried Voss on

Arduino Due with four CAN Bus ports

In the past, I frequently received inquiries regarding the availability of a four-channel CAN Bus gateway. Such devices exist in the marketplace; however, they are usually costly, and, after all, they don't support easy customization or programming. While we at Copperhill Technologies have the ability to create such a gateway, this is primarily a matter of market potential, and we determined that the current demand did not justify the required investment of time and money. The inquiries were usually for single units, and the hardware and firmware development would need months to finish, considering that the goal would be to develop an industrial-strength device.

Nevertheless, we deemed creating a hardware prototype with the necessary driver software as an easy task since we have the prototyping hardware at hand. The result we created (see above photo) comes in the form of an Arduino Due with a dual CAN Bus Interface to support the on-chip CAN controller plus an external dual CAN Bus board with an SPI interface.

The Hardware

The core of the hardware configuration is our Arduino-Based ECU Development Board With Dual CAN Bus Interface, which utilizes the ARM processor's two onboard CAN controllers. The board comes with plenty of documentation and programming samples and even a free-of-charge SAE J1939 protocol stack. Please refer to the product information for more details.

The second component is our Dual Isolated CAN Bus HAT for Raspberry Pi. While the board is primarily intended for the Raspberry Pi, it also connects to any other embedded system. We chose the board because it provides two CAN Bus ports on a single board. The CAN Bus isolation is a plus but is not necessarily required. Alternatively, we could have used two of our MCP2515 CAN Bus Breakout Boards With SPI Interface because they use the same CAN Bus controller, the MCP2515. However, the dual-port board made the wiring a bit easier.

The Wiring

The connection between the Arduino Due and the external CAN Bus board contains:

  1. SPI Serial Interface
  2. Chip Select (Arduino Digital Output)
  3. Interrupt Signal (Arduino Digital Input)
  4. Power Supply (Arduino feeds 5 VDC to the CAN board)

The basic connection between the two SPI ports is as follows:

Arduino        ----> CAN Board
----------------------------------------
SCK            ----> SCK SPI Data Output
MISO           ----> MISO SPI Clock Input
MOSI           ----> MOSI SPI Data Input
SS             ----> CS Chip Select
Digital Output ----> INT Interrupt Output

Since we have a dual SPI interface, we chose the following:

  • CS0 = 10 - CAN0 interface using CS on digital output10
  • CS1 = 9 - CAN1 interface using CS on digital output 9
  • INT0 = 2 - CAN0 interrupt digital input 2
  • INT1 = 3 - CAN1 interrupt digital input 3

We are preparing an application note with detailed wiring diagrams, but for the time being, please refer to:

The CAN Bus Software Libraries

We use the following github resources:

Combining the two software libraries required some tweaking, and we will publish the sketch as soon as the previously mention application note is finished.

Last, but not least...

Please be aware that the above-presented solution does not represent a fully functional CAN Bus to USB gateway. This would require some additional programming. However, we have demonstrated the basic building blocks that will allow you to write your application.

Also, the hardware operates within a limited temperature range of 0 to 50C (32 to 122F), which is suitable for use under laboratory or office conditions but not necessarily in harsh environments such as offroad vehicles.

And yes, the above described application can be easily extended to support CAN-FD, and we will follow up with a corresponding post on our website.

MCP2515 CAN Bus Monitor Demo Board Kit Forms A Simple Two-Node CAN Bus Network

The MCP2515 is a low pin count stand-alone CAN Bus controller which interfaces to a microcontroller via a standard Serial Peripheral Interface (SPI). The MCP2515 is a second-generation stand-alone CAN Bus controller. It is pin and function compatible with the MCP2510 and also includes upgraded features like faster throughput, data byte filtering, and support for time-triggered protocols.The feature [...]

Read More »


SAE J1939 Programming with Arduino - The CAN Bus Interface

This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino. While the code as introduced in the previous chapter was well designed and thus is highly efficient, I inserted yet another software layer between the CAN Bus interface and the ARD1939 protocol stack.I wrote the ARD1939 source code in plain C [...]

Read More »


SAE J1939 Programming with Arduino - MCP2515 Function Calls

This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino. There are further functions, among others, for message filtering and settings masks, and they are worth being checked out for more sophisticated functions, but they are not necessary for simple CAN communication tasks.The implementation of the MPC2515 library is fairly easy: Open Arduino, [...]

Read More »


SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino - The MCP2515 Library

This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino. Microchip Technology’s MCP2515 is a stand-alone Controller Area Network (CAN Bus) controller that implements the CAN 2.0B specification. It is capable of transmitting and receiving both standard (11-bit) and extended (29-bit) data and remote frames. The MCP2515 has two acceptance masks and six acceptance filters [...]

Read More »


SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino - Microchip MCP2515 CAN Bus Controller

This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino. Microchip Technology’s MCP2515 is a stand-alone Controller Area Network (CAN Bus) controller that implements the CAN specification, version 2.0B. It is capable of transmitting and receiving both standard and extended data and remote frames. The MCP2515 has two acceptance masks and six [...]

Read More »


CAN Bus Prototyping With Arduino Uno - The MCP2515 Library

This post is part of a series about Controller Area Network (CAN Bus) Prototyping With the Arduino Uno.As with any serial networking controller, the essential functions are: InitializationRead DataWrite DataCheck StatusIn case of the MCP2515 library, these functions are represented by: Initialization: CAN0.beginRead Data: CAN0.readMsgBuf incl. CAN0.checkReceive, CAN0.getCanIdWrite Data: CAN0.sendMsgBufCheck Status: CAN0.checkErrorFunction CallsFunction:           CAN0.beginPurpose: Initializes the CAN controller and [...]

Read More »


CAN Bus Prototyping With Arduino Uno - Arduino CAN Sketches

This post is part of a series about Controller Area Network (CAN Bus) Prototyping With the Arduino Uno.The implementation of either one of the introduced CAN Bus Shields and the corresponding CAN Bus sketches went surprisingly smooth when paired with the right library software. I found several source codes for accessing the MCP2515 CAN controller, but most of [...]

Read More »