Use of Memory Loops in Enbaled Subsystems

5 次查看(过去 30 天)
BACKGROUND:
I am trying to implement an increment/decrement counter in Simulink by using a memory loop inside an enabled subsystem. I'm running with a fixed time step of 0.002 seconds. The enabled subsystem is rising edge triggered and is fed a pulse every 0.005 seconds. I have UP and DN inputs. I add the inputs (+1 for UP, -1 for DN) to the output of the memory loop. The input of the memory loop is fed to the output of the subsystem.
PROBLEM: Usually, the output of the memory loop is updated to match the input to the memory loop before the subsystem stops execution, but about 15% of the time, the memory loop fails to update before the subsystem stops execution, causing the counter to revert back to the previous count. If I feed the output of the memory loop to the output of the subsystem (as opposed to the input of the memory loop) the memory loop still has the same problem but then it results in an occasional double increment or double decrement.
QUESTION: Why is the memory loop behavior unstable when the subsystem stops execution and what can I do to fix it?

回答(1 个)

Divyanshu
Divyanshu 2025-1-15
Hello @John,
I am not sure of the reason behind this unexpected behavior in the memory loop. However as a workaround you can try using Data Store Memory block, I have implemented a similar counter using the same.
You can execute the following command in your MATLAB command window, to get more details on Data Store Memory block:
>>web(fullfile(docroot,"simulink/slref/datastorememory.html"))

类别

Help CenterFile Exchange 中查找有关 General Applications 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by