Shop OBEX P1 Docs P2 Docs Learn Events
Why a ten bit ADC? Where do you store 10 bits? — Parallax Forums

Why a ten bit ADC? Where do you store 10 bits?

Martin_HMartin_H Posts: 4,051
edited 2012-10-04 23:59 in Propeller 1
Both the Prop Boe and the Arduino have ten bit ADC's, which seems odd to a programmer. Where do you store ten bits? You're wasting some bits if you store the value in a word, and chopping off some bits if you store them into a byte. Also when they send the 11 bits down the I2C bus are the upper bits always zero, junk, or somehow not sent to conserve bus bandwidth? In Phil's ADC code it looked like he masked with $3ff which implies junk bits to me.

Now ten bits obviously divides a voltage more finely than eight bits, but why don't ADC's natural word sizes match the architecture of computers? Do they cost more, or in the ADC world is it bad form to advertise a resolution that's isn't achievable?

Also, if you do need to store a ten bit value in a byte what's the best method? Obviously bit shifting two places to the right will work and should preserve the full range, but bit shifting one place and allowing clipping results in better sensitivity to voltages within the low end of the range.

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-10-04 08:28
    Martin,

    The obvious advantage of ten bits is that it's more than eight or nine. :) You don't have to use all ten bits if you don't want. With the PropBOE's ADC, just shift the result right by four and AND with $ff to get eight bits. Also, if you look at the ADC's datasheet, you will see that the upper "unused" bits are not junk or zeroes but contain additional information about the result, such as whether it is outside of programmed limits.

    And, yes, ADCs get more expensive and tricky to use the more bits of resolution you have. With 16 bits and a 5V reference, for example, the resolution is 76 uV. That's lower than the noise floor for most board layouts including, I'm sure, the Prop BOE.

    -Phil
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-10-04 08:35
    Phil, did you mean shift the result right by two instead of four?
  • Heater.Heater. Posts: 21,230
    edited 2012-10-04 08:41
    Is there an ADC that goes to eleven?:)
  • Martin_HMartin_H Posts: 4,051
    edited 2012-10-04 08:43
    Thanks. The physical limits imposed by electrical noise make sense why they would stop short of a byte boundary. Using the extra bits for metadata is actually a good idea.
    Dave Hein wrote: »
    Phil, did you mean shift the result right by two instead of four?

    I think he means divide by four which is shift two places right based on his code.
    Heater. wrote: »
    Is there an ADC that goes to eleven?:)

    Right because if your ADC is at 10 it has no place to go, but our has one extra bit.
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-10-04 08:49
    Heater. wrote: »
    Is there an ADC that goes to eleven?:)
    Actually there are quite a few 11-bit ADCs.
  • tonyp12tonyp12 Posts: 1,951
    edited 2012-10-04 09:03
    >Actually there are quite a few 11-bit ADCs.

    I think you missed out on the sarcasm.
    Though I have not seen the movie, 10 vs 11 comes from Spinal Tap.
    http://youtu.be/ll7rWiY5obI?t=1m18s

    10bit better than 8 or 9, but when 12-14bit would just sample the small background noice anyway.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-10-04 09:09
    Dave Hein wrote:
    Phil, did you mean shift the result right by two instead of four?
    No. The ADC is part of a family that includes a 12-bitter. To make the two compatible, the 10-bit version used by the PBOE uses bits 11..2 for the result, leaving zeroes in the two LSBs. So, to get an eight-bit result, you have to shift right by four.

    It's all in the datasheet. :)

    -Phil
  • Martin_HMartin_H Posts: 4,051
    edited 2012-10-04 09:15
    No. The ADC is part of a family that includes a 12-bitter. To make the two compatible, the 10-bit version used by the PBOE uses bits 11..2 for the result, leaving zeroes in the two LSBs. So, to get an eight-bit result, you have to shift right by four.

    OK That explains the shift right in your code. You were retaining 10 bits of precision by removing junk bits, you weren't truncating the precision down to eight.
  • kwinnkwinn Posts: 8,697
    edited 2012-10-04 23:59
    10 bits is a bit of a legacy item. Early SAR (Successive Approximation Register) adc's were expensive, and cost increased with the number of bits, so the bit count was kept to the absolute minimum required. Eight, ten, and twelve bits ( 1/256, 1/1024, and 1/4096) became the typical resolution standards of that time. They were also chosen because they fit reasonably well with the memory sizes since a byte sized memory could accommodate any number of eight bit, 3 ten bit, and 2 12 bit data points with very little wasted space.
Sign In or Register to comment.