Connecting nodes via virtual CAN bus channels in Simulink to create a simulation of an electric vehicle

28 views (last 30 days)
Hi,
I have a question and it would be so helpful if someone could offer some assistance: I am working on a project where me and team are trying to create an electric vehicle in Simulink and connect the modules (ECU, BMS) via CAN bus and inputting a DBC file collected from an actual vehicle to provide validation between the real world and simulation in Simulink. We are wanting to utilise the vehicle network toolbox.
I'm not sure how to link the modules via the CAN virtual channels - would anyone be able to offer some help?

Answers (1)

Hari
Hari on 12 Feb 2024
Edited: Hari on 12 Feb 2024
Hi laura medhurst,
I understand that you trying to simulate an electric vehicle in Simulink, where you need to connect different modules like ECU and BMS using a virtual CAN bus and also you want to use a DBC file for validation purposes.
You can use the CAN Communication blocks from Vehicle Network Toolbox in Simulink to set up your virtual CAN network. Here's a general approach for to do the same:
  1. Use the "CAN Configuration" block to set up the CAN bus parameters.
  2. Add "CAN Pack" and "CAN Unpack" blocks to encode and decode CAN messages according to the DBC file.
  3. Use "CAN Transmit" and "CAN Receive" blocks to send and receive messages over the virtual CAN channels.
  4. To link the modules (ECU, BMS, etc.), ensure they are on the same CAN channel and are using the correct message identifiers as defined in your DBC file.
Refer to the documentation of "CAN Communication in Simulink" for guidance on setting up and configuring the CAN network:
For information on how to use the "CAN Configuration" block, please at the "CAN Configuration" block https://www.mathworks.com/help/vnt/ug/canconfiguration.html
To understand how to encode and decode messages based on a DBC file, check out the documentation for
For details on sending and receiving messages over a CAN network in Simulink, you can refer to the documentation of CAN Receive and CAN Transmit.
Hope this helps!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!