9 posts / 0 new
Author
Message

I have a ADC, 8bit. My reference voltage is 5V,
so I have 256 distinct levels from 0 to 255.

`1LSB = Vref/(2^8) = 19.53mV`

Question: what's the voltage resolution (V/div) of my ADC?

I say:

`5V/256 (19.53mV)`

`5V/255 (19.6mV)`

So, 1LSB (not) equal to V/div ?
Not the same thing?

My (HW && SW) Setup: (MyAVR USB Programmer | bread-board | Butterfly | Arduino 10k | ATtiny2313 | ATmega8) && (WinAVR | AVR asm | AVRstudio)

Think of ADC as zones. If it were a two bit ADC, then there would be four zones: 00::0-1.2499v; 01::1.25-2.4999v; 10::2.5-3.7499; 11:3.75-5.0v. Any voltage in the zone is going to have a specific digital value.
Use the 5.0v / 256. Remember that analog is not going to be 100.000% accurate. An increasing voltage will produce increasing ADC values in reasonably-defined steps is all that the manufacturers claim with cheap ADCs.
Study the data sheets for various ADCs and all the tutorials on the web. Start simple and go deeper until the level of documentation meets your needs.

With a two bit ADC you wouldn't use 5v/3. So why use 5v/255 for an 8-bit?

I can think of one example.... I read the a/d and want to convert it to volts... I know 255 is 5.000 volts because thats what the meter reads. If I use v=ad*5.000/256.0 I get 5v-20mv->4.980v Just doesnt seem as 'exact'.

Imagecraft compiler user

Each AVR Datasheet with build in ADC has a chapter called "ADC Conversion Result". There you should find the formula:
ADC = Vin * 1024 / Vref (10bit resolution)

If you need to calculate the measured input voltage you use this formula:
Vin = ADC * Vref / 1024

When using 8-bit mode of the ADC (ADLAR bit in ADMUX register set) you have the following formulas:
ADC = Vin * 256 / Vref
Vin = ADC * Vref / 256

So with a Vref of 5V and an ADC result (8-bit mode) of 11 you get:
Vin = 11 * 5V / 256 = 0.215V

=> Vin = 0 * 5V / 256 = 0V

=> Vin = 255 * 5V / 256 = 4.98V

Well an ADC result of 255 should be better interpreted as Vin >= 4.98V

Regards
Sebastian

But if you have 255 in the denominator, fullscale is exact. Are the other 254 readings too low? I guess 0 is 0.

Imagecraft compiler user

But 255 isn't necessarily 5v, it is somewhere between 4.98v and 5v. And 0 is somewhere between 0v and 0.019v.

Regards,
Steve A.

The Board helps those that help themselves.

Koshchi wrote:
But 255 isn't necessarily 5v, it is somewhere between 4.98v and 5v. And 0 is somewhere between 0v and 0.019v.

Because 255 (all bit one) should correspond to a voltage between (VREF -1.5LSB) and VREF ... not only VREF?

My (HW && SW) Setup: (MyAVR USB Programmer | bread-board | Butterfly | Arduino 10k | ATtiny2313 | ATmega8) && (WinAVR | AVR asm | AVRstudio)

I respond myself :) Suppose we have a 2bit ADC with VREF=4V, so we have four intervals each width 1V since 1LSB=1V (1LSB=VREF/2^n), then:

```0V will converted as 0,
1V will converted as 1,
2V will converted as 2,
3V will converted as 3
```

And 4V?. Full scale voltage is (VREF-1LSB) so it is 3V (4-1) not 4V.

The inverse formula that given the number (N) returns analog value (V) is:

```V = VREF * N / 4
```

Infact:

```0 will converted as 0V,
1 will converted as 1V,
2 will converted as 2V,
3 will converted as 3V
```

If instead of 4 (2^n) we put 3 (2^n -1) in the above formula, we have a wrong D to A conversion:

```0 will converted as 0V,
1 will converted as 1,33V, *wrong*
2 will converted as 2,66V,*wrong*
3 will converted as 4V *wrong*
```

My (HW && SW) Setup: (MyAVR USB Programmer | bread-board | Butterfly | Arduino 10k | ATtiny2313 | ATmega8) && (WinAVR | AVR asm | AVRstudio)