Additional Information

Site Information

 Loading... Please wait...

Blog

Raspberry Pi PICAN2 Functionality Test With Two PICAN2 HATs

Posted by Wilfried Voss on

Raspberry Pi PICAN2 Test Setup

The following is yet another post on testing the PICAN2 - CAN Bus Interface for the Raspberry Pi, however, with a different approach. In this case, we utilize two identical PICAN2 boards and connect them per the CAN Bus (CAN_H to CAN_H, CAN_L to CAN_L) as shown in the image above.

In the past, we have documented different methods of testing the PICAN2, which did not require the presence of a second PICAN2:

Setting up the config.txt file

The first step is to edit the config.txt file as described in the PICAN User Manual. Please make sure, you use the following settings:

dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
dtoverlay=spi-bcm2835-overlay

I have seen forum entries where users recommended different settings, but they were ultimately wrong.

After editing the file, close it and reboot the Raspberry Pi.

Initializing the CAN Bus Interface

Both PICAN2 boards need to be initialized for using the same CAN Bus baud rate:

sudo /sbin/ip link set can0 up type can bitrate 500000

Sending And Receiving CAN Bus Data Frames

In the following, I used the cansend and candump commands to exchange CAN Bus data frames between the two devices. Yet again, for detailed information on the setup and data transfer, refer to the PICAN User Manual.

Raspberry Pi PICAN2 Test - Screen Print Left Monitor

The above screen shot shows the content of the monitor to the left. As the first line shows, we transmitted a CAN message, and with the second line, we received data from the other node.

Raspberry Pi PICAN2 Test - Screen Print Right Monitor

This next screen shot shows the content of the monitor to the right. The CAN data exchange is, of course, in reversed order.


Raspberry Pi Cookbook: Software and Hardware Problems and Solutions

Raspberry Pi Cookbook: Software and Hardware Problems and Solutions

With millions of new users and several new models, the Raspberry Pi ecosystem continues to expand, along with a lot of new questions about the Pi’s capabilities. The second edition of this popular cookbook provides more than 240 hands-on recipes for running this tiny low-cost computer with Linux, programming it with Python, and hooking up sensors, motors, and other hardware—including Arduino and the Internet of Things.

Prolific hacker and author Simon Monk also teaches basic principles to help you use new technologies with Raspberry Pi as its ecosystem continues to develop. This cookbook is ideal for programmers and hobbyists familiar with the Pi through resources, including Getting Started with Raspberry Pi (O’Reilly). Python and other code examples from the book are available on GitHub.

More Information...

SAE J1939 Programmable Data Traffic Simulator For Generating Diesel Engine Signals (PGNs)

The following represents an update on our current development activities, in this case the jCOM.J1939 Programmable Data Traffic Simulator (a first prototype is shown in the image to the left).In short, the plan is that the device is being set up by means of a Windows software and then runs the programmed PGNs (Parameter Group [...]

Read More »


CAN FD To USB Gateway Project With Teensy 3.2 And Microchip MCP2517FD CAN FD Controller

Our Teensy 3.2 With CAN FD Breakout Board provides all the components needed to create your CAN FD to USB-Micro Gateway. The board comes with the Microchip MCP2517FD CAN FD controller, while the Teensy 3.2 provides the USB connection. It also has an onboard 5 VDC regulator and reverse-voltage protection. The MCP2517FD is a cost-effective and small-footprint CAN [...]

Read More »


SAE J1939 Monitor, Analyzer, And ECU Simulator For Windows - New Byte & Bit Editing Mode

The jCOM1939 Monitor Software by Copperhill Technologies is the ideal software tool for monitoring, analyzing, and simulating SAE J1939 data traffic.  The program links to our jCOM.J1939.USB ECU Simulator Board that operates as an SAE J1939 to USB (or UART) gateway.  This comprehensive and easy-to-use, easy-to-understand Windows software illustrates not only SAE J1939 data traffic; it also allows the [...]

Read More »


Controller Area Network (CAN Bus) - Physical Layer And Bus Topology

The following is an excerpt from  A Comprehensible Controller Area Network by Wilfried Voss. The ISO/OSI Reference Model specifies seven levels starting with the physical connection up to the actual user application, i.e., the Application Layer. The standard CAN Bus implementation neglects the connection between the Data Link Layer and the Application Layer to save on relevant memory resources [...]

Read More »


CAN Bus Over Ethernet Interface For Internet-of-Things (IoT) Applications

The EtherCAN HS by Kvaser is a real-time Ethernet-to-CAN gateway interface that, when connected over the Internet to an Ethernet-equipped PC, enables remote CAN Bus data access from anywhere in the world. The built-in Power-over-Ethernet eradicates the requirement for a separate power cable when it is not possible to power the device from the CAN Bus network. Kvaser's EtherCAN [...]

Read More »


Galvanically Isolated CAN Bus Transceivers Protect Networks Against Destructive Energy

High noise levels on a CAN bus network have the potential to destroy CAN bus transceivers. This noise originates mainly from two sources, ground loops and electrical line surges.Protecting a network against this destructive energy requires the galvanic isolation of the CAN bus system from other local node circuitry. For more information on Controller Area [...]

Read More »


OBD-II Data Logging With Raspberry Pi And PiCAN2 CAN Bus Interface

In all regularity, I receive inquiries from users attempting to connect their Raspberry Pi with PiCAN CAN Bus interface to their vehicle's OBD-II diagnostics port, and the questions asked prompted me to write down the essentials to consider for such a project.Please, note: The following refers to reading CAN Bus data from a vehicle's OBD-II [...]

Read More »