Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Component Documentation

How to Use CAN BUS: Examples, Pinouts, and Specs

Image of CAN BUS
Cirkit Designer LogoDesign with CAN BUS in Cirkit Designer

Introduction

The Controller Area Network (CAN) bus is a robust and efficient communication protocol designed to enable seamless data exchange between microcontrollers and devices in real-time. Originally developed for automotive applications, the CAN bus has become a standard for various industries due to its reliability, fault tolerance, and ability to operate without a host computer. It is particularly well-suited for environments where multiple devices need to communicate efficiently and reliably.

Explore Projects Built with CAN BUS

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Dual Raspberry Pi 2B CAN BUS Communication Interface with Pushbutton Interaction
Image of BSP4: A project utilizing CAN BUS in a practical application
This circuit features two Raspberry Pi 2B microcontrollers connected to separate CAN BUS modules, forming a CAN network for data exchange. A pushbutton is included for user interaction, interfaced with GPIO pins on both Raspberry Pis.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino UNO WiFi CAN Bus Interface with Sensor/Actuator Module
Image of CAN : SN65HVD230 via NS-LS2(LevelConverter)2: A project utilizing CAN BUS in a practical application
This circuit features two Arduino UNO R4 WiFi microcontrollers interfaced with NS-LS2 light sensors and CAN_SN65HVD230 CAN bus transceivers. The Arduinos are configured to read light intensity data from the NS-LS2 sensors and communicate with each other over a CAN network, likely for a distributed sensing application. Power distribution is managed with 3.3V and 5V connections to the respective components, and the ground connections are shared across the devices to complete the circuit.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino Nano OBD-II Data Logger with TFT Display and CAN Bus Interface
Image of inzynierka: A project utilizing CAN BUS in a practical application
This circuit is an OBD-II vehicle diagnostic interface that uses an Arduino Nano to communicate with a vehicle's CAN bus via an MCP2515 CAN controller. It includes a 7805 voltage regulator to step down the vehicle's 12V supply to 5V, powering the Arduino and other components, and a 1.44-inch TFT display for visual output. A pushbutton is also included for user interaction.
Cirkit Designer LogoOpen Project in Cirkit Designer
STM32 and ESP32 CAN Bus Communication System with MCP2515
Image of CAR HACKING: A project utilizing CAN BUS in a practical application
This circuit integrates multiple microcontrollers (STM32F103C8T6, ESP32, and Raspberry Pi Pico W) with MCP2515 CAN controllers to facilitate CAN bus communication. The microcontrollers are connected to the MCP2515 modules via SPI interfaces, and the circuit includes USB-to-serial converters for programming and debugging purposes.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with CAN BUS

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of BSP4: A project utilizing CAN BUS in a practical application
Dual Raspberry Pi 2B CAN BUS Communication Interface with Pushbutton Interaction
This circuit features two Raspberry Pi 2B microcontrollers connected to separate CAN BUS modules, forming a CAN network for data exchange. A pushbutton is included for user interaction, interfaced with GPIO pins on both Raspberry Pis.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of CAN : SN65HVD230 via NS-LS2(LevelConverter)2: A project utilizing CAN BUS in a practical application
Arduino UNO WiFi CAN Bus Interface with Sensor/Actuator Module
This circuit features two Arduino UNO R4 WiFi microcontrollers interfaced with NS-LS2 light sensors and CAN_SN65HVD230 CAN bus transceivers. The Arduinos are configured to read light intensity data from the NS-LS2 sensors and communicate with each other over a CAN network, likely for a distributed sensing application. Power distribution is managed with 3.3V and 5V connections to the respective components, and the ground connections are shared across the devices to complete the circuit.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of inzynierka: A project utilizing CAN BUS in a practical application
Arduino Nano OBD-II Data Logger with TFT Display and CAN Bus Interface
This circuit is an OBD-II vehicle diagnostic interface that uses an Arduino Nano to communicate with a vehicle's CAN bus via an MCP2515 CAN controller. It includes a 7805 voltage regulator to step down the vehicle's 12V supply to 5V, powering the Arduino and other components, and a 1.44-inch TFT display for visual output. A pushbutton is also included for user interaction.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of CAR HACKING: A project utilizing CAN BUS in a practical application
STM32 and ESP32 CAN Bus Communication System with MCP2515
This circuit integrates multiple microcontrollers (STM32F103C8T6, ESP32, and Raspberry Pi Pico W) with MCP2515 CAN controllers to facilitate CAN bus communication. The microcontrollers are connected to the MCP2515 modules via SPI interfaces, and the circuit includes USB-to-serial converters for programming and debugging purposes.
Cirkit Designer LogoOpen Project in Cirkit Designer

Common Applications and Use Cases

  • Automotive systems (e.g., engine control units, airbags, and infotainment systems)
  • Industrial automation and robotics
  • Medical devices and equipment
  • Building automation (e.g., HVAC systems)
  • Aerospace and marine systems
  • IoT devices requiring real-time communication

