Quick Start of CarSim Simulation (23) - S-Function Module in CarSim&Simulink Co-simulation

Simulink S-Function Block

In order to work with external software such as Simulink, the VS math model is run from a wrapper module that links the used VS library to other environments. The wrapper communicates with the calling environment in the standard way for that environment. Figure 11 shows the relationship between the Simulink model, the VS S-function wrapper DLL, and the VS library.

Figure 11. Running a VS math model with Simulink

The VS browser starts a Simulink model, prepares the input files needed to create and run the VS mathematical model, and sends commands to Simulink. During runtime, there is close communication between Simulink and the wrapper DLL, and between the wrapper and the VS library.

Simulation tools, such as Simulink, have standard methods for communicating with program modules, using arrays of imported variables and exported variables. VS Math models are compatible with this approach: they include hundreds of variables referenced in the equations of motion, but these variables are nominally zero. They also have thousands of output variables available. In addition to setting parameters and tables for simulated vehicle and test condition properties, the data set read by the VS math model can include commands to activate import and export variables, which is required for cooperation with external models.

The VehicleSim product comes with a library of four S-function blocks. Figure 12 shows the blocks available in CarSim; similar S-function blocks are also available in BikeSim and TruckSim.

Figure 12. C

Guess you like

Origin blog.csdn.net/xiaoming0907/article/details/129943817