Average a analog input?

Thee 'FilteredPSI' will eventually get close to the actual PSI value (it takes longer with more filtering - it's how the algorithm works.) If you are impatient then, just one time at the start, copy the raw PSI into 'FilteredPSI'.
 
Rootboy, On your example, how does the CPt get a value for "filteredPSI" the first time it tries to calculate it?

For the first time all it will accumulate is the PSI_Input * .02 portion. And you can make the .98/.02 ratio into anything that you like as long as it adds up to 1.00.

This ratio was for an otherwise unusable O2 sensor, your application would probably not need to go so medieval on it.

And of course you can set your free running timer up for any period that you like. Start out small, say, 100ms.

And my entire routine also had offset and slope adjustments. I left them out here in the interest of clarity. But for offset you would add a positive or negative offset. And for slope, you would multiply by a value of, for example, .95 - 1.05 to give yourself a +/- 5% slope.

The advantage to this method is that you don't have to create an array of variables to provide your base for your average.

And like Bernie pointed out, it approaches the the average over time, which is why this is a filter, not a true average. But I think that you will find that it gets very close.
 
Hey Pal, a question:
Where Paramslevel[7] comes from ?

Hi widelto , sorry for the delay in replying . I must admit I was lazy in not replacing that branch with a simple MOV instruction . In the actual program this is 1 of several level functions for the process and ParamsLevel is an array of values set in an HMI maintenance screen . This particular value is an offset fot the level reading , since the bubble level sensor is just off the bottom of the tank by 3 mm .

Paul
 

Similar Topics

hi I have to take average of my analog input data from analog input module FX 2N-2AD using with FX1N plc. As I cant treat REAL NUMBERS in FX1N...
Replies
0
Views
2,036
Hi I am trying to find out , how to get an average of an analog input for 24 hours. I am interest to know the average of analog input value for...
Replies
6
Views
7,044
Hi all-- I need to create code in a Micrologix 1400 project that requires minimum, maximum and running average calculated values (Flows and...
Replies
17
Views
3,744
Hello, I'd like to obtain average of my analog input value which will be displayed on SCADA. For examplle, analog value should be sampled avery...
Replies
2
Views
2,126
I have a Banner LT3 laser sending 4-20ma signal to a Compact Logix System. The signal is the level of product on a conveyor. The signal is fast...
Replies
6
Views
8,749
Back
Top Bottom