Voltage to Digital

In one of the tech support forums, bg-bleah (I think that was the user name) posted the following question:

Unfortunately that forum does not allow general forum members to post replies, so I will post mine here.

In answer to the specific question of how a voltage is converted to a digital value (sometimes referred to as an “Analog Input” because the digital value represents the analog input), there are a number of good explanations on the web, including the answer provided by IFI. It seems most explanations of analog to digital conversion (ADC) on the web are related to measuring voltages over time, such as you would do when digitizing music (repeatedly measuring your arm position is not so different from recording sound). The specifics of how, exactly, that works are perhaps more complex than you want to get in to as a beginner… you can take it that it is done by a “magic black box”. (As Arthur C. Clarke said, “Any sufficiently advanced technology is indistinguishable from magic.”) If you want a quick overview, however, consider that a ten-bit ADC converter can measure 2^10 different values (0-1,023). In this case 0 represents zero volts and 1023 represents 5v (this particular ADC is only good to five volts.) Thus a value of “1” is approximately 5/1023= .005V, while a value of 512 is (5/1023)*512=2.5V

The best way to get a conversion table for rotation to a specific value is to hook up your potentiometer, and move turn it back and forth while using the terminal screen to print out values of that particular input. Do that again with the pot on the robot and you should be able to build a chart of values to arm angles. You may find that your range of values does not go precisely from zero to 1,023 so a bit of experimentation is best.

As for the books, however, there are MANY great books for the budding robot builder. I have pulled one example off my shelf, “123 Robotics Experiments for the Evil Genius” by Myke Predko (McGraw-Hill publishing). Variable resistors (aka potentiometers) are covered on page 52. In fact this book comes with a very high recommendation… one of the students on our FRC team bought it for me as she thought it was a good book that I would like… and she was right.

But there are lots of other good books out there, too. I’m sure that now this is on an open forum that others will post their suggesitons.

Jason

Thank you for the answer.
As far as the AD conversion. I ‘googled’ and I red the datasheet from Microchip and unfortunatly nobody explains it for beginners, smth like ’ if the converter receives 3V than this things happen and that’s how you get a number’. I didn’t think the value is proportional to input like you are suggesting. Duh…
Regarding the AD value to angle for a potentimer. I ended up with a set of values for 10 degree increments and ran an interpolation software to get the best fitting function. I plan on using an encoder to get increments of 4 degrees for better accuracy. I’m also applying the same method for a Sharp GP2D12 IR sensor.
Books… I guess I’ll just go for it 'till I find smth I can understand :slight_smile:
Thank you again for the post.

PS: Is there such a thing as a ‘cheap’ lidar hobby robotics?

If you double the gearing, the encoder or other device will be twice as accurate. The potentiameter has a limited range of motion though, so you’d be having the distance of course. The encoder tops out at a certain speed, but you could go from 4->2->1 by speeding it up by 4x. If you go slow enough, you’d have plenty of accuracy.