Why a ten bit ADC? Where do you store 10 bits?
Martin_H
Posts: 4,051
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.
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
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
I think he means divide by four which is shift two places right based on his code.
Right because if your ADC is at 10 it has no place to go, but our has one extra bit.
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.
It's all in the datasheet.
-Phil
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.