Hi Tasaddaq,
I am not sure I understand correctly what you want to achieve.
From your last mail, I assume that your record "b" should act as a
gate.
Whenever "b" gets 1, you want the counter record "time" to start
counting from 0, and the counter record "result" to continue
counting from where it was left.
While "b" is 0, the counter record "time"should be reset to 0, the
counter record "result" should keep its value.
This can be done using the following database (many other solutions
possible):
record (bi, "b") {
}
record (calcout, "time") {
field(SCAN, "1 second")
field(INPB, "b")
field(INPC, "1")
field(CALC, "B?VAL+C:0")
}
record(calcout, "result") {
field(SCAN, "1 second")
field(INPB, "b")
field(INPC, "1")
field(CALC, "B?VAL+C:VAL")
}
Cheers,
~Ralph
On 12/07/2015 21:24, Tasaddaq Khan
wrote:
Hi Ralph
I have tried many combinition but could not get the
desired result. Please have a look at my record,
record (bi, "b"){
field(DESC, "Increment")
field(DTYP, "Soft Channel")
field(FLNK, "time")
}
record (calcout, "time"){
field(SCAN, "1 second")
field(INPA, "time")
field(INPB, "b")
field(INPC, "1")
field(CALC, "B=1?a+c:0")
field(OOPT, "When Non-zero")
field(OCAL, "")
field(OUT, "result PP")
}
record(calcout, "result"){
field(SCAN, "Passive")
# field(INPA, "time")
field(INPB, "result")
field(INPC, "1")
field(CALC, "B+C")
}
The record result is derived by the record time. When record
b.VAL=1 things works fine but when record b.VAL=0 record
time.VAL=0 and record result.VAL holds the last value. Upto
here things are working fine. Now when I again put b.VAL=1,
time.VAL starts from 1 and it also derives result.VAL again
from 1 but not from the last value it holds. Then I disables
the field(INPA, "time") (as in the record), the record time
still derives the record result and the solution is same.
Please have a look and suggest me how to change my values in
order to get the desired result.
regards
Tasaddaq
|