Searching \ for '[PIC] 10-bit A2D: How to soft filter w/o lose LSB' in subject line. ()
Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/math/filter.htm?key=filter
Search entire site for: '10-bit A2D: How to soft filter w/o lose LSB'.

Exact match. Not showing close matches.
'[PIC] 10-bit A2D: How to soft filter w/o lose LSB'
2003\08\21@131605 by

I have a P-I temperature controller using a PIC 16f877.  There is apparent
random noise on the least significant 2 or 3 bits of the thermistor sensor
connected to the 10-bit A/D.  At least random as it appeared on my
spreadsheet.  I am using a 200ms sample rate.

How can I software filter this noise without losing the least significant
bits of the A/D?

I do not have a black-belt in math so I was thinking about something simple
like:
Avg=Avg + (Sample-Avg)/k

This would be simple to implement if k is a power of 2, however, this
appears to lose accuracy.

Thanks in advance for any tips or suggestions,

-Ed

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

I average as well, and get good accuracy...

Avg = (sample_1 + sample_2 + ... + sample_n) / n

Just start a counter and add until n samples have been reached, then divide accordingly.  In this particular case, the display updates happen only after the n samples.

n varies depending on purpose, but using a power of 2 does make life really simple.  In one case, I need very infrequent updates, so n is 64, and I add into 16 bits (2 registers), then use the upper byte for an 8- bit result w/o any specific division.  With this 8 bit result, I get a value from a lookup table, and another using the 8-bit result+1.  Then I interpolate the difference with the lower byte from the average.  Works great for my non-linear function where the difference between adjacent values in the lookup table may be greater than the display resolution I need.

I been reading a bunch on laying out PCB's properly, and the proper use of bypass caps, etc, and been able to reduce the actual noise, and it helps a bunch.  My latest gig is splitting a 16F872 circuit into 2 parts using a 12F675 and a 16F627A.  The '675 will be the analog and control part, and the '627 will be the display multiplexing part.  With this, it will be so much easier to split the power planes into separate analog and digital sections, so I should get lower noise.  I'll find out soon enough.  And cost is the same, and PCB layout becomes easier with the 2 smaller chips.

Cheers,
-Neil.

On Thursday 21 August 2003 12:15, Ed Sutton scribbled:
{Quote hidden}

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

>    Avg = (sample_1 + sample_2 + ... + sample_n) / n
>
> Just start a counter and add until n samples have been reached, then
> divide accordingly.  In this particular case, the display updates
> happen only after the n samples.

Thanks! Using a counter will be simple to implement, I can store the average
in my current 16-bit value and only use it for PI control and display
purposes after I have sampled it n-times and divided by n.

Do you see anything wrong with summing the thermistor 16-times in
succession, then shifting the sum right by 4?

Also, I am still struggling with how to calculate the conversion time.  I
have a 3.6864MHz oscillator. If ADCS1:ADCS0 are set to Fosc/8, is the below
calculation correct?

Conversion Time = 8 / 3.6864MHz * 12 = 26us ??

And 16 conversions will take approximately 416us + software overhead?

> n varies depending on purpose, but using a power of 2 does make life
> really simple.  In one case, I need very infrequent updates, so n is
> 64, and I add into 16 bits (2 registers), then use the upper byte for
> an 8- bit result w/o any specific division.  With this 8 bit result,
> I get a value from a lookup table, and another using the 8-bit
> result+1.  Then I interpolate the difference with the lower byte from
> the average.  Works great for my non-linear function where the
> difference between adjacent values in the lookup table may be greater
> than the display resolution I need.

This sounds very code efficient.

> I been reading a bunch on laying out PCB's properly, and the proper
> use of bypass caps, etc, and been able to reduce the actual noise,
> and it helps a bunch.  My latest gig is splitting a 16F872 circuit
> into 2 parts using a 12F675 and a 16F627A.  The '675 will be the
> analog and control part, and the '627 will be the display
> multiplexing part.  With this, it will be so much easier to split the
> power planes into separate analog and digital sections, so I should
> get lower noise.  I'll find out soon enough.  And cost is the same,
> and PCB layout becomes easier with the 2 smaller chips.

I remember reading in EE Times or some other magazine a long time ago that
adding random noise can actually give you more bits of resolution than you
already have.  I did not really understand it at the time yet I can sort of
visualize this as the actual voltage level being at some level between two
bits.  If no noise, then the A/D reading is always the same.  If you add
random A/D noise, I can see that it will bounce around to different A/D
steps.  If noise is random, reading will be distributed evenly around the
in-between level, which I suppose can then be calculated.  I dunno, it
sounded good anyway.

TRhank you for your help!

-Ed

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

If you have the 8 RAM locations available, create an averaging scheme I
call a "bucket with a hole in it". Everytime a new value is read, install
it into the buffer, and DELETE the OLDEST value. This creates a long-term
average of 1.6S (ea reading at 200ms) and it will cleanup the lower bits
nicely.

--Bob

At 12:15 PM 8/21/2003 -0500, you wrote:
{Quote hidden}

--------------
Bob Axtell
PIC Hardware & Firmware Dev
Tucson, AZ
1-512-219-2363

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

If you know you have a signal of a certain (constant) frequency (eg.
power line) added to the analog input you could take the n samples
equally spaced within the added signal's period. Then do the average
of the samples and the noise should be cancelled. This may be combined
with Bob Axtel's solution.

[I'm studying IT and know little about electronics so use with care!
Ovidio Vazquez Jara
{Original Message removed}

More... (looser matching)
- Last day of these posts
- In 2003 , 2004 only
- Today
- New search...