Using model states captured on the target

조회 수: 2 (최근 30일)
Piotr Sawko
Piotr Sawko 2024년 9월 12일
편집: akshatsood 2024년 9월 18일
Does anyone have any experience in using the block states/block signals captured on the target as the initial state for MIL testing in Simulink?
The use case here is that the product would capture the states of the algorithm when a set of conditions is met to allow bug identification and fixing.
It seems from the documentation that only by selecting the Save final operating point option in Simulink one can use the captured states as Initial states in another simulation. If this option is not selected then the states can be investigated but not realy used to repeat the behaviour of the model.

답변 (1개)

akshatsood
akshatsood 2024년 9월 18일
편집: akshatsood 2024년 9월 18일
I understand that you are looking to use the block states or signals captured on the target as the initial state for Model-in-the-Loop (MIL) testing in Simulink. The primary goal is to capture the states of the algorithm when specific conditions are met, enabling you to identify and fix bugs. Here is a general approach to achieve this:
  • Capture Block States: As you have noted, you can capture block states when certain conditions are met. This is typically done using Simulink's data logging capabilities or by saving final operating point of simulation.
  • Saving the Final Operating Point: By enabling the "Save final operating point" option, Simulink allows you to save the complete state of the model at the end of a simulation. This saved state can then be used as the initial state for subsequent simulations, which is crucial for reproducing and diagnosing issues.
  • Using Operating Points: Once you have saved an operating point, you can load it into your model to set the initial conditions. This is done using the "Simulink.op.ModelOperatingPoint" object.
  • Reproducing the Issue: By setting the initial state of the model to the captured operating point, you can reproduce the behavior that led to the bug. This allows for targeted testing and debugging.
  • Debugging and Fixing: With the ability to reproduce the issue, you can use Simulink's debugging tools, such as breakpoints and data inspection, to identify the root cause of the problem and make necessary corrections.
  • Iterative Testing: After making changes to the model, you can repeat the process to ensure the issue is resolved and that no new issues have been introduced.
If you find that the "Save final operating point" option does not meet your needs, consider the following alternatives:
  • Custom Logging: Implement custom logging to capture specific states or signals of interest. You can log signals by marking them for logging in your Simulink model by right-clicking on the signal line in the model and select "Log Selected Signals." which can be observed in the Simulink Data Inspector.
  • Simulink Test: If you have access to Simulink Test, consider using it to manage test cases and automate the testing process, including setting initial conditions and capturing results.
Please refer to the resources attached below for better understanding
I hope this helps.

제품


릴리스

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by