An operation that can be useful while working with digital signals is counting status changes from 0 to 1 and from 1 to 0.
Consider a digital signal, first step is
- creating a virtual signal that represent the original signal shifted of one unit, to refer the previous value
The virtual signal has to be created with the following formula
- kf(ago(x0),2)
Is therefore possible
- creating a virtual signal to filter the original one, so that only the status changes are returned
By importing the two signals as variables in the virtual signal we'll have the original signal as x0 and the shifted signal as y0, the formula to filter the status changes is
- x0+y0==1 ? 1 : undefined
To conclude
- set the signal as differential counter since the received values represent the increases and not the total accumulated
To visualize the number of status changes per day, just turn signal data frequency to daily.
To consider just the status changes from 0 to 1 proceed in the same way, using in the virtual signal the formula
- x0+y0==1 and x0>y0 ? 1 : undefined
For the status changes from 1 to 0 the virtual signal formula will be
- x0+y0==1 and x0<y0 ? 1 : undefined
0 Comments