Can I decouple a time-consuming Simulink function block or Function-call subsystem from Simulink fundamental sample time?
조회 수: 2 (최근 30일)
이전 댓글 표시
I have a Simulink model performing fixed-step control algorithm in 0.1 second fundamental sample time. However when the control logic enters a certain mode, I want to carry out a time consuming calculation that will run in 100% cpu time for approximately 2 seconds. If I place this computation under any Simulink time step, it will definitely make the model overrun at that certain time step. But the result from this time consuming computation will first be needed when the normal 0.1 second fixed-step control algorithm executes for 1 minute. Can I place this time consuming computation in a Simulink function block or Function-call subsystem and decouple it from the Simulink solver? Such that the result from this time consuming computation will be placed in a data store whenever it finishes, but reading of that data store by the main algorithm will first occur after one minute? The main algorithm execution of once every 0.1 second will thus not be clogged by this time consuming computation module.
댓글 수: 2
Jonas
2021년 5월 18일
There is no such thing as model overrun in simulation mode. Your computer just calculates what it needs to calculate, if it is computationally heavy it just takes longer.
Or are you talking about code generation? I would think not since you say 'Simulink solver'.
채택된 답변
Jonas
2021년 5월 18일
You need a background task to put those heavy calculations inside.
Depends heavily on your target if it will be easy or hard to implement the background task with code generation. Some hardware support packages may support it.
I generate code with two real-time tasks in Simulink, and then manually attach each task to either a real-time timer or an infinite background while-loop in code.
댓글 수: 8
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!