-
Notifications
You must be signed in to change notification settings - Fork 159
CAN‐FD add‐on (MCP2518FD)
Some batteries use CAN-FD insteaf of just CAN. Batteries like Kia EV6 are moving towards the faster and more flexible CAN-FD. The LilyGo hardware does not support CAN-FD protocol, but this can be added with an extra MCP2518FD chip via the GPIO pins, similar to the CAN add-on setup.
Tip
The CAN-FD chip can also be used for normal CAN. Just enable the USE_CANFD_INTERFACE_AS_CLASSIC_CAN , and you can use the add-on chip with classic CAN batteries.
The hardware used is an inexpensive chip, "MCP2518FD Pro", which can be purchased HERE
SCK -> Pin 12
MOSI -> Pin 5
MISO -> Pin 34
CS -> Pin 18
INT -> Pin 35
GND (next to 3V3) -> Any GND pin on LilyGo
3V3 -> VDD on LilyGo
GND (next to 5V) -> Any GND pin on LilyGo (+ to GND on external 5V source)
5V -> 5V source, can be same as feeds LilyGo via the input pins
The Lilygo also has a 3V3 to 5V boost switch-mode power supply (it is used for the RS485 chip on the Lilygo). It does not have an overly convenient location for connecting, but it can be soldered to one side of C62 (side closest to C64). The Lilygo can then be powered with 12V, which can be more convenient than powering the Lilygo with 5V. See the red wire in the image below. Of course the 5V supply on the Lilygo must be enabled for this to work.
Another board built around the same "MCP2518FD Pro" chip has been shown to work once the oscillator is configured to OSC_20MHz
- see details below
The labelling on this board is slightly different:
SCK -> Pin 12
SDI -> Pin 5
SDO -> Pin 34
nCS -> Pin 18
INT -> Pin 35
GND (next to 3V3) -> Any GND pin on LilyGo
3V3 -> VDD on LilyGo
GND (next to 5V) -> Any GND pin on LilyGo (+ to GND on external 5V source)
5V -> 5V source, can be same as feeds LilyGo via the input pins
NB: Only one GND connector is technically required if the same ground is being used for the LilyGo
Start by enabling the CANFD_ADDON
flag in the USER_SETTINGS.h
file. Then configure the battery to use this CAN interface in the USER_SETTINGS.cpp
file. Select CAN_ADDON_FD_MCP2518
on the component that you intend to connect to the chip.
Note
Remember to configure crystal according to your PCB!
Depending on your add-on board, there may be different oscillator crystals. On the "MCP2518FD Pro" board, it is 40MHz, while on some others, it is 20MHz. If you don’t have a 40MHz oscillator, you need to update CANFD_ADDON_CRYSTAL_FREQUENCY_MHZ
from OSC_40MHz
to OSC_20MHz
in the USER_SETTINGS.h
file.
Example picture, board with 40.0Mhz crystal:
The default settings are 500kbit/s arbitration bit rate, and 2 Mbit/s data bit rate. Incase you have a battery that needs some other bit rate settings, this can be changed in the Software.ino file.
It is possible to log CAN messages via USB serial, by enabling the DEBUG_CANFD_DATA
option in USER_SETTINGS.h