MotoHawk:Vector Database to MotoHawk CAN (.m script) Converter

From MotoHawk
Jump to navigationJump to search

Database Converter

Since the MotoHawk 2014b SP3 release, MotoHawk now includes a Vector to Motohawk CAN Database Converter script. This MATLAB script 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 script can be run from the MATLAB command prompt. The script name is motohawk_candb2mhcan. The command syntax would be:

>>motohawk_candb2mhcan('filename.dbc', fullfile(pwd,'dbc_j1939_MHCan.m'))

where filename.dbc is the name of the .dbc (database) file to be converted. The second parameter would be the desired output .m script file to be created. For example above, if the database file were named j1939.dbc, the outfile filename dbc_j1939_MHCan.m would be created in the current working directory.

Simulink Option

Since MATLAB R2017b, the Simulink blocks to Pack and Unpack CAN messages are compatible for use with MotoHawk. The Simulink Pack and Unpack blocks work directly with Vector CAN Db files. In version R2017b, Mathworks have added an option to output the CAN Message fields as a signal bus. This is enabled by the option "Output as bus." If this option is checked, the output of the CAN Pack block can be connected to the input of the MotoHawk CAN Send RAW block through the use of a bus selector.

SimulinkPackExample.jpg

More information about the Simulink Pack block can be found here:

http://www.mathworks.com/help/xpc/io_ref/canpack.html


Example Files

Here is an example of a .dbc file, as displayed in the KVaser database editor. Note the listed CAN messages in the left pane; one is selected, and its message fields are shown in the bottom-right pane under Signal Name:

DB-ed-1.png

Here is part of the .m script created from the same file as above, in a format more familiar to MotoHawk CAN message users:

M-script1.png

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')
    Block-parm1.png

  5. Click OK to close the block dialog, and press Ctrl-D to update the block. As a result, in 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 that 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.
    ReadCANblk1.png

Legacy Database Converter

Woodward has discontinued the product Vector to Motohawk CAN Database Converter (8909-1044). This was a command line program, part. no. 8909-1044, which made 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 used to be run from a command prompt in Windows. The executable file name was motohawk_candb2mhcan.exe. The command syntax was:

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. no. 8909-1044, Vector to Motohawk CAN Database Converter.