QUAD CAN BUS adapter for Raspberry Can Bus Shield
Quad CAN BUS is an open hardware to connect a couple of Can Bus Shield boards to Raspberry Pi. In this way it is possible to have 4 CAN interfaces: can0, can1, can2 and can3. The adapter is very very simple, it is a PCB with three 40 ways connectors, see the following scheme.
Raspberry Boards Compatibility
The Can Bus Shield 1 uses the standard pins (SPI 0) and it is identified as can0 and can1 with standard overlay files present in /boot/overlays, instead the Can Bus Shield 2 is remapped on the SPI1. In order to enable the interfaces can2 and can3 we must copy the can2 and can3 overlay in /boot/overlays as super user (If you want edit and recompile the overlay files dtbo download can2 and can3 dts files).
After that edit /boot/config.txt modify the following row
#In this way the SPI 1 is enabled with one chip select pin only for a Can Bus Shield one channel
#In this way the SPI 1 is enabled with two chip select pins
For the Can Bus Shield 1 the interface can0 is located in SPI0.1(X2 connector) and can1 in SPI0.0(X1 connector), instead for the Can Bus Shield 2 the interface can2 is located in SPI1.1(X2 connector) and can3 in SPI1.0(X1 connector).
Run sudo reboot
after your raspberry has been booted, go to home directory:
add these lines to the script
ip link set can0 up type can bitrate 1000000
ip link set can1 up type can bitrate 1000000
ip link set can2 up type can bitrate 1000000
ip link set can3 up type can bitrate 1000000
Run the script:
sudo sh can-start.sh
now you can see the 4 can interfaces
So the system is ready, then you can use standard can bus command to use the peripheral:
candump can0 -> to monitoring can bus traffic
cansend can0 7DF#0201050000000000 -> to send can bus commands
candump can1 -> to monitoring can bus traffic
cansend can1 7DF#0201050000000000 -> to send can bus commands
To use both interface simultaneously open 2 different telnet sessions.
Leave a Reply