23 February 2008

Bits!!!

Found the bits ...

So last night I connected a pot to V+ as a way of experimenting with different voltages and seeing what I values are read. Figured I'd notice something ... And I did. I got screwey values, but they tended to be bimodal. I put the pot in the middle and it reads some 2091 value. And then some -14295's. And then back to 2091. And back to -14295's. So I drop to 0V, or as near as the pot can get to it. And get -8197 and 8188. With +5V: just -12301.

Two high bits are random!

And that makes total sense when thinking about what the MCP3301 datasheet said. For the first two clocks the data out is held at high impedance. Which means random data is read. Next is a 0 bit followed by the value, sign bit first.

Change my code to check the sign bit and set the high three bits appropriately. Now everything is cool. Pot all the way left is -4. Middle is 1904. All the way right is 4083.

So that's 12 bits. As I'm getting a -4 that means I should be able to go down to near -4095 for the other bit. Probably just need to adjust Vref.

No comments:

Post a Comment