Use of Memory Loops in Enbaled Subsystems

5 visualizzazioni (ultimi 30 giorni)
John
John il 19 Giu 2018
Risposto: Divyanshu il 15 Gen 2025
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?

Risposte (1)

Divyanshu
Divyanshu il 15 Gen 2025
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"))

Categorie

Scopri di più su General Applications in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by