Re: Averaging AtoD samples
An old thread & just revisiting this issue again ...re the spurious rejection, there's a setting as follows....
Code:
Reject CON 2 ' Spurious Rejection level
Presumably that setting is the amount of samples, before the averaging code accepts/adopts the new incoming sample (vs just throwing away a sample that diverges too much) ....but what is deemed a 'spurious' sample ..in other words what in the Darrel's code a couple of posts above decides that the incoming sample was spurious ...and can this 'sprurious diversion amount' be adjusted?
To help explain, consider the following trail of ADC samples...
99
101
100
91 ------ not spurious, just a low sample
97
101
50 -----------spurious
98
100
How is the spurious rejection set so as to accept the ADC rsample of 91, but to just reject the sample of 50?
Re: Averaging AtoD samples
Ok Hank, I'll give this a go. BTW, it only took me 15 mins to remember what I was thinking when I posted almost a year ago!
Anyway, this is what I think is going on. Every sample with a difference greater then 50 in DT's code gets rejected the first and second time through. The 50 can be set with the FAspread constant. the number of times it get rejected is set by Reject constant.
The way it gets rejected is really pretty. Int the avg routine, the value gets tested against FAspread, if it is bigger, the flow jumps to FastAvg, where reject count gets incremented by 1. then reject count gets tested to see if it is now 3
Code:
IF RejCount = Reject + 1 THEN
if it is, the new value is accepted as good. It also becomes the new average. and everything moves on from there.
If it is not, then the running average is left as is and the current value is rejected.
BTW, I think using DT's FAspread con 50, 91 would never be considered as spurious since it is within 50
Does this help?
Re: Averaging AtoD samples
Thanks Bert....let me see - so it's the FAspread that sets how far the deviation from mean that can be accepted .... with the RejCount counting how many 'deviations from mean' there have been - once the Rejcount number is met, then the new level of incoming sample becomes a valid sample to average against?
Re: Averaging AtoD samples
Thats my understanding Hank. It sounds so much better when you say it. :)
Do you get the code now?
Re: Averaging AtoD samples
Yes, I get it - tks (as ever) for the input Bert. :)