element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Blog CANFDZeroHAT - CAN FD controller for the Raspberry Pi
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
GPIO Pinout
Raspberry Pi Wishlist
Comparison Chart
Quiz
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: bernhardmayer
  • Date Created: 31 Jan 2021 9:30 AM Date Created
  • Views 4739 views
  • Likes 5 likes
  • Comments 2 comments
Related
Recommended
  • can interface
  • arduino mkr
  • raspberry_pi
  • mkr can shield
  • can

CANFDZeroHAT - CAN FD controller for the Raspberry Pi

bernhardmayer
bernhardmayer
31 Jan 2021

The CAN bus ist widely used in many types of vehicles like cars and trucks, airplanes and now even drones. A few years ago the spec was updated and CAN FD was introduced. This upgraded the transmission speed and even more important extended the payload size from 8 byte to 64 byte. The Raspberry Pi doesn't have a CAN controller by default so this needs to be added with a HAT with an external controller.

The MCP2518FD is such a controller offered by Microchip and is connected via SPI. In the last year the driver for this controller found its way into the kernel of the raspbian distribution. So I decided to develop a HAT with it.

 

image

 

The board has only a few components:

  • the MCP2518FD CAN controller
  • a TCAN332 CAN transceiver which also supports CAN FD
  • a switch to enable the termination resistor
  • JST GH connectors
  • a terminal header to connect other CAN devices
  • and a few LEDs to show the status

In reality it looks like this:

image

It plugs directly ontop of a Raspberry Pi. In my case I used a Raspberry Pi 4.

 

The HAT is open source hardware and all the data is available on github:

 

https://github.com/generationmake/CANFDZeroHAT

 

To enable the HAT and the CAN controller in raspbian you simply have to edit /boot/config.txt and add line:

 

dtoverlay=mcp251xfd,spi0-0,interrupt=25

 

keep care that you choose the right interrupt and SPI CE line and populate the corresponding resistor.

To enable CAN after boot up you have to enter:

 

sudo ip link set can0 up type can bitrate 250000

 

So what can be done with this HAT?

 

I connected an Arduino MKR with an Arduino MKR CAN shield.

image

 

On the Arduino side I used the arduino-CAN library ( https://github.com/sandeepmistry/arduino-CAN/ ) and installed the CANSender example.

 

On the Raspberry Pi the messages can be displayed using the command candump -decaxta can0 and this generates the following output:

image

As I mentioned before the CAN bus is now also used in drones using the UAVCAN protocol ( https://uavcan.org/  ). There exists also the Dronecode standard ( https://www.dronecode.org/  ) which defines the mechanical connection for the CAN bus and that's why there are JST GH connectors on the HAT.

You can find more infos on this topice here: https://forum.uavcan.org/t/how-to-use-the-raspberrypi-with-mcp2518fd-to-debug-uavcan/1091

 

In the following picture the HAT is connected to a Zobax Orel 20 motor controller.

 

image

  • Sign in to reply

Top Comments

  • DAB
    DAB over 4 years ago +3
    Nice post. DAB
  • genebren
    genebren over 4 years ago +2
    Cool project. I have never used the CAN bus, but if I do, this looks like a handy device to have.
  • DAB
    DAB over 4 years ago

    Nice post.

     

    DAB

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • genebren
    genebren over 4 years ago

    Cool project.  I have never used the CAN bus, but if I do, this looks like a handy device to have.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube