Digest Number 2566
Archiver
Posts: 46,084
Hi Tim,
An easy way is to keep 2 counters:
1 for the accumulation of values
1 for the number of datapoints accumulated
loop:
read LTC1298_value
sum = sum + LTC1298_value
count = count + 1
avg = sum / count
if count < 10 goto loop
sum = avg
count = 1
goto loop
This saves some RAM bytes and gets you an ongoing 10 value average.
Cheers, Caesar.
Original Message
From: ikenniemandanders [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=DzGceZrJxzwClRVh8DBpKf0g1k_-ZFf0ZOSauPRIAoMxLiQCdK8erOkLAK0Gbo4K2e-Cl6aWMyLmnt0]tld-nv@s...[/url
Sent: Wednesday, July 14, 2004 9:34 AM
To: basicstamps@yahoogroups.com<mailto:basicstamps@yahoogroups.com>
Subject: [noparse][[/noparse]basicstamps] Using a FIFO register to stable my incoming ADC
values
Hi stampworkers,
I'm reading in an 4-20mA pressure sensor with an LTC1298. This works
very good but my values keep changing a little bit and I want to
make them as stable as I can so I thought an FIFO register software
loop would do the trick. My idea is to create an 10 adress FIFO
register, to make the sum of the 10 values en the devide it by 10 so
I get an average value of the reading wich will be stable
(hopefully). I searched a lot in nuts & volts and in my printed
manuals but didn't found a proper article about creating such
register. Do I need some kind of IC to make my idea work or could i
do this by inserting some program text? Could anyone help me with me
very enoying problem?
Greetings,
Tim (happy but not satisfied)
[noparse][[/noparse]Non-text portions of this message have been removed]
An easy way is to keep 2 counters:
1 for the accumulation of values
1 for the number of datapoints accumulated
loop:
read LTC1298_value
sum = sum + LTC1298_value
count = count + 1
avg = sum / count
if count < 10 goto loop
sum = avg
count = 1
goto loop
This saves some RAM bytes and gets you an ongoing 10 value average.
Cheers, Caesar.
Original Message
From: ikenniemandanders [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=DzGceZrJxzwClRVh8DBpKf0g1k_-ZFf0ZOSauPRIAoMxLiQCdK8erOkLAK0Gbo4K2e-Cl6aWMyLmnt0]tld-nv@s...[/url
Sent: Wednesday, July 14, 2004 9:34 AM
To: basicstamps@yahoogroups.com<mailto:basicstamps@yahoogroups.com>
Subject: [noparse][[/noparse]basicstamps] Using a FIFO register to stable my incoming ADC
values
Hi stampworkers,
I'm reading in an 4-20mA pressure sensor with an LTC1298. This works
very good but my values keep changing a little bit and I want to
make them as stable as I can so I thought an FIFO register software
loop would do the trick. My idea is to create an 10 adress FIFO
register, to make the sum of the 10 values en the devide it by 10 so
I get an average value of the reading wich will be stable
(hopefully). I searched a lot in nuts & volts and in my printed
manuals but didn't found a proper article about creating such
register. Do I need some kind of IC to make my idea work or could i
do this by inserting some program text? Could anyone help me with me
very enoying problem?
Greetings,
Tim (happy but not satisfied)
[noparse][[/noparse]Non-text portions of this message have been removed]