This might work for you.
Averaging 16 bit values without using 32 bit math?
http://www.pbpgroup.com/modules/wfse...hp?articleid=7
<br>
This might work for you.
Averaging 16 bit values without using 32 bit math?
http://www.pbpgroup.com/modules/wfse...hp?articleid=7
<br>
DT
Hi, Jorge
Why not place your sensor in a dummy product ??? ( With same thermal mass - and even approaching shape, if convective heat transfer ).
Result would be much more precise ... and doesn't keep you from an averaging !!!
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Darrels' averaging routine is pretty slick. I would go with that if at all possible.
For Temperature A2D (0-1023), a favorite of mine if T changes are gradual and code space is a premium...
pseudo-recursive filter (similar to Darrel's except without the smarts)
depending on the smoothing required, you can adjust and change the 7 & 8 in the AVE equation to 15 & 16, 3 & 4, etc., depending on what you need in the way of filteringCode:A2D var word AVE var word Main: ' Get new A2D value A2D = new A2D Value ' Smooth data Ave = ((((AVE<<1)+AVE)<<1)+AVE+A2D)>>3 'AVE = (7*AVE + A2D) /8 ' More stuff here if you want Goto Main
Paul Borgmeier
Salt Lake City, UT
USA
__________________
...as always you have helped me in finding the path, thanks for your precious time and for your hints !
Darrel´s solution (really good) and the this last one (Paul´s) are on the spot...
Thanks again !
regards, Jorge
Hey jorge,
Hope it works out for you.
The only thing it's missing is hysterisis. No matter how much you average, there's always a point where the reading bounces back and forth between two digits.
To illiminate that "wobble", I added some hysterisis to the averaging routine and posted them a couple times ...
http://www.picbasic.co.uk/forum/showthread.php?p=13267
Never did get a response, but I've used them myself since then so at least now I can say that they do work.
HTH,
DT
Always nice to hear things are working.
Thanks for letting me know peu.
<br>
DT
Hi all,
I have the need to slow things down a bit. I'm running a 18F1330 at 32 MHz executing a sense loop for ultrasonics each 32 mS. I have tried to use DT's averaging routine with a 250 reading average, but it still reacts way too fast. I need to dampen it to a 2 or 3 second response so that it doesn't drive the mechanical parts nuts.
It doesn't look like I can just change the AvgCount to a larger variable without messing it up.
Anybody ran into this before?
Thanks for any input while I try and think through this.
Bo
After looking closely at my code, I realized that I had tried to tweak DT's code.... as always, likely a mistake....
Went back to the original and it is working more like need. Further testing.
Move along, Nothing to see here.
Bo
Bookmarks