Site Information

 Loading... Please wait...

Developing CAN FD Applications with the Raspberry Pi and the PiCAN FD Board

Posted by Wilfried Voss on

PICAN CAN Bus FD Board With Real-Time Clock For Raspberry Pi

The Controller Area Network (CAN) protocol has been a cornerstone of reliable, real-time communication in embedded and automotive systems for decades. With the emergence of CAN FD (Flexible Data Rate), the capabilities of CAN have been significantly enhanced, allowing for faster and more efficient data transmission. This paper delves into the fundamentals of Classical CAN and CAN FD, and explores how the Raspberry Pi, in combination with the PiCAN CAN Bus FD Board from Copperhill Technologies, provides a powerful, flexible platform for CAN FD application development.


1. Introduction to CAN and CAN FD

1.1 Classical CAN Overview

Classical CAN was developed by Bosch in the 1980s to meet the growing need for a robust, fault-tolerant communication system in the automotive sector. Its key features include:

  • Multi-master protocol: Any node can transmit data when the bus is free.

  • Broadcast communication: Messages are identified by IDs rather than node addresses.

  • Deterministic behavior: Priority-based arbitration allows real-time guarantees.

  • Error handling: Built-in mechanisms detect and correct transmission errors.

In Classical CAN, the maximum data payload per frame is limited to 8 bytes, and the maximum bit rate is typically 1 Mbps. While this was sufficient for many automotive and industrial applications, modern systems require higher bandwidths due to the increasing complexity of sensors and control systems.

1.2 The Evolution to CAN FD

CAN FD was introduced by Bosch in 2012 to overcome the limitations of Classical CAN. It retains backward compatibility with Classical CAN but introduces key enhancements:

  • Extended payload length: Up to 64 bytes of data per frame.

  • Flexible data rate: Data phase can operate at speeds up to 8 Mbps or higher.

  • Improved protocol efficiency: Better bandwidth utilization by separating arbitration and data phases.

These improvements enable CAN FD to support applications such as real-time sensor fusion, advanced driver-assistance systems (ADAS), and industrial automation, where high-throughput and real-time reliability are critical.


2. The Raspberry Pi as an Embedded Systems Platform

2.1 Overview and Advantages

The Raspberry Pi is a low-cost, single-board computer developed by the Raspberry Pi Foundation to promote computer science education and rapid prototyping. Its advantages for embedded systems include:

  • Affordability and Accessibility: Wide availability and low price point make it ideal for development and deployment.

  • Broad I/O Support: GPIO, SPI, I2C, UART interfaces make it compatible with a variety of sensors and peripherals.

  • Strong Software Ecosystem: Support for Linux-based operating systems (e.g., Raspberry Pi OS) and extensive libraries for hardware interfacing.

  • Community and Documentation: A massive user community contributes tutorials, libraries, and tools.

The Raspberry Pi’s combination of computing power, expandability, and community support makes it ideal for developing and deploying embedded CAN FD applications in fields such as automotive, robotics, and industrial control.


3. The PiCAN FD Board by Copperhill Technologies

The PiCAN CAN Bus FD Board with Real-Time Clock is a hardware extension specifically designed to enable CAN FD communication on Raspberry Pi platforms. Key features include:

  • MCP2517FD CAN controller: A dedicated SPI-based CAN FD controller by Microchip.

  • MCP2562FD CAN transceiver: Ensures robust physical layer compatibility for CAN FD.

  • Real-Time Clock (RTC): DS3231 chip maintains accurate timestamps, even during power cycles.

  • Onboard 120-ohm termination resistor: Selectable via jumper, ensures proper CAN bus impedance.

  • GPIO header passthrough: Allows stacking with other HATs (Hardware Attached on Top).

  • Wide input voltage support: 7–24V DC input with onboard voltage regulator.

This hardware package offers a comprehensive solution for CAN FD communication, making it ideal for prototyping and deploying real-world embedded systems.


4. Setting Up the Development Environment

4.1 Hardware Setup

To use the PiCAN FD board with a Raspberry Pi, follow these basic steps:

  1. Mount the PiCAN FD board onto the GPIO header of the Raspberry Pi.

  2. Connect the CAN_H and CAN_L lines to the target CAN network.

  3. If the PiCAN is at the end of the CAN network, enable the onboard termination resistor.

  4. Provide power to the system through the Raspberry Pi or the PiCAN board’s external input.

4.2 Software Setup

