PDA

View Full Version : DT Average



ShaneMichael
- 5th October 2011, 18:28
I found a post about an average routine that Darrel Taylor built but the link to the code was broke so I checked his website but didn't find it there either. Is that still available? I searched using forum and code samples, but didn’t find any other reference to it.

I’m doing an A/D conversion about 50 times per second, I need a way to get an hourly average of the samples. I’m not sure of the limits of DT’s routine so any other idea’s are welcome. I’ve been using DT interrupts and timer, those have worked great, so I have a feeling the averaging routing will be what I need.

Thanks,
Shane

Charles Linquis
- 5th October 2011, 22:55
If every sample has equal weight, why not just add all the samples together and divide by 50*60*60 = 18000. The sum could be no larger than 1023 * 180000.

You can use LONGs to handle that.

Now don't tell me that you are one of those guys using 16Fs...

ShaneMichael
- 6th October 2011, 00:33
I'm using an 18LF2550, I should be able to use LONG's, seems like I had issues with LONG's at one time, that was many lines of code about two years ago...in a galaxy far away. I'll give it a try, see if I figure out why I was avoiding using longs.

Thanks for the Idea.
Shane

ShaneMichael
- 6th October 2011, 23:47
I used LONG without any issue, I still need to refine my code.
Thanks for the help.
Shane
:)