Hey guys,
is my understand correct, that if you read a free analog in-port, you will get a figure between 0 and 1023. I am using a Arduino Uno, which has a 10-bit ADC.
Thanks a lot

That is correct.

Thank you

tilo55:
Hey guys,
is my understand correct, that if you read a free analog in-port, you will get a figure between 0 and 1023. I am using a Arduino Uno, which has a 10-bit ADC.

A figure in the following range:

Between may mean excluding 0 and 1023.

The value you get , let’s name it “ADCValue”, will be an INTEGER in the range : 0<= ADCValue <=1023

Spare a minute and take a look at uC’s datasheet.

The following diagram may help OP to see how the converted value (ADCValue) could be in this range: 0<= ADCValue <=1023.

GolamMostafa:
The following diagram may help OP to see how the converted value (ADCValue) could be in this range: 0<= ADCValue <=1023.

Apart from the label at the very bottom that reads “10-Bit ADC”, I don’t really see how.

TheMemberFormerlyKnownAsAWOL:
Apart from the label at the very bottom that reads “10-Bit ADC”, I don’t really see how.

Let us ground A0-pin. The input analog voltage (VD) is 0V (forget the noise). The ADC will produce this value for B9 - B0 bits (let us forget the +/-2-bit error of the ADC): 00 0000 0000b = 000h = 0 (decimal)

Let us connect 5V (the Full Scale which is equal to the voltage of VREF-pin) at A0-pin. The ADC will produce this value for B9 - B0 bits (let us forget the +/-2-bit error of the ADC): 11 1111 1111b = 3FFh = 1023 (decimal).

When a user executes the following instructions, the value of the ADC Register (ADCH, ADCL) comes into variable x and then goes onto Serial Monitor.

``````unsigned int x = analogRead(A0);    //0<= x <=1023
Serial.print(x, DEC);
``````

Let us connect 5V - 1 LSB.
The ADC will produce this value for B9 - B0 bits (let us forget the +/-2-bit error of the ADC): 11 1111 1111b = 3FFh = 1023 (decimal).

How was anyone supposed to deduce all that from that over-complicated diagram?

TheMemberFormerlyKnownAsAWOL:
Let us connect 5V - 1 LSB.
The ADC will produce this value for B9 - B0 bits (let us forget the +/-2-bit error of the ADC): 11 1111 1111b = 3FFh = 1023 (decimal).

How was anyone supposed to deduce all that from that over-complicated diagram?

Full Scale : 5000 mV
Weight/LSBit = 5000/1023 ~= 4.88 mV
Given: Input Voltage at A0-pin = 5000 mV - 4.88 mV = 4995.12 mV

Because the ADC will respond to a change of 4.88 mV in the input voltage, the ADC will see 4995 mV and accordingly the B9 - B0 bits will assume this pattern: (1023/5000)*4995 ~= 1022 = 3FEh = 11 1111 1110.

GolamMostafa:
Full Scale : 5000 mV
Weight/LSBit = 5000/1023 ~= 4.88 mV
Given: Input Voltage at A0-pin = 5000 mV - 4.88 mV = 4995.12 mV

Because the ADC will respond to a change of 4.88 mV in the input voltage, the ADC will see 4995 mV and accordingly the B9 - B0 bits will assume this pattern: (1023/5000)*4995 ~= 1022 = 3FEh = 11 1111 1110.

No cigar.

Cigar VS. Cigarette.
Analogue VS. Analog.

GolamMostafa:
Full Scale : 5000 mV
Weight/LSBit = 5000/1023 ~= 4.88 mV
Given: Input Voltage at A0-pin = 5000 mV - 4.88 mV = 4995.12 mV

Because the ADC will respond to a change of 4.88 mV in the input voltage, the ADC will see 4995 mV and accordingly the B9 - B0 bits will assume this pattern: (1023/5000)*4995 ~= 1022 = 3FEh = 11 1111 1110.

I refer my unlearned friend to the processor’s datasheet, section 24.7 “ADC Conversion Result”

After the conversion is complete (ADIF is high), the conversion result can be found in the ADC Result Registers
For single ended conversion, the result is
V IN  1024
V REF
where V IN is the voltage on the selected input pin and V REF the selected voltage reference (see Table 24-3 on
page 257 and Table 24-4 on page 258). 0x000 represents analog ground, and 0x3FF represents the selected
reference voltage minus one LSB.

Edit: Apologies - the cut and paste from the .PDF doesn’t show the equation correctly.

This is the definition of ‘Full Scale’ of an ADC that I know:

It (the Full Scale) is the voltage equal to the voltage of VREF-pin which when placed on an analog channel, the ADC assumes HIGHs for its all bits. Accordingly,

VREF = 5V; Voltage at A0-pin = 5V; ADC Result Registers will hold: 11 1111 1111 = 1023.
VREF = 1.1V; Voltage at A0-pin = 1.1V; ADC Result Registers will hold: 11 1111 1111 = 1023.

VREF = 5V; Voltage at A0-pin = 5V - LSB = 5000 mV - 5 mV; ADC Result Registers will hold: 11 1111 1110 = 1022 = 0x3FE.

Where am I wrong – beyond my understanding?

VREF = 5V; Voltage at A0-pin = 5V; ADC Result Registers will hold: 11 1111 1111 = 1023.

Yes, because 5V is over-range, so the ADC can only return 1023.

If you don’t believe the manufacturer’s own datasheet, then I suspect that yes, it is beyond your understanding.

Imagine a one bit successive approximation ADC, with a 1V reference.

If 0 has to represent 0V, then 1 must represent 0.5V and above.

TheMemberFormerlyKnownAsAWOL:
If you don't believe the manufacturer's own datasheet, then I suspect that yes, it is beyond your understanding.

Usually, we don't argue much on manufacturer's datasheet as we, in general, live well with +/-2% error except for some critical applications like research, manned space mission, nuclear plant etc.

1024-1023/1023 ==> 0.09% error.

" “Beauty is truth, truth beauty,” – that is all
Ye know on earth, and all ye need to know. "

Keats.