Vector DBC To CAN M-file

From NewEagleWiki
Jump to navigation Jump to search

Vector DBC to M-file Conversion

This tool makes use of the Vector CANdbLib to convert your CAN message descriptor files from the DBC format to Matlab compatible m-files that we use for MotoHawk.

Common Errors

Error while running the *.exe file on XP:

This occurs because the motohawk_candb2mhcan application has a dependency on the Vector canDBlib. Make sure that all files from the Vector CanDBlib disk are installed. Installing the files should place the cdbmsmo.dll on the computer. If it is not installed to the Windows\System32 directory, then simply make sure the motohawk_canb2mhcan.exe and the cdbmsmo.dll are in the same directory.

Here is a helpful example of how to use this tool.

Example Model

Database Converter

Woodward has a Vector to Motohawk CAN Database Converter program available to customers. This program (p/n 8909-1044) makes it possible to take a database obtained via the Vector program and convert this to an *.m script suitable for use with MATLAB/MotoHawk.

The program can be run from a command prompt in Windows. The executable file name is motohawk_candb2mhcan.exe. The command syntax would be:

motohawk_candb2mhcan --dbcfile=filename.dbc

where filename.dbc is the name of the *.dbc (database) file to be converted. The program automatically names the output *.m script file identifiably. For example, if the database file were named j1939.dbc, the outfile filename dbc_j1939_MHCan.m would result.

For purchasing information or more details, contact Woodward sales regarding part number 8909-1044, Vector to Motohawk CAN Database Converter.

No Program Installation

When you receive the program file, you do not need to run an installation program. Just place the motohawk_candb2mhcan.exe file in a suitable folder location.

Usage Example

To use the converter program:

Note: This example presumes the *.dbc file is named j1939.dbc and is located in the same folder as the converter *.exe file.

  1. Open a command prompt; in Windows, select Start -> Run to open the Run dialog.
  2. In the Run dialog, enter cmd to open the prompt.
  3. At the command prompt, use the cd command as needed to change to the folder where the executable and database files are located.
  4. Enter the command:
    motohawk_candb2mhcan --dbcfile=j1939.dbc
    The *.m script dbc_j1939_MHCan.m is created and some output information is displayed.

To use the *.m script created

  1. Copy the *.m script file to your MATLAB Work folder or project folder location where MATLAB will find it.
  2. Place a MotoHawk Read CAN Message block where appropriate in your model.
  3. Double click on the block to open the block parameter dialog.
  4. In the Message Definition field, enter the name of the *.m script file (without the '.m' extension) and append a parenthetic parameter to pass to the message function the name of one of the messages defined. From our example, this could be:
    dbc_bodybuilder1939auxio_MHCan('Auxio_HCM')
  5. Click OK to close the block dialog, and press Ctrl-D to update the block. As a result, the MotoHawk Read CAN Message block displays the CAN message information such as the name and payload contents, and the output ports are correctly labeled to reflect the message fields for the named message (here, Auxio_HCM).

Note: The output names match the fields listed in the database editor for the Auxio_HCM shown above, and likewise listed in the *.m script shown.

A Better Way

A native DBC to CAN toolbox was created to replace or augment the use of *.m files in MotoHawk. This workflow enhancer can be found at CAN Network Toolbox for MotoHawk.