|
KiKadKiKad
|
CAN HAT for Raspberry Pi
CAN HAT for Raspberry Pi
Raspberry Pi 4 Model B : https://amzn.to/3S8a9vY (Amazon)
Raspberry Pi Zero 2 W : https://amzn.to/3S949mq (Amazon)
Look! A hat! 🎩
This little board extends the Raspberry Pi with a CAN interface, a 5V regulator to supply the Pi with power and a pin header to access some GPIO lines.
Specifications
Mechanical
The board outline and component placement conform to the Micro HAT specification and the Add-On Boards and HATs specification. It is designed to fit the Raspberry Pi Zero, but can also be mounted to other models. (Pi 2, 3, 4, ...)
Instead of the usual DB9 connector found on many CAN interface boards, the CAN HAT has terminal blocks for easier wiring and a smaller footprint.
For added stability, 11mm spacers should be mounted between the Pi and the HAT.
Electronics
The circuit is built around the Microchip MCP2515 CAN Interface Controller, connected to SPI port 0 on the Raspberry Pi, and a CAN transceiver IC.
It is highly recommended to use a 5V CAN transceiver with a separate 3.3V input for the RX/TX pins, such as Texas Instruments SN65HVD541. When using a different transceiver without split voltage, the voltage inputs must be reconfigured through solder bridges JP3 and JP4.
The SN65HVD541 also supports disabling the transceiver through pin 8. This pin is connected to ground via JP2 and 0Ω resistor R5 by default, which enables the transceiver at full speed. With JP2, it can be connected to Raspberry Pi pin GPIO22, which makes it controllable. Not that this is not supported by the MCP2515 device drivers and must be implemented manually. R5 is useful for transceivers that support slope control, but this is not available in the SN65HVD541.
See the section "Transceiver Configuration" below.
To reduce interference on the CAN bus, tuned microstrips were used to connect the CAN transceiver to the terminals on the PCB. The differential impedance is matched to 60Ω. For added fun, the pair length is also matched with meanders.
Aside from the CAN interface part, an additional ID EEPROM ensures conformance with the HAT specification. JP1 is only needed to program the EEPROM. The part can be left out if desired, and the connection be made by other means, such as a screwdriver or a temporary solder bridge.
The left side of the board is populated with a 6-24V to 5V step-down converter. If the Raspberry Pi is powered via USB, the components for this converter should not be soldered, or at least not be connected to a power source. It's also possible to power the Rasberry Pi from a 5V source via this connector directly. See the section "Power Options" below.
Note that the AP63205 regulator is rated for a maximum current of 2A. The Add-On Boards and HATs specification recommends at least 2.5A, but 2A is normally sufficient unless a lot of peripherals and USB devices are used. The Raspberry Pi 3 and the CAN HAT will only draw a few hundred mA when using Ethernet and the CAN bus and no other external peripherals.
Overvoltage protection is done through the TVS diode D1, but note it cannot handle overcurrent. The fuse may not react quickly enough if a large amount of energy is sent through D1, and it may still fail to protect the circuit.
Transceiver Configuration
The recommended transceiver SN65HVDA541 has separate voltage inputs for the logic and the CAN transceiver. In the default configuration, the logic is connected to 3.3V and the transceiver to 5V.
If transceiver power control should be possible from the Raspberry Pi, cut the solder bridge from JP2 (IOCTL) pins 1-2 and connect 2-3 instead. Note that this is not supported by the driver and must be implemented separately.
For over transceivers, the 3.3V power supply should be disconnected by cutting JP3 (3VIO) and choosing an appropriate voltage on JP4 (VBUS). 1-2 is 5V and 2-3 is 3.3V. Note that there is no input voltage protection on the MCP2515, which is powered from 3.3V. Choosing a 5V part may result in damage to the MCP2515.
If the chosen transceiver supports slope control on pin 8, JP2 should be left in position 1-2 and the 0Ω resistor R5 should be replaced with an appropriate value. Refer to the transceiver's data sheet for more information.
Power Options
⚠️ Do not connect a power source to both the Raspberry Pi and J5!
Power the Raspberry Pi and the CAN HAT is possible via different means.
You can power the Raspberry Pi directly, for example via USB. In this case, it will provide both the 5V and 3.3V to the HAT. If this is the only power option you want to support, you can leave out the voltage regulator comprised by J5, F2, D1, D2, C9, U4, C10, L1, C12 and C13.
It's also possible to connect the terminal block J5 to the 5V supply, bypassing the voltage regulator. Connect the solver bridge JP5 and leave out the voltage regulator as described before. Be careful not to send more than 5V to the Raspberry Pi or you will destroy it.
When using the step-down converter, the input polarity is protected by D7. However, because the negative terminal is directly connected to the ground plane and the CAN bus ground, polarity reversal may still lead to a short-circuit via other bus components. Avoid connecting a power source in reverse.
Cabling and Termination
It is recommended to use twisted pair or star quad cabling to connect other CAN nodes. With star quad cables, connect opposite wires together to the same terminal for better noise resistance.
Use shielded cable if possible and make sure all CAN bus components share a common ground. To facilitate connecting the bus ground, there is a ground terminal for each CAN connection, marked with an earth sign (⏚).
If the Raspberry Pi is the last node in a chain, attach a 120Ω termination resistor to the terminals marked with a downwards arrow (↓).
⚠️ Note the polarity on the terminals! CAN does not support swapping the H/L pins.
GPIO Pins
For added convenience, 4 Raspberry Pi GPIO pins are available via an optional connector on the board. If you would like to use them, solder the J3 header.
R11, R12, R13, R14 are optional pull-up resistors. When using the GPIO lines as external inputs, you can solder 1k-10k resistors into them. A ground pin for toggling the logic level is available on the pin header.
The 4 GPIO lines are: GPIO19, GPIO20, GPIO21, GPIO26. GPIO19-21 are also available for SPI, but this requires custom configuration and is outside the scope of the CAN HAT.
Note: To actually use the GPIO pins, you must edit eeprom_settings.txt to suit your custom configuration, or enable the GPIO pins from user space after booting the Raspberry Pi.
Integration
The built-in ID EEPROM contains device information according to the HAT ID EEPROM Specification, as well as a Device Tree blob. This allows for automatic configuration when Linux boots.
The EEPROM can be programmed in the field by shorting the jumper JP1 and flashing with the help of eepromutils.
The provided Makefile will compile a DeviceTree overlay and the device descriptor into an EEPROM image. To build the image, type:
make
To flash the image to the attached EEPROM, you first need to allow access to the first I²C bus. On the Raspberry Pi, this bus is used for several system components, and hidden by default to avoid accidental access. Put the following line into /boot/config.txt:
dtparam=i2c_vc=on
Short the write protection jumper, reboot, and flash the EEPROM:
sudo make flash
Remove the line from /boot/config.txt and the jumper, then reboot.
The preconfigured I²C bus and and device address correspond with the AT24C32E chip on the HAT. Change them in the Makefile if you use a different device.
The CAN bus should then appear automatically as network device can0.
Compatibility
The HAT is fully compatible with the Linux drivers for the MCP2551. Refer to the CAN bus on raspberry pi quick guide for more information on how to configure the device manually.
This may be necessary on older Raspberry Pi boards that don't support the ID EEPROM feature.
During testing, you can use the following command to quickly load the driver without the ID EEPROM:
sudo dtoverlay mcp2515-can0 oscillator=16000000 interrupt=12
Note that the interface still needs to be brought up like a network device:
sudo ip link set can0 up type can bitrate 125000 loopback off sample-point 0.75
This configures a line speed of 1MHz. Commonly supported rates are 125kHz or 1MHz. Choose according to your other CAN components and wiring quality.
Links
Data Sheets
Microchip MCP2515 CAN Interface Controller
Microchip MCP2551
Texas Instruments SN65HVD234 3.3 V CAN Transceiver
Microchip AT24C32E 32Kbit Serial EEPROM
Diodes Inc AP63205 Buck Regulator
Original by : https://github.com/onitake/canhat
CAN HAT for Raspberry Pi
*PCBWay community is a sharing platform. We are not responsible for any design issues and parameter issues (board thickness, surface finish, etc.) you choose.
- Comments(0)
- Likes(3)
- Bradley Nichols Jan 29,2024
- Engineer Aug 29,2023
- EL M Nabil Aug 11,2023
- 1 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
-
10design
-
10usability
-
10creativity
-
10content
More by EL M Nabil
- CANPico v2 Raspberry Pi Pico : https://amzn.to/41P4ZYQ (Amazon)The Yes We CAN repositoryThis repository contain...
- OBD II GPS Tracker OBD II GPS Tracker OBD ii GPS tracker is the most convenient vehicle GPS tracking device. This track...
- LoRa Pro Mini LoRaProMini - A low power LoRaWAN NodeA LoRaWAN sensor node, based on ATmega328P MCU (Arduino Pro Mi...
- CAN HAT for Raspberry Pi CAN HAT for Raspberry PiRaspberry Pi 4 Model B : https://amzn.to/3S8a9vY (Amazon)Raspberry Pi Zero 2...
- GNSS HAT for Raspberry Pi Raspberry Pi 4 Model B : https://amzn.to/3S8a9vY (Amazon)Introduction to mosaicHATWhat is mosaicHAT?...
- HoneyPi - Connect various sensors To Raspberry Pi HoneyPi-PCB 3.0xRaspberry Pi 4 Model B : https://amzn.to/3S8a9vY (Amazon)Raspberry Pi Zero 2 W : htt...
- GamePort USB adapter - necroware Necroware's GamePort AdapterFor more information: https://github.com/necroware/gameport-adapterFor R...
-
-
Helium IoT Network Sensor Development board | H2S-Dev V1.2
90 0 0 -
-
-
-
-
-
3D printed Enclosure Backplate for Riden RD60xx power supplies
176 1 1