Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ATMEGA328p convert analog value to voltage

Tags:

c

embedded

atmega

This is an extract of the official ATMEGA328p data sheet page 261:

enter image description here

As the documentation say

      Vin * 1024
ADC = ----------
         Vref

What I don't understand is an analog pin can provide us 10bits. That's mean a value between 0x0 and 0x3ff (1023)

So I don't understand why the documentation say Vin * 1024 and not 1023. Because for me 0v = 0 and 5v = 1023?

like image 730
Fpasquer Avatar asked Aug 17 '19 08:08

Fpasquer


People also ask

How do you convert analog voltage to digital voltage?

The value is obtained by dividing the sampled analog input voltage by the reference voltage and them multiplying by the number of digital codes. The resolution of converter is set by the number of binary bits in the output code. An ADC carries out two processes, sampling and quantization.

Does atmega328 have analog to digital converter?

The Atmel ATmega328P microcontroller used on the Arduino Uno has an analog-to-digital conversion (ADC) module capable of converting an analog voltage into a 10-bit number from 0 to 1023 or an 8-bit number from 0 to 255. The input to the module can be selected to come from any one of six inputs on the chip.

How do you convert analogue to digital value?

ADCs follow a sequence when converting analog signals to digital. They first sample the signal, then quantify it to determine the resolution of the signal, and finally set binary values and send it to the system to read the digital signal. Two important aspects of the ADC are its sampling rate and resolution.

How do you convert analogue to digital value in Arduino?

The Arduino has a built-in analog-to-digital converter (ADC) that measures the value of analog signals. The ADC converts the analog voltage into a digital value. The function used in order to obtain the value of an analog signal is analogRead(pin).


1 Answers

0 counts as a valid reading. 1..1023 is 1023 steps and plus 0 that makes 1024. 0x000 represents analog ground, and 0x3FF represents the selected reference voltage minus one LSB. In reality, ADCs are not perfect as results can have more than 1 count of error and it really does not matter much if 1023 or 1024 is used. In theory using 1024 is more accurate.

like image 163
Lakshitha Wisumperuma Avatar answered Oct 02 '22 23:10

Lakshitha Wisumperuma