Main Content

Generate ASAP2 and CDF Calibration Files

Generate and customize an ASAP2 file and a CDF (Calibration Data Format) file for a model by using the Generate Calibration Files tool. By default, the tool generates the latest supported version of the A2L file according to ASAM MCD-2 MC standards. You can choose to generate a different version. You can customize the options for calibration files, such as the version for the A2L file and the schema type, for the CDF file. For more information on the ASAM MCD-2 MC (ASAP2) standard and the ASAM CDF Standards, see the ASAM website at www.asam.net.

Open Generate Calibration Files Tool

  1. Open the model.

  2. Open the Embedded Coder app.

    Note

    For AUTOSAR models, open the AUTOSAR Component Designer app. And for Simulink Real-Time models, open the Simulink Coder app.

  3. Generate code for the model.

  4. On the C Code tab, select Share > Generate Calibration Files.

Note

For AUTOSAR models, select Autosar > Share > Generate Calibration Files.

Using the tool, you can generate A2L and cdfx files at the same time for a model. You can use the tool for models configured with an ERT-based, GRT-based, Simulink Real-Time, AUTOSAR Classic, or AUTOSAR Adaptive system target file. The tool remembers the last used settings, such as the version of the ASAP2 file, include or exclude comments, turn off or on the ASAP2 file and CDF file generation. Simulink saves these settings in the MATLAB preferences. The settings will override the default settings.

For AUTOSAR classic models, the tool allows you to include or exclude RTE elements into the ASAP2 file by using the Include AUTOSAR RTE elements option. The RTE elements in the generated ASAP2 file will use RTE API service call names.

ASAP2 File Generation

ASAP2 defines the description format of the internal ECU variables used for tuning parameters and measuring signal data as an application executes. To generate an ASAP2 file:

  1. By default the Generate ASAP2 option is enabled. If it is not enabled, slide the Generate ASAP2 switch to the On position to enable A2L generation.

  2. To change the name of the A2L file, in the File name field, specify the name.

  3. By default, the code generator uses the build folder for the folder path of the selected model. If you want to specify a different folder path for the A2L file, you can do that in the Folder path field.

  4. To replace ECU addresses in the A2L file, in the Symbol file field, provide a symbol file associated with the application executable. Otherwise, clear the Address replacement field.

    The tool supports an ELF, PDB, or DWARF file as a symbol file to replace the ECU addresses.

  5. Set Version to the required version of the A2L file to be generated. The default version is 1.71.

  6. To exclude comments in the A2L file, clear Include comments.

  7. For AUTOSAR classic models, to exclude RTE elements in the A2L file, clear Include AUTOSAR RTE elements.

  8. To exclude generation of separate files for CompuMethods and record layouts, clear Include shared elements.

  9. To exclude referenced model data elements in the A2L file, clear Include referenced models.

  10. Click Generate.

To generate the A2L file programmatically, use the coder.asap2.export function.

CDF File Generation

ASAM CDF defines the data description format for storing the ECU parameter values and the associated meta data. The ASAM CDF files use XML, which can be easily validated, edited, imported, and exported by calibration tools and XML editors. To generate a CDF file by using the tool:

  1. Slide the Generate CDF switch to the On position.

  2. To change the name of the CDF file, specify it in the File name field.

  3. By default, the code generator selects the build folder for the folder path of the selected model. If you want to specify a different folder path for the CDF file, in the Folder path field, specify the path.

  4. Use the Schema type field to set to XSD (XML Schema Definition) or DTD (Document Type Definition). The DTD schema type is the default.

To generate the CDF file programmatically, use coder.cdf.export function.

Note

CDF file generation is disabled for Simulink Real-Time system target file.

Generate ASAP2 and CDF Data Definition Files

This example shows how to export ASAP2 and Calibration Data Format (CDF) files for data measurement and calibration using the Generate Calibration Files tool.

ASAP2 standard defines the description format of the internal electronic control unit (ECU) variables used in measurement and calibration and ASAM CDF standard defines the data for storing the ECU parameter values and the associated meta data. These standards are proposed by the Association for Standardization of Automation and Measuring Systems (ASAM). For more information about ASAM MCD-2 MC and ASAM CDF standards, refer to www.asam.net.

This example uses ASAP2Demo.slx and ASAP2DemoModelRef.slx models.

Build ASAP2Demo Model

Open the ASAP2Demo model.

open_system("ASAP2Demo");

Build the model to generate C Code for both the parent model ASAP2Demo and the child model ASAP2DemoModelRef.

slbuild("ASAP2Demo");

Open "Generate Calibration Files" Tool

On the C code tab, select Share > Generate Calibration Files to open the Generate Calibration Files tool.

You can customize the calibration file generation settings such as filename, the destination folder, include or exclude comments in the file.

Generate ASAP2 File

Follow these steps to generate the ASAP2 file for the model.

  1. Move the Generate ASAP2 switch to On position. By default, the Generate ASAP2 switch is in the On position.

  2. Specify a name in the File name field to change the name of the file from ASAP2Demo.

  3. Specify the path for the A2L file in the Folder path field. By default, the A2L file is generated in the build directory.

  4. Provide a symbol file associated with the application executable in the Symbol file field, to replace ECU addresses in the A2L file. Otherwise, uncheck the Address replacement field. The tool supports an ELF, PDB, DWARF file as a symbol file to replace the ECU addresses.

  5. Set Version option to the required version of the A2L file to be generated. The default version is 1.71.

  6. Uncheck Include comments option to exclude comments in the A2L file.

  7. Uncheck Include referenced models option to exclude referenced model data elements in the A2L file.

  8. Click Generate.

To generate the A2L file programmatically, use this command.

coder.asap2.export("ASAP2Demo");

Generate CDF File

Follow these steps to generate the CDF file for the model.

  1. Move the Generate CDF switch to the On position. By default, the Generate CDF switch is in the On position.

  2. Specify a name in the File name field to change the name of the file from ASAP2Demo.

  3. Specify the folder path for the CDF file in the Folder path field. By default, the CDF File is generated in the build directory.

  4. Choose the Schema type field as XML Schema Definition (XSD) or Document Type Definition (DTD). By default it is set to DTD schema type.

  5. Click Generate.

To generate the CDF file programmatically, use this command.

coder.cdf.export("ASAP2Demo");

You can verify that the calibration files are generated in the specified folder. Now, you can use these calibration files for calibration and measurement of the application.

See Also

| |

Related Topics