Need ADC function

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
dslocum
Posts: 102
Joined: 31 Aug 2009 12:21

Need ADC function

#1 Post by dslocum » 08 Oct 2011 13:59

Hi,

I'm not sure what to call it, so I haven't had much luck in my searches.

I'm taking multiple ADC readings and applying a divisor (/6). Therefore I end up with a number from 0 to 5. That works fine.

The problem is that there is sometimes a bit of noise on the ADC inputs which sometimes causes glitches or jumping in my numbers. A hardware solution to this is not practical for other reasons.

What I would like to try, is to take several ADC readings and then make a decision which of the 0 - 5 readings had the most readings and then use that as my final number.

Please be kind... I'm not a math wiz.

Thanks

Doug

drdoug
Posts: 1074
Joined: 16 Aug 2007 03:49
Location: St. Louis, MO

Re: Need ADC function

#2 Post by drdoug » 08 Oct 2011 20:54

Take a series of readings and average them. About 30 should be fine. Ill try to post some code later but no need to wait for me to try it out.
Btw "Dougs" are awesome.

Mince-n-Tatties
Posts: 2780
Joined: 25 Dec 2008 15:22
Location: Scotland

Re: Need ADC function

#3 Post by Mince-n-Tatties » 09 Oct 2011 23:21

if you know the expected range of good values then you can also simply dump values which are outside your expected range.

if you want to go completely nuts, then you could look into the usage of the Kalman filter!
Best Regards

Mince

Post Reply

Return to “mikroC PRO for PIC General”