Example Code

CAN DBC file ECU prototype Model VI and mapping generation for VeriStand

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Operating System

  • Windows

    Programming Language

  • LabVIEW G

Code and Documents

Attachment

Description

I wrote this (some time ago) to assist in creating VIs to model the IO from other ECUs needed to support the ECU under test. 

It will scan a CAN DBC file and list the ECUs found within. It will then generate empty LabVIEW model VIs with the IO clusters created for you.

You can select an individual ECU from the list and the IO selections in the other ECUs are reduced to only those which interact with the chosen ECU. It will also export the mapping files to connect them up in VeriStand.

It is using scripting underneath to generate the VIs from scratch.

How to Use

Unzip the project and open it in LabVIEW 2021 or later.

Run the main VI and select a DBC file. It will scan and list the ECUs it finds along with the number of channels within. If you click on the red write button, it will generate empty labVIEW VIs in a subfolder with all of the IO in input and output clusters. These VIs can be populated and then converted into lvmodel or lvmodelso files withing LabVIEW.

Click on an individual ECU in the list and you will see that the IO selections in the other ECUs are downselected to only those which match the chosen ECU. Now when you write the files, only the relevant ECU VIs are generated and with only the inputs and outputs needed to communicate with your chosen ECU. You can also export the mapping files for the individual ECU VIs created and also for the whole set including the selected ECU. They will be created in the same subfolder. Import these into VeriStand to connect all of the matching IO between the model prototypes generated.

You can also downselect the channels by listing the CAN IDs if you want. Just write a delimited list into the box on the right.

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors