Table of contents
foreword
Motor model simulation can be called model-in-the-loop test (MIL). As for SIL, it is software-in-the-loop simulation test. To put it bluntly, it is to verify whether there is any problem with the generated code. By generating code and then packaging the generated code into a model form, verify whether the generated code is reliable, you can test the code coverage, and verify whether the data is distorted after the code is generated. Sometimes the model simulation is fine, but the generated code behaves differently when it runs on the system. I have stepped on the pit before, so it is necessary to do SIL before going on the machine. Next, we will introduce the specific steps on how to achieve SIL.
model configuration
Configure model parameters, expand Code Generation to find Verification, and then find Advanced parameters, which are the three small dots at the bottom, and select SIL.
Since SIL is selected, you cannot check Generate code only. Here, Toolchain is automatically selected by default. If you want to debug the C code, install a Visual_studio. Here we don’t need to install it. It’s basically useless for the C code. If necessary for debugging, it is also possible to use MinGW64 for actual testing.
Get here and get ready
SIL model generation
Click on the main model to generate a SIL model for the sub-model, right-click on C/C++ Code, and select Build This subsystem.
The following window pops up, click Build
After a while, the following window will pop up, this is the SIL model that is packaged after generating the code
It can be saved for easy traceability
Copy it to the main model interface, as follows:
SIL model generation, ready for simulation comparison
Model simulation comparison
Comment out the SIL model, and first perform simulation verification on the original model, as shown in the figure below:
Then cut out the original model, replace it with a SIL model, and perform simulation verification on it
After the simulation is over, click on the Data Inspector, as shown below:
Comparing the results of the two simulations, it is almost the same without exception, which means that the generated code has no problem
Set tolerance for comparison
Summarize
It briefly introduces the steps of SIL software-in-the-loop testing. It is very simple. The deeper things can be excavated according to the needs of the process. Let’s summarize here first.