How to execute a k-step predictor within a real-time Simulink model
Mostra commenti meno recenti
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
Risposte (1)
Hari
il 13 Nov 2024
0 voti
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:
- 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.
- 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.
- 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.
- 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:
- For details on using Model Reference blocks, refer to the documentation at https://www.mathworks.com/help/simulink/slref/model.html.
- Information on Function-Call Subsystems can be found at https://www.mathworks.com/help/simulink/ug/using-function-call-subsystems.html
- To explore optimization techniques for Simulink models, the following page might be useful: https://www.mathworks.com/help/sldo/
- For understanding asynchronous executions, see https://www.mathworks.com/help/matlab/matlab_prog/asynchronous-functions.html
Hope this helps!
Categorie
Scopri di più su Deployment, Integration, and Supported Hardware in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!