Author Topic: Variables  (Read 969 times)

0 Members and 1 Guest are viewing this topic.

Offline dannytemmermanTopic starter

  • Full Member
  • ***
  • Posts: 48
  • Helpful? 0
Variables
« on: February 22, 2009, 10:06:39 AM »
I am wondering how the value of a sensor is known. Does the IC check the voltage and than say a value to this voltage or what? I don't understand how this goes. Would somebody please explain it to me?



Offline Razor Concepts

  • Supreme Robot
  • *****
  • Posts: 1,856
  • Helpful? 53
Re: Variables
« Reply #1 on: February 22, 2009, 10:42:01 AM »
The 5v supply of the microcontroller is connected to the VREF pin. (Voltage reference). So if your sensor reading is outputting 2.5 volts, the microcontroller will divide 5 by 2.5 to get one-half, and then multiply it by 255 (for 8 bit ADC). I doubt the microcontroller actually goes through multiplying and dividing (there should be a more accurate way), but thats basically how it's done.

Offline ArcMan

  • Supreme Robot
  • *****
  • Posts: 519
  • Helpful? 4
  • Mmmm... Plasma
Re: Variables
« Reply #2 on: February 22, 2009, 01:09:09 PM »
I am wondering how the value of a sensor is known. Does the IC check the voltage and than say a value to this voltage or what? I don't understand how this goes. Would somebody please explain it to me?

I'm assuming you're talking about the value of an analog sensor.  Many microcontrollers come equipped with what's called an analog-to-digital converter (A/D converter).  This converter translates an analog voltage to a digital value used by your microcontroller code.  For example, a 10-bit A/D converter could convert a 0V - 5V analog input signal into a digital value with a range of 0 - 1023.

 


Get Your Ad Here