The ADC conversion equation is ADC=Vin*1024/Vref Let's choose Vref=1.1V Vin=0.5V The theoretical result should be ADC=465.4545 that round up to integer ADC=466 or 465. But the experimental result was ADC>=1023. What happened in this business? 0.5V was read from multimeter, Im not sure how ADC seen it other wise. Also how exactly does the mcu perform calculation anyway? How does it handle decimals? Round up before the conversion or round up after conversion?
ADC measuring <1V Vin
1) What AVR model are you using?
2) What clock speed for the AVR?
3) What supply voltage for the AVR?
4) All Vcc and Gnd pins connected and properly decoupled?
5) Schematic of the test circuit?
6) Code for the testing. In particular, we'll be looking at reference circuit, reference selection, ADC clock speed, tossing first conversion result, proper ADCL/ADCH read order, ...
Also how exactly does the mcu perform calculation anyway?
Have you read the ADC chapter in the datasheet? What part of the above is not clear?
Oh, yeah...
But the experimental result was ADC>=1023.
I want to hear more about the ADC > 1023 cases. :twisted:
Around 29760? (== 465 << 6)
You probably have chosen left adjusted result.
Ok the chip is mega48, there is only one conversion method ADC=Vin*1024/Vref
AVR clock 1MHz ADC clock = 1MHz/8 = 125kHz (the datasheet recommend 50k~200kHz)
Vcc=6V
Of course Gnd and Vcc are connected correctly, the same circuit was tested on other programs, not sure what you mean by decoupled.
The circuit is sample, capacitors on AVCC on VREF, (not sure do I really need the AVCC capacitor?) Led on PB0, ADC input on PC2 (Vcc in series with 300k resistor Vcc=6V) I will give the detail later, Im in an hurry now.
Oh, yeah...
Quote:
But the experimental result was ADC>=1023.
I want to hear more about the ADC > 1023 cases. :twisted:
damn typo, what I was thinking? that should be ADC==1023
AVCC is the VCC for portA, so it definitely needs to get VCC. The general checklist is: All VCC pins to 5V (not 6V! abs max is 5.5! You'll let the smoke out!), all gnd pins to gnd, cap on AREF to gnd to make the ref voltage stable. You select the 1.1V internal ref by reading channel 11 or something. Check the datasheet of course.
Of course Gnd and Vcc are connected correctly
:roll: Please show
5) Schematic of the test circuit?
Though you gave a description, it is not clear. If indeed you have Vcc --> series resistor --> ADC pin then obviously you will get Vcc on the pin. But that cannot be the circuit as you said there is .2V on the pin.
And also:
6) Code for the testing. In particular, we'll be looking at reference circuit, reference selection, ADC clock speed, tossing first conversion result, proper ADCL/ADCH read order, ...
The ADC conversion equation is ADC=Vin*1024/Vref Let's choose Vref=1.1V Vin=0.5V The theoretical result should be ADC=465.4545 that round up to integer ADC=466 or 465.
You miss something.The ADC returned value is always a 10bit integer 0...1023.The reference voltage is what you choose.Internal,external,vcc external and is a constant in the calculations as constant is the 10bit maximal value of the ADC.
The input voltage in the ADC pin will be
Volts=(ADC returned value/1024)*VRef and a float result is expected as the minimal step is VRef/1024.
If a resistors divider is used in the pin then to find the real voltage that applied in that pin the calculated voltage must be multiplied with the dividers ratio.
Volts=(ADC returned value/1024)*VRef*dividers ratio.
The circuit is sample, capacitors on AVCC on VREF, (not sure do I really need the AVCC capacitor?) Led on PB0, ADC input on PC2 (Vcc in series with 300k resistor Vcc=6V) I will give the detail later, Im in an hurry now.