Hi Donny,
Because the Charge record is Passive scan and is being processed (presumably) only by
the calc record what you are saying makes sense. the calc record processes the charge
record first for link A using a PP link causing it to get a new value, then it gets that new
value again using link B without processing (NPP) the charge record.
I think what you really want is this:
record(calc, "$(KEIT):CalcCurrent")
{
field(SCAN, "1 second")
field(INPA, "$(KEIT):Charge NPP") # Get the current value of Charge
field(INPB, "$(KEIT):Charge PP") # Process charge record then get the new value
field(CALC, "B-A") # You may need to change this to A-B if you want a positive value assuming the charge is always increasing
}
You need to get the current value first then process the record to get the new value.
Marty
From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of Donny Domagoj Cosic via Tech-talk <tech-talk at aps.anl.gov>
Sent: Monday, March 29, 2021 6:35 AM
To: Tech-talk <tech-talk at aps.anl.gov>
Subject: Rate of change calculation
Hello,
I am trying to calculate the rate of change of a record using a calc
record as follows:
record(ai, "$(KEIT):Charge")
{
field(DESC, "Measure Charge")
field(DTYP, "steam")
field("@devKeithley6514.proto measureCharge() $(PORT)")
field(SCAN, "Passive")
}
record(calc, "$(KEIT):CalcCurrent")
{
field(SCAN, "1 second")
field(INPA, "$(KEIT):Charge PP")
field(INPB, "$(KEIT):Charge NPP")
field(CALC, "B-A")
}
The calc record always returns 0. If I change the calc to B+A, to check
what is going on, I always get double the charge. It seems like the PP
and NPP are both returning the same value even though the actual charge
is changing. Any ideas on why this would be happening or suggestions
would be greatly appreciated.
Thank you in advance,
Donny
--
Donny Domagoj Cosic
Institut Ruđer Bošković, Bijenička cesta 54, 10000 Zagreb, Croatia
|