Documentation

Configuring the Model for Vector CANape

Setting Up and Building the Model

Set up your model to work with Vector CANape®. The following procedure uses the xpcosc model. It assumes that you have already configured your model to generate Simulink® Real-Time™ code. If you have not done so, see Set Configuration Parameters and Simulink Real-Time Options Configuration Parameters. It also assumes that you have already created a Vector CANape project. If you have not done so, see Creating a New Vector CANape Project.

  1. In the MATLAB® Command Window, type

    xpcosc
  2. Open the Simulink Real-Time library. For example, in the MATLAB window, type

    slrtlib
  3. Navigate to the Displays and Logging sublibrary and double-click that library.

  4. Drag the XCP Server block to the xpcosc model.

    This block enables an XCP server process to run in the real-time application.

  5. In the model, double-click the XCP Server block. Check the following parameters:

    • Target Address — Target IP address for target computer. The default value is slrtGetTargetSettings(`TcpIpTargetAddress'). Typically, you will want to leave the default entry. Otherwise, enter the TCP/IP address for the target computer.

    • Server Port — Port for communication between target computer and XCP server. The default value is 5555. This value must be the same as the port number you specify for the Vector MATLAB device.

  6. If you want to use the event mode to acquire signal data, set the priority of the xcpserver block to be the lowest priority. For example, enter a priority of 10000000. For Simulink blocks, the higher the priority number, the lower the priority.

  7. In the model Simulink window, click Simulation > Model Configuration Parameters.

    The Configuration Parameters dialog box is displayed for the model.

  8. In the left pane, click the Simulink Real-Time Options node.

    The associated pane is displayed.

  9. In the Miscellaneous options area, select the Generate CANape extensions check box.

    This option enables real-time applications to generate data, such as that for A2L (ASAP2), for Vector CANape.

  10. Build the model.

    The Simulink Real-Time software builds the real-time application, including an A2L (ASAP2) data file for the real-time application.

  11. On the target computer monitor, look for the following message. These messages indicate that you have built the real-time application without producing an error and can now connect to the target with Vector CANape.

    XCP Server set up, waiting for connection

You can now create a new Vector CANape project (see Creating a New Vector CANape Project.

Creating a New Vector CANape Project

This procedure describes how to create a new Vector CANape project that can communicate with a real-time application. It assumes that you have set up, built, and downloaded your model (see Setting Up and Building the Model).

  1. In a DOS window, create a new folder to hold your project. This can be the same folder as your Simulink Real-Time model files. For example, type

    mkdir C:\MyProject
  2. Start Vector CANape.

  3. Select File > New project.

    A new project wizard is displayed. Follow this dialog to create a new project.

  4. After you create the new project, start it.

    After the preliminary warning, the CANape window is displayed.

You can now configure the target computer and the loaded real-time application as a Vector CANape device (see Configuring the Model for Vector CANape).

Configuring the Vector CANape Device

This procedure describes how to configure the Vector CANape Device to work with your real-time application. It assumes the following:

  1. If you have not yet started your new Vector CANape project, start it now.

    The Vector CANape window is displayed.

  2. In the CANape window, click Device > Device configuration.

    The device configuration window is displayed.

  3. In the device configuration window, click New.

  4. In Device Name, enter a name for the device to describe your real-time application. For example, type

    SimulinkRealTime

    Add the required comments.

  5. Click Next.

  6. From the driver-type menu list, select XCP.

  7. Click Driver settings.

    The XCP driver settings window is displayed.

  8. In the Transport layer pane, from the Interface menu list, select TCP.

  9. In the Transport layer pane, click Configuration.

  10. In the Host field, enter the IP address of your target computer.

    This is the target computer to which you have downloaded the real-time application.

  11. Set the port number to 5555.

  12. Click OK.

  13. If you have Vector CANape Version 5.6.32.3 and higher, and you want to use the Simulink Real-Time software to acquire event driven data:

    1. In the Driver pane of the XCP driver settings window, click Extended driver settings.

    2. Set the ODT_ENTRY_ADDRESS_OPT_DISABLED parameter to Yes.

      With this setting, events that are generated in the Simulink Real-Time environment will be based on the model base sample time. For example, a sample time of 0.001 seconds will appear as 100 milliseconds.

    3. Click OK.

  14. In the XCP driver settings window, verify the connection to the target computer by clicking Test connection. This command succeeds only if the target computer is running and connected to exactly one development computer.

  15. Click OK.

    The Device dialog is displayed.

  16. Click Next.

    Do not exit the dialog.

You can now configure the location of the real-time application A2L (ASAP2) file for the CANape database. See Configuring the Location of the A2L (ASAP2) File.

If you want to load a new real-time application, you must close Vector CANape, download a new real-time application through the MATLAB interface, then restart Vector CANape.

Configuring the Location of the A2L (ASAP2) File

Use this procedure to configure the location of the real-time application A2L (ASAP2) file for Vector CANape. This procedure assumes that you have already configured the Vector CANape device and are still in the device configuration dialog.

  1. Clear Automatic detection of the database name.

  2. At the Database name parameter, click Browse.

    The Select database dialog box for device SimulinkRealTime is displayed.

  3. Browse to the folder that contains the A2L (ASAP2) file for the real-time application.

    This might be the folder in which you built the real-time application, or it might be the folder you specified while configuring the real-time application.

  4. Select the A2L (ASAP2) file. Click Open.

    A dialog requests confirmation of ASAP2 settings.

  5. Click Yes.

  6. Click Next.

  7. Click Next.

  8. Click Next.

  9. Click OK.

  10. You have completed the configuration of Vector CANape for the Simulink Real-Time software environment.

You can now monitor and control your Simulink Real-Time system. The CANape database should be populated with a comprehensive list of real-time application signals and parameters that are available. See Event Mode Data Acquisition.

During real-time application changes, you might need to manually reload the A2L (ASAP2) that is generated by the Simulink Real-Time build process. You can do this from the CANape Database editor.

Providing A2L (ASAP2) Files for Vector CANape

This topic assumes that:

  • You have set up and built your model to generate data for Vector CANape. If you have not yet done so, see Setting Up and Building the Model.

  • You have created a Vector CANape project folder and know the name of that project folder.

To enable Vector CANape to load the A2L (ASAP2) file for the model xpcosc:

  1. In a DOS window, change folder to the one that contains the A2L (ASAP2) file from the previous procedure. For example:

    cd D:\work\xpc

  2. Look for and copy the A2L (ASAP2) file to your Vector CANape project folder. For example:

    copy xpcosc.a2l C:\MyProject

Vector CANape automatically loads the real-time application A2L (ASAP2) file when it connects to the target computer.

Was this topic helpful?