constant compare only drives one reset
2 次查看(过去 30 天)
显示 更早的评论
In the attached simple test I have a simple step counter from -5000 to +5000. The constant compare block drives the 'Delay' reset and the 'Stop' However, the stop never triggers but the delay reset does as shown by the scope. Is this a bug or do I need to somehow split the output of the constant compare?
2 个评论
Jonas
2021-5-7
Why would you want to reset the Delay block when you are stopping the simulation anyway?
I recreated your model but I am getting algebraic loop errors.
采纳的回答
Jonas
2021-5-7
The root-cause is because the Delay block is Direct Feedthrough. This means that it processes its inputs and directly sets the new outputs in one timestep.
What happens is the Delay block will output a value for which the condition '>5000' is true. This condition resets the Delay block, and within the same cycle, the output of the delay block resets to zero, which renders the '>5000' condition to false again. After this has happened, the STOP block will be executed, which never sees a 'true' input.
This mechanism is also the root-cause why you are getting an algebraic loop error.
When you display the execution order you see the 'STOP' block is executed last, and because of the algebraic loop, the brief moment the condition is true is removed again.
2 个评论
Jonas
2021-5-10
If you add another Delay block before the compare to constant, the value will be '>5000' for one cycle time which you can use to drive another signal. Also, it breaks the algebraic loop.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!