What Is CAN Bus?
Learn how a Controller Area Network Bus (CAN Bus) operates as well as its applications in different industries. This video covers how a CAN Bus connects nodes and ECUs in a single system and the specific protocols that define different CAN operations. It also highlights how traditional CAN differs from CAN Flexible Data Rate (CAN FD). You can use MATLAB®, Simulink®, and Vehicle Network Toolbox™ to directly interface with your CAN Bus and develop applications that:
- Support hardware manufacturers such as Kvaser, NI®, PEAK-System, and Vector
- Collect raw CAN data, process the data using DBC files, and visualize the results in a single environment
- Utilize the CAN Tool to work directly with your CAN Bus in an application without having to write MATLAB code
- Implement higher-level protocols such as XCP and J1939 to define CAN operations for specific applications
- Convert into C or C++ code and deploy to embedded targets
Controller Area Network, also known as CAN bus, is a standard messaging protocol that allows microcontrollers and devices to communicate with each other. CAN bus was originally designed to address wiring complexity challenges in the automobile industry, but its use has spread to other areas such as industrial automation, aerospace, and more. Nowadays, you can find CAN bus used in a variety of applications such as passenger vehicles, heavy trucks, medical equipment, and elevators.
MATLAB, Simulink, and Vehicle Network Toolbox provide functions, blocks, and apps to interface with and retrieve data from CAN busses.
CAN Bus is the system that connects nodes and electronic control units, or ECUs, in a vehicle network system. The CAN bus provides a low-level interface that allows ECUs to communicate directly with each other through a simple serial bus.
CAN FD, or Controller Area Network Flexible Data-Rate, is a protocol that builds upon CAN. The main difference between CAN and CAN FD is that the Flexible Data Rate in CAN FD allows for higher data throughput on the bus. For comparison, the maximum CAN frame is 8 bytes, while the maximum CAN FD frame is 64 bytes.
CAN and CAN FD are advantageous because of their low cost, decentralized network system, efficiency, and node flexibility.
Higher level protocols such as J1939 or XCP define communication systems on top of the CAN bus that define operations for specific applications, such as heavy vehicles for J1939 and vehicle calibration for XCP. Raw data from a CAN bus can extracted and decoded into protocol specific information using a CAN Database File, or DBC.
MATLAB and Simulink support CAN bus interfaces from manufacturers such as Kvaser, National Instruments, PEAK-System, and Vector. Vehicle Network toolbox supports CAN bus interfaces that connect directly to your PC via USB, PCI, PCI-Express, PXI, and PCMCIA.
Vehicle Network Toolbox provides Simulink blocks for generating C or C++ code from your CAN bus workflow. Certain blocks such as CAN and CAN FD Pack and Unpack support code generation for embedded targets. You can also generate code for custom targets through the documented Pack/Unpack interfaces.
Vehicle Network Toolbox, alongside MATLAB and Simulink, provides a single environment to communicate and analyze CAN and CAN FD data in cross-functional engineering workflows. You can collect raw CAN and CAN FD data directly from a CAN bus or transmit ECU data directly from MATLAB using a virtual CAN or CAN FD channel. Once you receive the CAN data, you can unpack and decode the raw data into CAN messages. You can store the CAN message logs or process them using MATLAB or Simulink algorithms and visualize the results.
The Vehicle CAN Bus monitor provides a direct interface to visualize CAN and CAN FD channel traffic without having to write MATLAB code. Using the interactive CAN tool, you can view raw data on a CAN or CAN FD channel and configure the CAN bus to filter messages of interest. You can also import DBC files into the CAN tool in order to decode and see message signal information directly. Once you have isolated all messages of interest, you can save and export the CAN bus data to log files in MATLAB.
For more information about using the CAN bus from MATLAB or Simulink, explore the Vehicle Network Toolbox product page. You can also explore the MATLAB documentation for examples on how to get started using the CAN bus.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
- América Latina (Español)
- Canada (English)
- United States (English)
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- United Kingdom (English)
- Australia (English)
- India (English)
- New Zealand (English)
- 日本Japanese (日本語)
- 한국Korean (한국어)