Panel Cookies
How CAN Works?
11 months ago | Blogs | by: ELECTRONOOBS


This in the video is a CAN transceiver where CAN stands for Controller Area Network and is a type of serial communication. In previous videos we’ve talked about UART, i2c and SPI communications, and the Arduino UNO or NANO for example, have all these types of serial ports. But it doesn’t have a CAN bus, so what is CAN, how it works internally, why is better or worse than other types of serial communications and why we use this type of serial data transfer for the entire automobile industry? We will check the signals, explain you how they work and establish a CAN connection between an Arduino and an ESP32. So guys, let’s get started.  

 


Let’s make an example using Arduino. This is a CAN transceiver module using the TJA1050 chip. This needs an RX and TX input and it will create the differential signals on the H and L pins. But the Arduino UNO for example, can’t directly control those RX and TX pins because that’s not a normal UART port. It needs a CAN controller. For example this module has the same TJA1050 IC but it also has this CAN controller chip which is the MCP2515. This has an SPI communication it will automatically generate the TX signals or read the RX signals from the CAN transceiver. 

By the way, the Arduino DUE does have CAN controller pins but I don’t have a DUE right now. But the ESP32 also has CAN controller pins so we can use that. So I will connect the module with the CAN controller to the Arduino UNO and the CAN transceiver without the controller directly to the ESP32 as in this schematic. Then I connect the L and H lines from one module to the other. 


So for the data frame, the signal starts with a start bit so the rest of the devices will be aware that new data is coming in. Then we have the ID bits so we know to which device the data is sent. Then we have the control bit and the actual data which could be from 0 to 8 bytes of data. Then we have the CRC bits which we will talk about in a moment and finally the end frame bits. 





11 months ago | Blogs | by: ELECTRONOOBS











Last tutorials

FOC control with Arduino + magnetic encoder feedback
Laser Power Meter DIY PCB
All about Arduino PWM frequencies
Smallest ESC based on ARDUINO
Debug Arduino and ESP with PlatformIO

ADVERTISERS



Affiliate Disclosure

ADVERTISERS



PCBWAY PCB service





Curso Arduino Online nivel Intermedio