Mechanical Simulation Corporation: CarSim

Legacy/internal identifier: CARSIM-2

Vendor information

Vendor

Web page

Product name

Version

Mechanical Simulation Corporation

https://www.carsim.com

CarSim

CarSim 2019 - 2023

Categories

MDL 🛈

APL 🛈

BAN 🛈

BMA 🛈

SVC 🛈

DGN 🛈

FIU 🛈

EES 🛈

FCT 🛈

DBG 🛈

IMG 🛈

AUDIO 🛈

ENVSIM 🛈

ENVCOM 🛈

✓

Platform

Operating system

Support

Windows

✓

Linux

Ports

Specifics

Basic information on dealing with environmental simulations can be found in section Tab Environment Simulation.

With the CarSim tool connection, tools from the VehicleSim product family can be controlled remotely. This includes:

  • CarSim

  • TruckSim

  • BikeSim

  • SuspensionSim

This documentation refers specifically to CarSim, but can also be applied analogously to the other VehicleSim products, such as TruckSim.

To use CarSim with ecu.test, it is necessary to register the “CarSim.exe” as COM server. To do this, enter the command “{path to CarSim.exe}” /RegServer in a command prompt with administrator rights. Further information is available in the CarSim documentation in section VS COM Interface.

To connect to a running instance of CarSim with ecu.test, CarSim must not be started via the “CarSim.exe” file. Instead, CarSim must be started via the automation interface (COM API). The following code shows this as an example:

import time
import win32com.client

com = win32com.client.Dispatch('CarSim.Application')  # Starts CarSim

alive = True
while alive:  # Infinite loop to keep CarSim open, destroying the COM connection would close CarSim
    try:
        com.GetProgFolder()  # Check if CarSim is alive
    except:
        alive = False

    time.sleep(1)

ecu.test will then automatically connect to the running CarSim instance without any further settings have to be made.

For reading and writing parameters the test steps are to be used preferentially. The modification of parameters with a leading * in the name is not supported by the test steps, since these can only be specified in the CarSim GUI. Instead, the tool jobs ReadValue and WriteValue should be used. A parameter should always be read and written either via the test steps or the tool jobs.

Supported execution modes

The CarSim connector allows the execution of scenarios in different ways. This refers to the used solver / simulator as well as the time mode to be configured in ecu.test. Supported solvers are the CarSim built-in solver and various external solvers.

The CarSim built-in solver provides a blocking execution mode where a scenario is executed from start to end without any pauses. In this mode additional operations, like reading signals etc. are not possible. Therefore execution is not controlled via the test steps Start Simulation and Stop Simulation but by calling the tool job RunMathModel that blocks the test case execution until the scenario end is reached. The blocking execution is only available when using the time mode “real time”. Therefor real time or determine automatically (default) must be selected as time source in the test configuration.

Supported external solvers and corresponding tool jobs:

  • Mathworks Simulink: RunSimulink

  • dSPACE SCALEXIO platform: RunScalexio

  • NI-RT systems: RunNIRT

These tool jobs convert the scenario and transfer it to the respective platform. The simulation must be started separately via the respective platform (e.g. by ControlDesk for the SCALEXIO platform). For these tool jobs, real time or determine automatically (default) must be selected as time source in the test configuration.

The tool jobs also provide the parameter ExecuteBlocking. This is set to True by default. If the parameter is filled with the value False, the respective tool job does not block the test case until the end of the scenario. To ensure the proper operation of the CarSim connection, waiting for the end of the simulation must be done by the user in this case. There are two options for this:

  • Using of the tool job IsSimulationRunning (recommended) The return value of this tool job indicates whether a simulation is still running. Only if the value False is returned the simulation is finished.

  • Using the Wait test step with a high enough value for the wait time, so that the simulation is definitely completed within this time span.

Alternatively to the blocking mode, the CarSim built-in solver offers scenario execution in stepwise simulation mode. For this the ENVSIM port must be selected as time source in the test configuration and the time mode must be set to stepwise or determine automatically. In this execution mode the simulation is always paused and only advanced by using wait test steps (or read test steps with time options). The test steps Start Simulation and Stop Simulation are used to start and stop the scenario. During scenario execution reading signals is possible.

The continuous simulation mode, which is another fundamental time mode offered by ecu.test, is not supported by this connector.

Limitations

The stepwise simulation mode is only supported from CarSim 2017.1.

Writing signal values is not supported.

Only .erd files are supported for recording. The ERD format will be automatically activated by ecu.test.