Blog
Recent Posts
ESP32: CAN Bus Programming with MCP2515 and MCP2517FD
Posted by
onFor good reasons, the ESP32 processor is a prevalent choice for embedded hardware development. Besides considerable memory resources, it provides various hardware features for many applications, most prominently the Internet of Things (IoT). All that comes with more than reasonable price tags, specifically when you use one of the multiple ESP32 development modules. And since we at Copperhill Technologies are primarily involved with CAN Bus, SAE J1939, and NMEA 2000 development, we welcomed the integration of an internal CAN controller. Consequently, we offer a variety of hardware components based on the ESP32 and using the onboard CAN controller, such as our SAE J1939 ECU Simulator with USB Port. Furthermore, we offer the user-programmable ESP 32 WiFi, Bluetooth Classic, BLE, and Controller Area Network (CAN) Module.
So, the question arises: Why use an external MCP2515 CAN Controller? Well, first of all, the ESP32, combined with its two SPI connections, can control up to six CAN controllers. Add the internal controller, and you get seven, even though it requires a different code. Furthermore, while the internal CAN Bus controller is much appreciated, you should be aware of some functionality limitations. These (not necessarily critical) limitations include a restricted set of baud rate settings and the lack of support for CAN FD.
We have used the available MCP2515 resources to create two products:
- ESP32 Development Board with NMEA 2000 & NMEA 0183 HAT...
- ESP32 Development Board with Dual Isolated CAN Bus HAT...
Both modules come with extensive documentation and plenty of code samples.
We are currently working on combining our espBerry board with our PICAN FD and PICAN FD Duo HATs. Both HATS use the Microchip MCP2517FD controllers. We will post an application note as soon as it is available. If you need further information, please feel free to contact us.
Github.com offers a unified library, all-inclusive of code, which implements a CAN Busdriver for the built-in CAN hardware on an ESP32. It also implements a driver for the MCP2517FD SPI-connected CAN module. The built-in CAN port is CAN0, and the MCP2517FD is CAN1. This library works directly with the EVTV ESP32-Due board. However, with minor modifications, either driver found within this library could be used on other boards.
For further information on ESP32 CAN Bus programming, see our posts:
- ESP32 Triple CAN Bus Application Through Adding Two MCP2515 Ports - Copperhill (copperhilltech.com)
- ESP32 Sketch: espBerry with Dual MCP2515 CAN Bus HAT - Copperhill (copperhilltech.com)
- ESP32 Application: Galvanically Isolated CAN Bus Repeater and Baud Rate Converter - Copperhill (copperhilltech.com)
- Arduino IDE Boards Manager - Do NOT Install ESP32 by Espressif Systems Version 3.00-alpha1 - Copperhill (copperhilltech.com)
- Dual-Channel Linear Actuator Control Module with ESP32 Processor - Copperhill (copperhilltech.com)
- ESP32, ESP32-S2 - Serial Port, Native USB Access using Arduino IDE - Copperhill (copperhilltech.com)
- espBerry Project: ESP32 with NMEA 2000 & NMEA 0183 HAT - Copperhill (copperhilltech.com)
- ESP32 with Dual Isolated CAN Port Controls Thomson Electrac Linear Actuator - Copperhill (copperhilltech.com)
- Know OBD2 Before You Start That Development Project - Copperhill (copperhilltech.com)
Connecting any CAN Bus, SAE J1939, or NMEA 2000 application to the internet is easily accomplished using the information in this post. To learn more about a connection to Bluetooth, BLE, or WiFi, we recommend the following literature:
Electronics Projects with the ESP8266 and ESP32: Building Web Pages, Applications, and WiFi Enabled Devices
Copperhill Technologies highly recommends using this book for your wireless application projects. Yes, many good books and free online resources are available these days, but this is the book we are using. It made our approach to Bluetooth, BLE, and WIFI a breeze. Programming wireless applications without hassles was fun, and we will share them on this web page.
Projects throughout the book utilize the wireless functionality and processing power of the ESP microcontrollers. Projects are built in the Arduino IDE, so you don't need to download other programming software. In addition, mobile apps are now ubiquitous, making the app build projects of the book very relevant, as are the web page design projects.
In Electronics Projects with the ESP8266 and ESP32, you'll see how easy and practical it is to access information over the internet, develop web pages, build mobile apps to remotely control devices with speech recognition, or incorporate Google Maps in a GPS route tracking app.
ESP32 Application: Galvanically Isolated CAN Bus Repeater and Baud Rate Converter
With this application, I am adding yet another example to the vast CAN library we developed over the years. The use of the Dual Isolated CAN Bus HAT with the ESP32 opens the door to a number of possible applications. The development of a CAN repeater and/or Baud Rate Converter came to mind first, because the [...]
Kvaser's Leaf v3 Supports Classical CAN and CAN FD in Silent Mode
Every professional CAN Bus development, may it be Classical CAN, CAN FD, or higher layer protocols such as SAE J1939, require a data monitoring device for a proof of functionality. Kvaser has introduced such a device, the Leaf v3 interface supporting Classial CAN and CAN FD in optional Silent Mode. The Leaf series depicts one of the [...]
Dual Isolated CAN Bus PCIe Expansion Card for Industrial, Automotive Applications
Cervoz Technology, a supplier of embedded components for the industrial PC market, has extended its industrial modular expansion cards line with the MEC-CAN-2802i, which provides two isolated CAN CC (Classical CAN) interfaces. The expansion card delivers a cost-effective solution for integrating CAN CC ports into embedded computer systems, especially in hostile environments. The board incorporates an M.2 [...]
Dual-Channel Linear Actuator Control Module with ESP32 Processor
As part of a customer project, I, with the help of a capable hardware designer, developed an embedded system to control two linear actuators, specifically the Thomson Electrac HD model with SAE J1939 interface. The Electrac series of actuators supports two higher-layer protocols (HLP) based on Controller Area Network (CAN): CANopen, and SAE J1939. CANopen is [...]
Industrial Strength Dual CAN FD Interface in Mini PCIe Format
The VL-MPEu-C1 module by Versalogic, compliant with the Mini PCIe format, is a tiny and rugged dual-channel CAN Bus add-on interface. It supports CAN-FD for high-speed data transfer but is still fully compatible with CAN 2.0 A and CAN 2.0 B (Classical CAN). It supports additional CAN functions, including message acceptance filtering, listen-only mode, and wake-up [...]
Micro CANopen Libraries for Embedded CANopen and CANopen FD Higher-Layer Protocols
Embedded Systems Academy (EmSA) announced the release of its Micro CANopen libraries as Open-CMSIS-Pack compliant with the Common Microcontroller Software Interface Standard (CMSIS) by ARM. The release simplifies CANopen implementation in embedded systems. Previously, the Micro CANopen libraries were part of selected NXP MCUXpresso software development kits (SDKs). Along with NXP's recent support release for MS [...]
ESP32 with Dual Isolated CAN Port Controls Thomson Electrac Linear Actuator
The above image shows part of a hardware setup for a customer project to control and synchronize two Thomson Electrac linear actuators. See also my posts:Thomson Electrak Linear Actuator with SAE J1939 Interface for Railway and Industrial Applications Thomson... Electrak HD Linear Actuator - Multiple Actuators in the Same Network Will Empty the Batteries... Thomson Electrac HD [...]
Know OBD2 Before You Start That Development Project
We at Copperhill Technologies offer a variety of CAN (Controller Area Network) devices for developing automotive and industrial embedded systems. In that capacity, we receive frequent inquiries regarding OBD2 (Onboard Diagnostics). OBD2, or Onboard Diagnostics Second Generation, is a vehicle diagnosis system found in modern cars and trucks. The OBD2 system collects data from sensors and [...]
SAE J1939 250k/500k Baudrate Converter with Arduino Due - Source Code Included
The introduction of 500 Kbps (see SAE J1939/14) as an alternative to 250 Kbps, required clarifications on how to solve problems that come with incorporating devices supporting different baud rate settings in the same network. One solution comes with automatic baud rate detection. The SAE J1939/16 document outlines the methods used to detect the baud rate [...]