Perhaps some strange questions... but I want to be sure that I'm not making a logic error...
1. If I want to determine whether a value changed, does it suffice to compare it with a memory flag that contains the same value with 1 cycle delay? Thus the condition below works?
-
if (value(t) <> value(t-1)) then value changed
-- value(t) denotes the value at time t
-
2. If I have 2 values (a and b), and they should have the same value but should take the value of the one that changed last, would this work:
-
if ((a changed) and (b not changed)) then b=a
if ((b changed) and (a not changed)) then a =b
if ((a changed) and (b changed)) then ... ( this is very unlikely to occur within one cycle of the miniserver, but just to be safe I should catch it and either give priority to a or to b)
-
3. If the logic from 2. works, would the combination with 1. work,
-
if (a(t) <> a(t-1) and (b(t)==b(t-1) then b=a
if (a(t) == a(t-1) and (b(t)<>b(t-1) then a=b
...
-
or will I risk to run into issues that the comparisons happen in different cycles, and that I would e.g. have to store whether one changed in an analog memory as below?
-
if (a(t) <> a(t-1)) then trigger analog memory "a_changed" to store true
if (b(t) <> b(t-1)) then trigger analog memory "b_changed" to store true
if (a_changed and not b_changed) then b=a, reset a_changed, reset b_changed
if (b_changed and not a_changed) then a=b, reset a_changed, reset b_changed
-
Or can I forego the analog memory and just use the outputs of the conditions as in 2.
Thanks!
Jörg
Kommentar