The intention of this tutorial is to provide a quick method for testing the Arduino DUE CAN shield kit after it has been put together so you can have confidence in your construction and code.
Step #1: Solder it
Assemble the shield, solder the headers, jumpers and screw terminals. At a minimum the signals needed to pass through the shield include CANH, CANL, 3.3V and GND. This means installing a minimum of 4 headers (pins 36-54 bottom half of 2×18 way header, the 8-way header that has 3.3V, 5V and gnd on it, and the 8-way that has A8-CAN TX on it). You can also install one header on the opposite side of the board such as the digital output (PWM) header to help with alignment and pin seating. You will also need to install the jumpers for the termination resistors as well. Make sure the solder joints for the headers are clean and solder does not get on to the portion of the pins that will go into the DUE sockets, this will cause poor board seating.
Step #2: Wire it
Wire the two CAN ports on the shield together: CANH -> CANH, CANL -> CANL. Install at least one of the jumpers on the termination resistors, two to be technically correct. A CAN bus should be terminated at both ends by 120 Ohm resistors. These are already on the shield, you just need to add the jumpers.
Step #3: Download Software
Download the latest Togglebit DUE CAN libraries following these instructions. Unzip and place the entire CAN folder into the “C:\Program Files (x86)\Arduino\libraries\CAN” folder (see our posting about IDE versions here if you are on an older version). Plug in the USB on the DUE programming port not the native port (flip DUE over to read labels).
Step #4: Program it
Open the IDE and go to File->Examples->CAN and select “CAN_BoardTest.ino”. Or navigate to find the “CAN_BoardTest.ino” and open it; the IDE may ask you to relocate the file into a new folder, click ok. You’ll need to have the DUE drivers installed and there is a tutorial on the arduino due website here. Make sure you have selected the proper board and port selected from Tools->Board->Arduino DUE Programming Port and Port->COMxx. Now click upload button, it will verify and upload the code to the DUE. Once completed go to Tools->Serial Monitor and make sure the baud rate is 115K.
Step #5: Check Serial Monitor Messages
The board should be running a self test at this point with CAN 1 sending data to CAN 0 and vice-versa (see code for more details). Watch the serial monitor for the following messages. NOTE: the first test will likely result in a failed message, wait for the second message to appear to get a valid test result, the test will repeat every 2 seconds.
A successful test looks like this:
/////////////////////////////////////////////////////////////////////////////// CAN0 is Receiving Data from CAN1, CAN1 is Receiving Data from CAN0, The CAN shield has passed construciton testing!
A failed test looks like this:
/////////////////////////////////////////////////////////////////////////////// The CAN shield has failed construciton testing. Here are some things to check: - remove all loopback jumpers - install jumper on at least one termination resistor - make sure wiring is CAN0 H -> CAN1 H, CAN0 L -> CAN1 L, GND -> GND - make sure the shield header pins are is properly seated on the Arduino DUE and also see www.togglebit.net notes on SPI header - see www.togglebit.net for minimum number of headers to be installed on shield
Thank you for your purchase, we wish you success!