Professional Documents
Culture Documents
ADC
Our Microcontroller is digital electronics device It can respond to only two states -- either ON or OFF Here Comes ADC Feature which converts continuous variation into discrete levels represented by a sequence of digit 0 or digit 1.
ADC uses a Reference Voltage to convert the analog input. 1023 = 5V 255= 5V
512= 2.5 V
127= 2.5 V
0= 0 V 8 bit Resolution
Resolution: The minimum value of analog quantity for which the ADC responds.
Let Reference Voltage= 5 Volt Thus In 10 bit ADC Resolution-- 5/1024 = 4.89 mV or around 5mV In 8 bit ADC Resolution-- 5/256 = 19.53mV or around 20mV
A
T M
E G
A 8
In Atmega8 PORTC is Multiplexed with ADC. PORTC can work as both IO PORT or ADC .
Three Registers are used to operate the ADC. ADC can be used for interfacing analog devices like temperature sensors etc. to the microcontroller.
ADMUX REGISTER
This register is used to select the reference voltage for conversion.
To Enable the ADC. To start each ADC conversion. To operate ADC in Free Running mode. This bit is set when an ADC conversion completes When this bit is written to one and the I-bit in SREG is set, the ADC Conversion Complete Interrupt is activated. Bits 2:0 ADPS2:0 :- ADC Prescaler Select To provide ADC Clock
:::::-
ADC PRESCALER
ADPS2 0 0 ADPS1 0 0 ADPS0 0 1 Division Factor 2 2
0
0 1 1
1
1 0 0
0
1 0 1
4
8 16 32
1
1
1
1
0
1
64
128
ReadADC()
This Function is used read the selected ADC input pin passed as a parameter.
uint16_t ReadADC(uint8_t ch) { //Select ADC Channel ch must be 0-7 ch=ch&0b00000111; ADMUX|=ch; //Start Single conversion ADCSRA|=(0b01000000); //set ADSC //Wait for conversion to complete while(!(ADCSRA & (0b00010000))); // wait for ADIF bit of ADCSRA to be enabled //Clear ADIF by writing one to it ADCSRA|=(00010000); return(ADC); }
EXAMPLE
TEMPERATURE SENSOR
With the help of ADC, we can monitor the change in the ambient temperature.
THANK YOU!!!