Author Topic: Analog to digital converter questions  (Read 630 times)

0 Members and 1 Guest are viewing this topic.

Offline garriwilsonTopic starter

  • Supreme Robot
  • *****
  • Posts: 345
  • Helpful? 0
Analog to digital converter questions
« on: December 29, 2013, 01:43:50 PM »
Hey guys, so I've been trying to understand all of the $50 robot code and ran into some technical questions.

So when one of the ADC ports on the microcontroller converts an analog voltage value from the photoresistor to a digital value, how do you know what digital number you will get for that analog signal? My guess would be to find the resolution of the ADC, which I think would be (Vmax-Vmin)/(2^N), where N is the number of bits. Is this correct? To get the range of Vmax-Vmin, is Vmax = 5V and Vmin= 0V?

If my thinking is right so far I would get: (5V - 0V)/(2^8) = 0.0195 Volts/division. So then let's say I wanted to know what number the microcontroller would get from a voltage reading of 3V from the photoresistor. It would be (3V)*(1/0.0195) = 153.8

Thanks for your help!

Offline jwatte

  • Supreme Robot
  • *****
  • Posts: 1,345
  • Helpful? 82
Re: Analog to digital converter questions
« Reply #1 on: December 29, 2013, 04:08:20 PM »
Yes, that is approximately right. There are some small deviations (the maximum resolvable range may be different from exactly AREF through GND, for example) and some noise, but you've got it basically right. Also, you will only get an integer number back from the ADC, not a floating-point number.


Get Your Ad Here