Raspberry Pi CAN-Bus interface
Configuring CAN-Bus interface
General information
The following instructions are written primarily for the Experimental Avionics FDR unit, however they are largely applicable to any MCP2515-based hardware working with Raspberry Pi
FDR unit uses NiRen MCP2515 CAN-Bus adapter wired to the Raspberry Pi as follows:
CS pin – GPIO 8/ Pin 24
INT pin – GPIO 25/ Pin 22
Some nicie writeups about configuring CAN on Raspberry Pi:
https://www.raspberrypi.org/forums/viewtopic.php?t=141052&start=100
https://harrisonsand.com/can-on-the-raspberry-pi/
http://wiki.rdu.im/_pages/Application-Notes/Software/can-bus-in-linux.html
Instructions
Enable the SPI Bus by editing the /boot/config.txt
sudo nano /boot/config.txt
Add the following lines
dtparam=spi=on dtoverlay=mcp2515-can0,oscillator=8000000,interrupt=25 dtoverlay=spi-bcm2835
This will configure the CAN Bus adapter to work at the speed of 500Kbs.
Reboot.
sudo reboot
Edit /etc/network/interfaces
sudo nano /etc/network/interfaces
Add the following lines
auto can0 iface can0 inet manual pre-up /sbin/ip link set can0 type can bitrate 500000 up /sbin/ifconfig can0 up down /sbin/ifconfig can0 down
Restart the Pi
sudo reboot
Initialize the CAN interface by entering:
sudo /sbin/ip link set can0 up type can bitrate 500000
Install can-utils
sudo apt-get install can-utils
Confirm the can board can read data from the bus.
For that
- connect the FDR unit to the CAN-Hub
- connect any sensor board (AHRS or Module-A) to CAN-Hub
- power up the CAN-Hub
- run the following command
candump can0
You should be able to the stream of CAN messages