ROBO INDIA
http://roboindia.com
ROBO INDIA
SIGNAL
DISCRETE CONTINOUS
ROBO INDIA
• Are all CONTINUOUS time signals ANALOG ?
• All continuous time signals are analog but all
analog signals are not continuous time
ROBO INDIA
ANALOG
Cont. Time
Discrete
Time
ROBO INDIA
• The ADC converts an analog input
voltage to a 10-bit digital value through
successive approximation.
• The minimum value represents GND
and the maximum value represents the
voltage on the AREF pin minus 1 LSB
ROBO INDIA
𝐴𝐷𝐶 =
𝑉𝑖𝑛 . 1024
𝑉 𝑟𝑒𝑓
ROBO INDIA
Signal
Processing
Analog Digital Mixed
ROBO INDIA
• What's wrong with totally analog ?
• Ans – Two arrows in a Quiver is always
better than one
ROBO INDIA
A digital signal is superior to an analog
signal because it is more robust to noise
and can easily be recovered, corrected
and amplified. For this reason, the
tendency today is to change an analog
signal to digital data
ROBO INDIA
ROBO INDIA
ROBO INDIA
ReadADCX()
{
ADMUX=0x4X;
ADCSRA=0x86;
SETBIT(ADCSRA,BIT(6));
while(!(ADCSRA & (1<<ADIF)));
s=ADC;
return(s);
}
NOTE: X can take value from 0 to 7
ROBO INDIA
• ADMUX = 0x4X
• Let x = 1
⇒ ADMUX = 0x41 ⇒ ADMUX = 01000001
0 1 0 0 0 0 0 1
ROBO INDIA
• REFS1 = 0
• REFS0 = 1
0 1 0 0 0 0 0 1
ROBO INDIA
The ADLAR bit affects the presentation of
the ADC conversion result in the ADC Data
Register.
• ADLAR = 0 ⇒ LEFT ADJUST
• ADLAR = 1 ⇒ RIGHT ADJUST
0 1 0 0 0 0 0 1
ROBO INDIA
• MUX4..0 = 00001
0 1 0 0 0 0 0 1
ROBO INDIA
ReadADCX()
{
ADMUX=0x4X; // DONE
ADCSRA=0x86;
SETBIT(ADCSRA,BIT(6));
while(!(ADCSRA & (1<<ADIF)));
s=ADC;
return(s);
}
NOTE: X can take value from 0 to 7
ROBO INDIA
• ADCSRA = 0x86
• Let x = 1
⇒ ADCSRA = 0x41 ⇒ ADCSRA = 10000110
1 0 0 0 0 1 1 0
ROBO INDIA
• BIT 7
• ADEN ⇒ ADC Enable bit
• ADEN = 1 ⇒ Enable ADC
• ADEN = 0 ⇒ Disable ADC
1 0 0 0 0 1 1 0
ROBO INDIA
• BIT 6
• ADSC - Write this bit to one to start
each conversion
1 0 0 0 0 1 1 0
ROBO INDIA
• BIT 4
• ADIF - This bit is set when an ADC
conversion completes
1 0 0 0 0 1 1 0
ROBO INDIA
ADPS2..0 = 110 ⇒ Division factor is 64
1 0 0 0 0 1 1 0
ROBO INDIA
ReadADCX()
{
ADMUX=0x4X; // DONE
ADCSRA=0x86; // DONE
SETBIT(ADCSRA,BIT(6)); // DONE
while(!(ADCSRA & (1<<ADIF)));
s=ADC;
return(s);
}
NOTE: X can take value from 0 to 7
ROBO INDIA
www.roboindia.com
Mail-info@roboindia.com

ADC - Analog to Digital Conversion on AVR microcontroller Atmega16