ADC (Analog-To-Digital Converter) and Sensor Interfacing
ADC (Analog-To-Digital Converter) and Sensor Interfacing
ADC (Analog-To-Digital Converter) and Sensor Interfacing
Systems
ADC (analog-to-digital converter)
and
Sensor Interfacing
Lecture 0902
1
2 2
ADC Modes
3 3
ADC Modes
If ADATE bit is 1,
We can use other modes as well by setting
ADTS2:0 in SFIOR register
4 4
Differential Mode ADC
5 5
Differential Mode ADC
6 6
ADC on Arduino
analogRead(pin)
pin: the name of the analog input pin to read
from. A0 to A7 on UNO
Returns: Digital Equivalent of Analog value
7 7
Example of Different
Analog Sensors
8
8
Analog Input Sensors
Vcc , GND , Signal
Light Dependent
Resistor
10
Temperature Sensor (LM35)
11
Temperature vs. Vout for AVR
(with Vref = 2.56)
S
12
Get data from LM35 sensor interfaced to channel 0 (ADC0) of ADC and
displays the result on Port D.
#include <avr/io.h> #include <avr/io.h>
while(1) while(1)
{ {
ADCSRA = ADCSRA | 0x40; ADCSRA = ADCSRA | 0x40;
PORTD = ADCL;
PORTB = ADCH; PORTB = ADCH;
} }
} }
13
DAC
(digital-to-analog
converter)
14
14
DAC (digital-to-analog converter)
Vout
4
3
2
VREF 1
Step size = 0 input
Num of steps 00 01 10 11
Binary number n
(input) DAC VOUT
Vref
15
Connecting a DAC to the Microcontroller
To scope
OUT –
VOUT = 0 to 10V
+ 1k
Comp
0.1uF
100 pF
PD7 D7
VEE -12V
GND
16
Generating a saw-tooth wave using DAC
#include <avr/io.h> LDI R16, 0xFF
OUT DDRD, R16
int main (void)
{
unsigned char i = 0; //define a counter AGAIN:
DDRD = 0xFF; //make Port D an output
Time
17