Accumulating timer from a analog input

Put the "compare previous to current" logic that was mentioned earlier in a task which only runs every 300 ms.
It's too bad Pro Suite doesn't have the DELTA contact that Do More has.
 
Last edited:
Comparing floating-point to floating-point is haphazard as-is, noise (even filtered) and ADC quantization error will only exacerbate the problem. You should compare values to see whether they fall within an expected range of error.

Ostensibly, doing something like this is magnitudes better:
Code:
if( abs( value1 - value2 ) <= error ) ... // do something
 
Comparing floating-point to floating-point is haphazard as-is, noise (even filtered) and ADC quantization error will only exacerbate the problem. You should compare values to see whether they fall within an expected range of error.

I agree, but in my case I'm only using integer values over a scale of 4 to 125.

In any case, after grinding away on it this morning, I've come up with something that works. There are possibly better ways, but this works and seems to be pretty efficient.

I've attached a screenshot of the logic. Basically, if it falls in the range of "bad" pressures, it allows the Change of Values instruction to run. The CHG instruction looks at my pressure and samples it every 300ms, giving me a integer value of change in that sample time. If you go from 5psi to 7psi in 300ms, the change would be 2.

So, to start the timer, I'm comparing that value to zero (meaning, no change in 300ms). If that is true, timer starts.

I gave that value an initial value of 5 so that it doesn't immediately start timing the moment it goes into "bad pressure". Doing that allows it to sample once and derive an accurate value as to not penalize the player due to bad code work on my end.

flask_timers3.jpg
 
A = Real AI

If B <> A then //AI has changed value.
B=A
C=0 // Used to reset the timer enable
Else
C=1 // AI is stable so run the timer
End If




If C=1 run 300ms timer etc
 

Similar Topics

Hi all, Can anyone tell me why the MinDuractionACC isn't accumulating in the example below? Is it just a visual bug? I've tried in multiple...
Replies
4
Views
1,213
I AM Using a AB micro1500 PLC and the PTO instruction. I need a program or technique to keep a running total of all pulses produced from the PTO...
Replies
0
Views
1,097
Hello everyone, so I added some inputs and 2 TON timers to an existing program that I knew was working just fine before I added these. I verified...
Replies
3
Views
2,349
Hey guys, we have a big trouble with our drives; In our application we have often to disable the drive and hold it on brake; The problem is after...
Replies
2
Views
1,633
In a system I'm working on, remote well pump sites report to a central controller. Amongst other signals, the remote well pumps report the daily...
Replies
9
Views
4,741
Back
Top Bottom