AVR Microcontroller: Prepared By: Eng. Ashraf Darwish
AVR Microcontroller: Prepared By: Eng. Ashraf Darwish
AVR Microcontroller: Prepared By: Eng. Ashraf Darwish
Prepared by:
Eng. Ashraf Darwish
Session 7
Introduction
Electrical quantities can be classified into :
Analoge
Digital
Range of voltage
Logic zero
0V
Logic one
5V
Any value between logic one
and logic zero is undefined.
ADC
ADC :
It
The
ADC
ADC
Electrical Resolution :
electrical resolution
(voltage per step)
VRefLow
M
ADC
Example:
resolution Q= 5/(2^10)
Q= 5/1024 = 4.88 mv
Which
ADC
Error :
There is no ACD without error. Simply because the
analog value is approximated to the nearest digital
value Theoretically
Practically
ADC
ATmega 16 has 8 ADC channels
ADC
1- ADC Multiplexer Selection Register
(ADMUX)
(ADCSRA)
(ADCL and
(SFIOR)
ADC
1- ADC Multiplexer Selection Register
Reference voltage
selection
(ADMUX)
ADC
ADC
Right adjustment
Left
adjustment
ADC
ADC
diferential Ended
Mode
ADC
2- ADC Control and Status Register A
(ADCSRA)
In
Free Running
mode, write this bit to one to start the first conversion.
ADC
2- ADC Control and Status Register A
When
This
(ADCSRA)
ADC
ADC
3- The ADC Data Register ADCL and ADCH
When an ADC conversion is complete, the result is
found in these two registers
When
ADLAR=0
When
ADLAR=1
ADC
4- Special Function IO Register (SFIOR)
Bit
7,6,5:
The value of these bits selects which source will trigger an ADC
conversion
ADC
Modes of Operation :
1- single conversion mode:
Only one conversion and repeated by request (ADSC=1)
2- Auto triggering mode:
A conversion can be triggered automatically by various
sources. The trigger source is selected by setting the ADC
Trigger Select bits, ADTS in SFIOR
3- Free running mode:
Starting new conversion as soon as the ongoing conversion
has finished. The first conversion must be started by writing
one to ADSC bit in ADCSRA register
ADC Example
- I want to run ADC0 (pin 40).
- Single conversion mode.
- left adjusted and only the 8 MSB will be used.
- No ADC interrupts.
- Speed=500 000 bps.
Then:
//ADMUX =0x60
//ADCSRA= 0x80
//To start conversion
//ADCSRA|=0x40 or
//ADCSRA.6=1
ADC Example
- I want to run ADC0 (pin 40).
- Single conversion mode.
- left adjusted and only the 8 MSB will be used.
- No ADC interrupts.
- Speed=500 000 bps.
Then:
//ADMUX =0x60
//ADCSRA= 0x80
//To start conversion
//ADCSRA|=0x40 or
//ADCSRA.6=1
Temperature sensor
The most known Application of ADC
It
has 3 pins
VCC
GND
Output
Final Project
links
http://www.atmel.com/products/microc
ontrollers/default.aspx?src=parent
http://www.avrfreaks.net/
http://ram-e-shop.com/oscmax/catalo
g/
http://www.nekhely.com/home-new.h
tm
http://sa.rsdelivers.com/
http://www.sparkfun.com/
Thank you
Contact:
http://www.facebook.com/groups/263197427113025
/
[email protected]
[email protected]
+201064897791