Updated CAN adapter docs

This commit is contained in:
Pontus Borg 2022-02-15 17:39:46 +01:00
parent fa9ed991d3
commit 6e7f8c7cc7
3 changed files with 19 additions and 25 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -4,43 +4,37 @@
You will need a CAN bus adapter for your Raspberry Pi (or other board you run klippy on). There are many options available.
### MCP2515 based CAN HATs
![Waveshare CAN HAT](wavesharecanhat.jpg)
The MCP2515 is a very common SPI connected CAN bus chip. It is a pretty bad options since it has very small buffers on chip and creates a lot of CPU load on the Raspberry Pi. It is not recomended if you use more than 1 or 2 boards.
You have to run the CAN bus at 250kbits/s or possibly 500kbits/s. An older Pi, or a Pi Zero will not work reliably, it has to be a Pi3 or Pi4 or better.
When using an MCP2515 hat you have to increase the linux CAN bus tx queue length or the system will not be stable. "ip link set can0 txqueuelen 128". This is again due to the lack of buffers in the MCP2515.
TBD: Is the MCP2517FD based HATs any better? They are made for CAN-fd but are backwards compatible. As the drivers are not in the mainline kernel it's non-trivial to get an MCP2516 to work.
An easily available option is "Waveshare RS485 CAN HAT"
The adapter must support Linux socketcan
### USB CAN adapter
![Canable USB CAN clone](canable.jpg)
There is a very good open source firmware for STM32 based USB adapters, https://github.com/candle-usb/candleLight_fw. Any board running this firmware should work fine. There are plenty of open source hardware alteratives that runs this firmware. Unforunately they can be a bit hard to buy and you have to turn to aliexpress or ebay to find clones. Search for canable or cantact.
There is a very good open source firmware for STM32 based USB adapters, https://github.com/candle-usb/candleLight_fw. Any board running this firmware should work fine. There are plenty of open source hardware alteratives that runs this firmware.
If someone can find a good board please tell me so I can recomend one.
![Inomaker USB CAN](innomakerusbcan.jpg)
The Innomaker This product is readily available on Amazon and many other places. It's optically isolated and high performace, a good product on paper.
Update Feb 2 2021: Unfortunately this adapter has bugs in the firmware that reorders incoming packets when reveiving a lot of data. It causes major problems for klipper. Not recomended!
Get one at https://openlightlabs.com/products/canable-0-4 or find a clone on aliexpress.
## Linux setup
![Innomaker CAN USB](innomakercangood.jpg)
The klipper CAN bus implementation needs a program to run on the host that tunnels serial over CAN bus to the Huvud boards.
Innomaker has an USB CAN bus adapter widely available. It had a firmware bug that was reported and fixed March 2020, newer boards should have this fixed.
https://github.com/bondus/CanSerial
### MCP2515 based CAN HATs
The program will open virtual serial ports in /tmp when boards are discovered on the CAN bus. The serial ports are named depending on the unique ID of the STM32 MCUs. Such as /tmp/ttyCAN0_0d8da6c6698e.
![Waveshare CAN HAT](wavesharecanhat.jpg)
The MCP2515 is a very common SPI connected CAN bus chip. It is a pretty bad options since it has very small buffers on chip and creates a lot of CPU load on the Raspberry Pi, and has a tendency to drop packet. It is not recomended if you use more than 1 or 2 boards or if you plan to use the accelerometer.
You have to run the CAN bus at 250kbits/s or possibly 500kbits/s. An older Pi, or a Pi Zero will not work reliably, it has to be a Pi3 or Pi4 or better.
An easily available option is "Waveshare RS485 CAN HAT"
TBD: Is the MCP2517/MCP2518 based HATs any better? They are made for CAN-fd but are backwards compatible. As the drivers are not in the mainline kernel it's non-trivial to get an MCP2517/8 to work.
## Linux and Klipper setup
Please read https://github.com/KevinOConnor/klipper/blob/master/docs/CANBUS.md
## Wiring

BIN
doc/innomakercangood.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB