How to execute a k-step predictor within a real-time Simulink model

11 views (last 30 days)
Hi,
I'm trying to implement a k-step predictor within a real-time Simulink model. For each time step in the real-time simulation, values will be used as initial conditions in a predictor model (nonlinear Simulink model, quite extensive) and marched forward multiple time steps, and then the final predicted value is returned and carried on within the real-time simulation.
The primary concern is that the predictor model contain integrators, which cannot be run repeatedly within each real-time step. I have looked into For Loop blocks, but then I would have to write my own integrators.
Alternatively, I have looked into placing the predictor in a separate "offline model" running in normal mode, where it is called at every real-time step. The issue I ran into with this is the amount of overhead I have to load in when running the extensive predictor model, and thus it won't be completed between each real-time step.
I understand that this could be done a lot easier if the predictor model is in the form of matlab script rather than a Simulink model. However, the predictor model is quite complex, and it would be highly prefered to not needing to re-write it into script form.
I have been stuck on trying different workarounds, but without much luck. I would greatly appreciate if anyone can shed some light on directions I can take.
Thanks in advance,
Tim

Answers (1)

Hari
Hari on 13 Nov 2024
Hi Tim Teng,
I understand that you are trying to integrate a k-step predictor within a real-time Simulink model, where the predictor model is nonlinear and contains integrators. You're facing challenges with executing this predictor model in real-time due to the computational overhead and the limitations of using integrators within each simulation time step.
You can follow the below approches to overcome the challenges:
  1. Model Referencing: Use Model Reference blocks for integrating the predictor model into the real-time simulation. This method compartmentalizes the predictor, potentially reducing overhead. Ensure effective communication between the real-time model and the predictor.
  2. Function-Call Subsystems: Encapsulate the predictor model within a Function-Call Subsystem, triggered at each real-time step. Execution time management is crucial to fit within real-time constraints.
  3. Optimization of the Predictor Model: Optimize the predictor by simplifying the model, reducing blocks, and adjusting solver settings. Using fixed-step solvers and tuning the step size can improve both performance and accuracy.
  4. Asynchronous Execution: If feasible, run the predictor model asynchronously to the real-time simulation. This involves parallel execution and synchronization mechanisms for integrating outputs without violating real-time constraints.
References:
Hope this helps!

Categories

Find more on Manual Performance Optimization in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!