Question

I am trying to retrieve two 1-bit values (i.e. their previous values) after the system starts up OR write to it during the normal operation if cirumstances change. When I say "System starts up" I want to make it clear that this is a subsystem that sits inside a very big system.

THe idea is that if I disconnect this subsystem, the rest of the system is unaffected. I will preserve two 1-bit values based on their last known state. On a startup of the subsystem again, based on my processing, those 1-bit values will either be preserved or overwritten by new values. For confidential reasons, I cannot get into deeper than I already have.

My approach so far

Attached is the SIMULINK diagram of the part of the subsystem that does this memory read/write . I believe that this will work. However, I am not entirely sure. Could anyone think of a better way of doing it? I know that an obvious answer will be to say "Try to save and load from workspace" but I have a specficiation that only allows loading from Flash/E2PROM. Unfortunately, I don't know anything in SIMULINK that will do it. If anyone knows something different, I am quite happy to be educated fully :)

enter image description here

Thanks.

Was it helpful?

Solution

You basically need a memory. There are possibly multiple ways of doing this.

  1. Delay is a memory. You can set its initial conditions for start up values. You can either put the Delay inside an enabled sub-system to write new values or you can use a mux to write new value or previous value from output of delay.
  2. You can use a MATLAB Function block and declare a persistent variable in it. You can initialize this inside a check for "is empty(persistent_var_name)" and then read or write into it.

One more way is how the original question implements it using "Data Store".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top