Searching \ for 'Extending accuraccy of a PIC A2D' in subject line. ()
Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=a2d
Search entire site for: 'Extending accuraccy of a PIC A2D'.

Truncated match.
PICList Thread
'Extending accuraccy of a PIC A2D'
1998\12\17@051203 by

This started off as a private reply to Nigel Orr but it seems close
enough to the original discussion that I'll throw it back on the
list. Does anyone have actual real world experience of this at
substantially more than 8 bits using an 8 bit A2D???

Russell McMahon

--------------------------------------------------------------

Nigel

>>- You can get 12 bits from an 8 bit A2D by taking enough samples
and
>>averaging them (or adding them into an eg 16 bit register and
taking
>>the msbs as required).
>
>Is it that straightforward?  ie can I take 256 8-bit samples, add
them into
>a 24 bit accumulator with some noise, and take the top 16 bits?

Basically, yes.
Note my prior caveats about possible affect of error sources. I may
be wrong.

>>- You should ideally add 1/2 an lsb (at 8 bits) of random noise to
>>the input signal to spread it between the 2 lsbs it lies between.
>
>Are there any good algorithms for generating random noise on a PIC?

Yes, but that's not what you really want (although, on reflection,
that's not a terrible idea).
What is normally done is to have a noise source external to the PIC
which adds ANALOG noise to the input signal. It should I think be +/-
1/2 a bit. Imagine that the input was exactly correct to give a
reading of 00001111. If we went to 12 bits this SHOULD give
000011110000. Back at 8 bits, if you add JUST less than 1/2 a bit of
dc offset you will still get 00001111. If you SUBTRACT JUST less than
1/2 a bit of dc offset you will again STILL get 00001111. However, if
you had looked at all 12 bits in the above case you would see the 4
lsbs varying.

In the above case, by adding +/- 1/2 one lsb of noise you move the
value across the whole range of possible values which still allow it
to return the same 8 bit value. HOWEVER, if the value was NOT an
exact 8 bit value, some of the offsets will push it across into the
next bit (up or down depending on its value). Do this often enough
randomly and you get an eg 12 bit value. Probably it would be wise to
use more than eg 16 samples to get a 12 bit result eg use a 16 bit
accumulator and take 256 values and take the top 12 bits.

Now, back to your comment on making noise with the PIC. Adding
"noise" after the A2D stage gives no value but you could generate
analog noise with the PIC and add it externally. This leads to the
obvious thought - take a PIC and drive and eg 4 bit D2A which scans
across a 1LSB range and add it to the input signal Analogue'ly. If
the D2A is accurate (somewhat better than 4 bit accurate - very easy)
and the 8 bit A2D is 12 bit accurate (which it won't be of course)
you can run a classical successive approximation algorithm under
software control - you have reinvented the wheel. Do this, say 256
times to allow for hardware errors and you MAY get a usable 12 bit
result.

Best approach is probably to try it and compare the results with a
"real" 12 bit A2D.

regards

Russell McMahon

At 11:10 PM 12/17/98 +1300, you wrote:
>This started off as a private reply to Nigel Orr but it seems close
>enough to the original discussion that I'll throw it back on the
>list. Does anyone have actual real world experience of this at
>substantially more than 8 bits using an 8 bit A2D???

I have used this circuit on several projects very successfully.

+5V
-----
|                     R3
|                |-/\/\/\/-- to PIC Digital output with square wave
R1  /                |
\       R2       |
/<---/\/\/\/\----o--------- to PIC ADC
\                |
/                -
|                -C1
|                |
GND              GND

On one project R1 = 5K, R2 = 0, R3 = 100K, C1 = .47uF and square wave = 2mS
per cycle (1mS high, 1mS low).  Taking 32 samples gives 10 bits, with some
jitter when the pot output is close to 5V.  By increasing R2 and decreasing
R3 this could be reduced.

I'm sure someone on the list will be happy to provide optimal values for
everything.

Andy

==================================================================
Andy Kunz - Statistical Research, Inc. - Westfield, New Jersey USA
==================================================================

Andy,

How does it work?

How do you get the extra two bits?
Could this be coersed to 12 bit?
What is the sample rate?
Is there an application note?

Thanks,

Craig

> {Original Message removed}
>How does it work?
>How do you get the extra two bits?

The pot provides a basic voltage to the ADC pin.

The square wave applied to the capacitor through the resistor causes a
slight variation of the voltage seen by the PIC.  Ideally this should be <
1 bit voltage difference (in a PIC, that means Vref / 256).

You take lots of samples of the pin as it rises and falls (in one product,
I sample at 1mS rate, just before the bias pin changes state) and sum the
results.  This gives lots more bits of data than you can use.  Next, there
will always be noise, so you shift those bits out.

>Could this be coersed to 12 bit?

Yes, but you need to take about 256 samples and average them together.
I've done this and it works, but I would recommend and external ADC if you
really need the extra precision.

>What is the sample rate?

Samples are taken every 1mS, just before changing the state of the bias pin.

>Is there an application note?

You just read it!  Actually, I think that you can read the appnote on using
a digital input pin as an adc and just think about it.  This will help you
a lot.

Also, play around.

Andy

{Quote hidden}

==================================================================
Andy Kunz - Statistical Research, Inc. - Westfield, New Jersey USA
==================================================================

> >Is there an application note?
>
> You just read it!  Actually, I think that you can read the
> appnote on using
> a digital input pin as an adc and just think about it.  This will help you
> a lot.

I shall, and I'll build an application note.  I've wanted to do this for
sometime, as the 8 bit ADC limits the PIC chips I can use.  I suspect some
attention to temperature drift should be provided as well as some
'engineering
rules of thumb' on component selection.

> Also, play around.

Thanks for the info, but I don't think my wife would approve.
wink wink nudge nudge)

> Andy

Craig

Russell McMahon wrote:
>
> This started off as a private reply to Nigel Orr but it seems close
> enough to the original discussion that I'll throw it back on the
> list. Does anyone have actual real world experience of this at
> substantially more than 8 bits using an 8 bit A2D???

I had made this on a 6805R3.  I used one pin to make a saw tooth waveform from
a resistor and a capacitor and feed the noise to the input and oversample it.
It give accurate data.

regards,
Reggie

Regulus Berdin wrote:

> I had made this on a 6805R3.  I used one pin to make a saw tooth
> waveform from a resistor and a capacitor and feed the noise to the
> input and oversample it.   It give accurate data.

Sounds good.  Note that the "dither" need not be random noise, it can
just as well be a staircase (unfiltered) or a ramp.  The *only*
requirement is that over an averaging interval, it is uniformly
distributed.  If you think about it, random noise does not fulfil this.
--
Cheers,
Paul B.

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