Try this:
record(seq, "$(P)arm") {
field(DO1, "1")
field(LNK1, "$(P)state.D PP NMS")
field(DO2, "0")
field(LNK2, "$(P)state.D PP NMS")
field(DO3, "0")
field(LNK3, "$(P)state.A NPP NMS")
field(DESC, "process to arm timer")
}
record(bi, "$(P)bi") {
field(FLNK, "$(P)state.PROC")
field(DESC, "record whose values are timed")
}
record(calcout, "$(P)state") {
field(INPB, "$(P)bi NPP")
field(CALC, "c:=(a==0)?b:c;a:=(b==c?a+1:a);a==1?1:a==2?0:-1")
field(OUT, "$(P)counter.A NPP")
field(DESC, "counter state")
}
record(calcout, "$(P)counter") {
field(INPB, "$(P)counter.VAL NPP")
field(INPC, "$(P)counter.D NPP")
field(CALC, "a==-1?0:(a?b+1:b)")
field(SCAN, ".1 second")
field(DESC, "counter")
}
To arm the counter, process $(P)arm. Once armed, the next time $(P)bi is processed, the counter will start, and the value that started it will be recorded. The next time $(P)bi processes and has the recorded value, the counter will stop.
Tim Mooney
I receive bi input either 1 or 0 . I want to calculate the time interval between two 1s or two 0s.
Thanks
azra