Technical Specifications

The CAN bus operates based on a differential signaling method, ensuring high noise immunity and reliable communication. Below are the key technical specifications:

General Specifications

Parameter Value
Communication Speed Up to 1 Mbps (Classical CAN)
Voltage Levels 2.5V (dominant) and 0V (recessive)
Maximum Nodes 120 devices per bus
Bus Length Up to 40 meters at 1 Mbps
Protocol Standard ISO 11898-1 and ISO 11898-2

Pin Configuration and Descriptions

The CAN bus typically uses a 2-wire differential signaling system. Below is the pin configuration for a standard CAN transceiver module:

Pin Name Description
CAN_H High-level CAN signal (dominant state: 3.5V, recessive state: 2.5V)
CAN_L Low-level CAN signal (dominant state: 1.5V, recessive state: 2.5V)
VCC Power supply for the transceiver (typically 5V or 3.3V)
GND Ground connection
RX Receive data pin (connects to the microcontroller's RX pin)
TX Transmit data pin (connects to the microcontroller's TX pin)

Usage Instructions

How to Use the CAN Bus in a Circuit

  1. Connect the Transceiver Module: Use a CAN transceiver module (e.g., MCP2551 or SN65HVD230) to interface the CAN bus with your microcontroller.

    • Connect CAN_H and CAN_L to the CAN bus lines.
    • Connect VCC and GND to the power supply.
    • Connect the RX and TX pins to the corresponding UART pins on the microcontroller.
  2. Add Termination Resistors: Place 120-ohm resistors at both ends of the CAN bus to prevent signal reflections.

  3. Configure the Microcontroller:

    • Set the baud rate to match the CAN bus speed (e.g., 500 kbps).
    • Initialize the CAN controller with the appropriate settings (e.g., filters and masks).
  4. Write and Read Data:

    • Use the microcontroller's CAN library or API to send and receive messages.
    • Messages are typically sent in frames, which include an identifier, data length, and payload.

Important Considerations and Best Practices

  • Ensure all devices on the CAN bus operate at the same baud rate.
  • Use twisted-pair cables for CAN_H and CAN_L to minimize electromagnetic interference (EMI).
  • Avoid long stubs (branch connections) to maintain signal integrity.
  • Verify that the total bus length and number of nodes comply with the CAN standard.

Example: Using CAN Bus with Arduino UNO

Below is an example of how to use the CAN bus with an Arduino UNO and an MCP2515 CAN module:

#include <SPI.h>
#include <mcp_can.h>

// Define the SPI CS pin for the MCP2515 module
#define CAN_CS_PIN 10

// Initialize the MCP_CAN object
MCP_CAN CAN(CAN_CS_PIN);

void setup() {
  Serial.begin(115200); // Start serial communication for debugging
  while (!Serial);

  // Initialize the CAN bus at 500 kbps
  if (CAN.begin(MCP_ANY, 500000, MCP_8MHZ) == CAN_OK) {
    Serial.println("CAN bus initialized successfully!");
  } else {
    Serial.println("Error initializing CAN bus.");
    while (1);
  }

  // Set the CAN bus to normal mode
  CAN.setMode(MCP_NORMAL);
  Serial.println("CAN bus set to normal mode.");
}

void loop() {
  // Example: Sending a CAN message
  byte data[8] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
  if (CAN.sendMsgBuf(0x100, 0, 8, data) == CAN_OK) {
    Serial.println("Message sent successfully!");
  } else {
    Serial.println("Error sending message.");
  }

  delay(1000); // Wait 1 second before sending the next message
}

Troubleshooting and FAQs

Common Issues and Solutions

  1. No Communication on the CAN Bus:

    • Cause: Incorrect baud rate or wiring.
    • Solution: Verify that all devices are configured with the same baud rate and check the wiring.
  2. Bus Errors or Data Corruption:

    • Cause: Missing or incorrect termination resistors.
    • Solution: Ensure 120-ohm resistors are placed at both ends of the CAN bus.
  3. Intermittent Communication Failures:

    • Cause: Excessive bus length or poor cable quality.
    • Solution: Use shorter cables and twisted-pair wires for CAN_H and CAN_L.
  4. Microcontroller Not Receiving Data:

    • Cause: Incorrect RX/TX pin connections.
    • Solution: Double-check the connections between the transceiver and the microcontroller.

FAQs

Q: Can I use the CAN bus for non-automotive applications?
A: Yes, the CAN bus is widely used in industrial automation, medical devices, and other fields requiring reliable communication.

Q: What is the maximum data payload for a CAN message?
A: The maximum payload for a Classical CAN message is 8 bytes. For CAN FD (Flexible Data-rate), it can be up to 64 bytes.

Q: Do I need a specific library to use the CAN bus with Arduino?
A: Yes, libraries like mcp_can are commonly used to interface with MCP2515-based CAN modules.

Q: Can I connect devices with different voltage levels on the same CAN bus?
A: Yes, but you will need level shifters or transceivers that support the voltage levels of all devices.