The Raspberry Pi must be configured to support SPI and CAN interface:

  1. Enable SPI Interface:

    • Run sudo raspi-config and enable SPI under the “Interfacing Options.”

  2. Install CAN Utilities:

    sudo apt-get update sudo apt-get install can-utils
  3. Install MCP2517FD Driver: The MCP2517FD driver may need to be compiled from source or installed via an overlay. Copperhill provides setup scripts or documentation for this.

  4. Load Kernel Modules:

    sudo modprobe mcp251xfd
  5. Bring Up the CAN Interface:

    sudo ip link set can0 up type can bitrate 500000 dbitrate 2000000 fd on sudo ifconfig can0 up

4.3 Testing CAN FD Communication

Use cansend and candump from the can-utils package for sending and receiving messages:

  • Sending a Message:

    cansend can0 123##01122334455667788
  • Monitoring Bus Traffic:

    candump can0

These tools help validate bus connectivity and application-level logic before full integration.


5. Developing Applications with CAN FD

5.1 Application Areas

CAN FD with Raspberry Pi can be used in various domains:

  • Automotive diagnostics and telemetry

  • Industrial control systems

  • Agricultural and construction machinery

  • Smart energy and grid management

  • Robotics and autonomous navigation

5.2 Example Python Application

Using the Python python-can library:

import can bus = can.interface.Bus(channel='can0', bustype='socketcan') msg = can.Message(arbitration_id=0x123, data=[0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88], is_extended_id=False, is_fd=True) bus.send(msg)

This simple script sends a CAN FD message with 8 bytes of data. The library supports asynchronous handling, filtering, and logging for more advanced use cases.


6. Advantages of Raspberry Pi for CAN FD Development

  • Cost-Effective Prototyping: Combines affordable hardware with powerful performance.

  • Flexible Environment: Can run full Linux OS for rapid development and debugging.

  • Scalable Integration: Easily connects to sensors, actuators, and cloud services.

  • Open-Source Friendly: Compatible with Python, C/C++, Node.js, and other languages.

  • Real-Time Capabilities (via PREEMPT_RT patch): Offers real-time extensions for deterministic behavior.


7. Challenges and Considerations

  • Real-Time Performance: While Raspberry Pi is not inherently real-time, using the PREEMPT_RT kernel and careful coding can improve performance.

  • Electrical Robustness: Industrial environments may require additional protection or isolation.

  • Driver Support: Some kernel versions may not fully support MCP2517FD without custom overlays.

  • Power Supply Considerations: Ensure stable power delivery, especially in automotive or mobile environments.


8. Conclusion

The Raspberry Pi, when paired with the PiCAN CAN Bus FD board by Copperhill Technologies, becomes a highly capable platform for developing and testing CAN FD applications. From robust hardware support to a flexible and accessible software environment, this combination empowers developers to create next-generation embedded systems with minimal overhead. Whether you're building automotive test benches, industrial controllers, or robotics systems, this setup offers an affordable, open-source pathway to CAN FD prototyping and deployment.

As CAN FD becomes increasingly prevalent in modern embedded systems, having a solid, low-cost development environment is more important than ever—and the Raspberry Pi, together with PiCAN FD, delivers just that.


PICAN CAN Bus FD Board With Real-Time Clock For Raspberry PiPICAN CAN Bus FD Board With Real-Time Clock For Raspberry Pi

The PiCAN FD Board adds CAN Bus FD (Flexible Data Rate) functionality to the Raspberry Pi 3, enabling high-speed, high-efficiency communication for automotive and industrial applications. It is built around the Microchip MCP2517FD CAN FD controller and the MCP2562FD CAN transceiver, delivering robust and reliable performance.

CAN FD (Flexible Data-Rate)—developed by Bosch and standardized under ISO 11898-1—is an enhancement of the original CAN protocol. It addresses the increasing bandwidth demands of modern automotive networks by supporting faster data rates and larger data payloads of up to 64 bytes per frame.

The PiCAN FD board offers versatile connectivity through a DB9 connector or a 4-way screw terminal. An optional 5V 1A switched-mode power supply (SMPS) can power the Raspberry Pi directly via either connection.

Additional features include an onboard real-time clock (RTC) with battery backup support (CR1220 battery not included), ensuring accurate timekeeping even when the Raspberry Pi is powered off.

Software support is streamlined with an easy-to-install SocketCAN driver, making integration into Linux-based systems simple. Developers can program CAN FD applications using C or Python, making the board ideal for prototyping, diagnostics, and data logging in CAN-based systems. More information...