Blog
Recent Posts
Unlocking High-Speed CAN FD Development with the PiCAN FD Board for Raspberry Pi
Posted by
onIf you're developing modern, high-speed applications on the Raspberry Pi and need access to the advanced capabilities of CAN FD (Controller Area Network with Flexible Data-rate), the PiCAN FD Board with Real-Time Clock from Copperhill Technologies is a powerful and flexible solution. This board is specifically designed to support app development involving CAN FD and integrates seamlessly with Raspberry Pi systems. Whether you're working in automotive, robotics, industrial automation, or research, this HAT (Hardware Attached on Top) empowers developers with next-gen capabilities.
Key Features of the PiCAN FD Board
The PiCAN FD Board delivers robust CAN FD functionality in a compact HAT that fits neatly on any Raspberry Pi model with a 40-pin GPIO header. Key features include:
-
MCP2517FD CAN FD Controller: Provides the enhanced CAN FD protocol capabilities.
-
MCP2562FD CAN FD Transceiver: Enables communication at higher data rates.
-
PCF8523 Real-Time Clock: Maintains accurate time, essential for data logging.
-
SocketCAN Support: Native integration with Linux networking stack.
-
Optional 5V 1A SMPS: Allows powering the Raspberry Pi through the board.
-
Flexible Connectivity: DB9 connector and 4-way screw terminal options.
This HAT is not just an interface—it is a development platform that gives engineers and developers access to high-speed, real-time communication using CAN FD, along with precise time synchronization through the onboard RTC.
CAN FD: A Leap Forward in Embedded Networking
CAN FD (Flexible Data-rate) is the evolution of the traditional CAN bus protocol. It was introduced to overcome bandwidth limitations of Classical CAN while maintaining backward compatibility. Here's why it's important:
-
Larger Payloads: CAN FD supports up to 64 bytes of data per frame, compared to 8 bytes in Classical CAN.
-
Faster Transmission: While Classical CAN is limited to 1 Mbps, CAN FD can handle up to 8 Mbps.
-
Improved Efficiency: Reduced overhead for the same data payload.
-
Error Detection: Enhanced CRC and robust error handling.
These improvements make CAN FD ideal for applications that require rapid communication and large data payloads, such as advanced driver-assistance systems (ADAS), electric vehicles, automation equipment, and more.
SocketCAN Compatibility: Native Linux CAN Support
SocketCAN is an integrated Linux kernel framework that provides a standard interface for CAN communication, similar to how Ethernet interfaces are managed. The PiCAN FD Board fully supports SocketCAN, which allows you to:
-
Treat CAN interfaces like network devices.
-
Use standard Linux networking tools (
ip
,ifconfig
, etc.) for CAN configuration. -
Integrate easily with popular Linux applications.
Example: Bringing up the CAN FD interface:
sudo ip link set can0 up type can bitrate 500000 dbitrate 2000000 fd on
sudo ifconfig can0 up
This brings the CAN FD interface online using a nominal bitrate of 500 kbps and a data bitrate of 2 Mbps.
Python Programming for CAN FD on Raspberry Pi
Python developers will appreciate how easy it is to work with the PiCAN FD Board using the python-can
library. This high-level interface allows you to send and receive CAN FD frames with just a few lines of code.
Sending a CAN FD Frame:
import can
bus = can.interface.Bus(channel='can0', bustype='socketcan')
msg = can.Message(
arbitration_id=0x123,
data=[0x11, 0x22, 0x33, 0x44],
is_fd=True,
bitrate_switch=True
)
bus.send(msg)
Receiving a CAN FD Frame:
for msg in bus:
print(f"ID: {msg.arbitration_id} Data: {msg.data}")
This makes it easy to develop diagnostic tools, data loggers, and real-time monitoring applications using Python.
Real-Time Clock: PCF8523 for Precise Timing
The onboard PCF8523 Real-Time Clock keeps accurate time even when the Raspberry Pi is powered off. This is essential for timestamping CAN messages or synchronizing events across distributed systems.
RTC Setup Steps:
-
Enable I2C using
raspi-config
-
Install required tools:
sudo apt-get install i2c-tools sudo apt-get install python3-smbus
-
Detect the RTC:
sudo i2cdetect -y 1
-
Set up the RTC manually:
sudo modprobe rtc-pcf8523 echo pcf8523 0x68 | sudo tee /sys/class/i2c-adapter/i2c-1/new_device sudo hwclock -s
Python Example (Reading Time):
import time
import board
import busio
import adafruit_pcf8523
i2c = busio.I2C(board.SCL, board.SDA)
rtc = adafruit_pcf8523.PCF8523(i2c)
while True:
t = rtc.datetime
print("Current RTC Time: {}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}".format(
t.tm_year, t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec))
time.sleep(1)
CAN FD Programming Samples
To facilitate development, the PiCAN FD board supports various programming samples. These samples demonstrate sending and receiving CAN FD messages, error handling, and integrating with other systems.
Example: Transmitting a CAN FD Message
import can
def transmit_can_fd():
bus = can.interface.Bus(channel='can0', bustype='socketcan')
msg = can.Message(arbitration_id=0x01, data=[0xDE, 0xAD, 0xBE, 0xEF], is_fd=True)
try:
bus.send(msg)
print("Message transmitted")
except can.CanError:
print("Transmission failed")
transmit_can_fd()
Example: Receiving a CAN FD Message
import can
def receive_can_fd():
bus = can.interface.Bus(channel='can0', bustype='socketcan')
while True:
msg = bus.recv()
if msg:
print(f"Received: ID={msg.arbitration_id}, Data={msg.data}")
receive_can_fd()
These examples provide a foundation for building more complex CAN FD applications.
Why Choose the PiCAN FD Board from Copperhill Technologies?
The PiCAN FD Board from Copperhill Technologies is one of a limited number of Raspberry Pi HATs on the market that supports the full features of CAN FD via the MCP2517FD controller. While there are other CAN HATs available, many are limited to Classical CAN and do not include important features like SocketCAN support, advanced transceivers, or integrated Real-Time Clock capabilities.
This board is engineered with practical development in mind:
-
Direct support for Raspberry Pi models via the 40-pin header
-
Excellent documentation and example code
-
Full compatibility with Linux tools and Python
-
Reliable components sourced from trusted suppliers (Microchip, NXP)
In summary, if your project requires true CAN FD performance with a seamless Raspberry Pi integration experience, the PiCAN FD Board is a solid, well-supported choice.
For more information or to purchase, visit: PiCAN CAN FD Board with RTC - Copperhill Technologies
In just 24 one-hour lessons, Sams Teach Yourself Python Programming for Raspberry Pi in 24 Hours guides you step-by-step through using Python to build exciting projects on your Raspberry Pi. Whether you're interested in home automation, multimedia, gaming, or robotics, this hands-on guide takes you from absolute beginner to confident creator.
Using a clear, practical approach, each lesson builds on the last—introducing essential programming concepts, real-world applications, and interactive examples. From setting up your Pi and learning Python basics, to building graphical interfaces, controlling hardware, and networking with the web, this book gives you the foundation you need for Raspberry Pi success.
Whether you're a hobbyist, student, or aspiring developer, this book provides a solid path to mastering Python on the Raspberry Pi. More information...
Enhancing Raspberry Pi 4 with PiCAN3: A Powerful CAN Bus Solution for Automotive and Industrial Applications
The PiCAN3 CAN Bus Board is a versatile expansion board designed specifically for the Raspberry Pi 4, enhancing its capabilities by providing Controller Area Network (CAN) Bus functionality. This integration is particularly beneficial for applications in industrial automation, automotive diagnostics, and embedded systems development. Key Features CAN Bus Functionality: The PiCAN3 utilizes the Microchip MCP2515 CAN controller [...]