07 Adc PDF
07 Adc PDF
E-Yantra Team
Embedded Real-Time Systems Lab
Indian Institute of Technology-Bombay
IIT Bombay
September 26, 2012
2 Coding ADC
ADC Initilization
ADCSRA
ADCSRB
ADMUX
ACSR
Program
X IR Proximity sensors
X IR Proximity sensors
X Sharp IR Range sensors
X IR Proximity sensors
X Sharp IR Range sensors
X white line sensors
X IR Proximity sensors
X Sharp IR Range sensors
X white line sensors
X battery voltage sensing
X IR Proximity sensors
X Sharp IR Range sensors
X white line sensors
X battery voltage sensing
X etc..
X 10-bit Resolution
X 10-bit Resolution
X 13 - 260 s Conversion Time
X 10-bit Resolution
X 13 - 260 s Conversion Time
X 16 Multiplexed Single Ended Input Channels
X 10-bit Resolution
X 13 - 260 s Conversion Time
X 16 Multiplexed Single Ended Input Channels
X 14 Differential input channels
X 10-bit Resolution
X 13 - 260 s Conversion Time
X 16 Multiplexed Single Ended Input Channels
X 14 Differential input channels
X Optional Left Adjustment for ADC Result Readout
X 10-bit Resolution
X 13 - 260 s Conversion Time
X 16 Multiplexed Single Ended Input Channels
X 14 Differential input channels
X Optional Left Adjustment for ADC Result Readout
X 0 - VCC ADC Input Voltage Range
X 10-bit Resolution
X 13 - 260 s Conversion Time
X 16 Multiplexed Single Ended Input Channels
X 14 Differential input channels
X Optional Left Adjustment for ADC Result Readout
X 0 - VCC ADC Input Voltage Range
X 2.7 - VCC Differential ADC Voltage Range
X 10-bit Resolution
X 13 - 260 s Conversion Time
X 16 Multiplexed Single Ended Input Channels
X 14 Differential input channels
X Optional Left Adjustment for ADC Result Readout
X 0 - VCC ADC Input Voltage Range
X 2.7 - VCC Differential ADC Voltage Range
X Selectable 2.56V or 1.1V ADC Reference Voltage
X 10-bit Resolution
X 13 - 260 s Conversion Time
X 16 Multiplexed Single Ended Input Channels
X 14 Differential input channels
X Optional Left Adjustment for ADC Result Readout
X 0 - VCC ADC Input Voltage Range
X 2.7 - VCC Differential ADC Voltage Range
X Selectable 2.56V or 1.1V ADC Reference Voltage
X Free Running or Single Conversion Mode
X 10-bit Resolution
X 13 - 260 s Conversion Time
X 16 Multiplexed Single Ended Input Channels
X 14 Differential input channels
X Optional Left Adjustment for ADC Result Readout
X 0 - VCC ADC Input Voltage Range
X 2.7 - VCC Differential ADC Voltage Range
X Selectable 2.56V or 1.1V ADC Reference Voltage
X Free Running or Single Conversion Mode
X Interrupt on ADC Conversion Complete
ADC Channels
ADC Channels
Pin No. Pin Name Description
97 PF0/ADC0 ADC input for Battery Voltage Monitoring
96 PF1/ADC1 ADC input for White Line Sensor 3(Right)
95 PF2/ADC2 ADC input for White Line Sensor 2(Center)
94 PF3/ADC3 ADC input for White Line Sensor 1(Left)
93 PF4/ADC4 ADC input for IR proximity analog sensor 1
92 PF5/ADC5 ADC input for IR proximity analog sensor 2
91 PF6/ADC6 ADC input for IR proximity analog sensor 3
90 PF7/ADC7 ADC input for IR proximity analog sensor 4
89 PK0/ADC8 ADC input for IR proximity analog sensor 5
88 PK1/ADC9 ADC input for Sharp IR range sensor 1
87 PK2/ADC10 ADC input for Sharp IR range sensor 2
86 PK3/ADC11 ADC input for Sharp IR range sensor 3
85 PK4/ADC12 ADC input for Sharp IR range sensor 4
84 PK5/ADC13 ADC input for Sharp IR range sensor 5
83 PK6/ADC14 ADC input for Servo Pod 1
82 PK7/ADC15 ADC input for Servo Pod 2
ADC Channels
Pin No. Pin Name Description
97 PF0/ADC0 ADC input for Battery Voltage Monitoring
96 PF1/ADC1 ADC input for White Line Sensor 3(Right)
95 PF2/ADC2 ADC input for White Line Sensor 2(Center)
94 PF3/ADC3 ADC input for White Line Sensor 1(Left)
93 PF4/ADC4 ADC input for IR proximity analog sensor 1
92 PF5/ADC5 ADC input for IR proximity analog sensor 2
91 PF6/ADC6 ADC input for IR proximity analog sensor 3
90 PF7/ADC7 ADC input for IR proximity analog sensor 4
89 PK0/ADC8 ADC input for IR proximity analog sensor 5
88 PK1/ADC9 ADC input for Sharp IR range sensor 1
87 PK2/ADC10 ADC input for Sharp IR range sensor 2
86 PK3/ADC11 ADC input for Sharp IR range sensor 3
85 PK4/ADC12 ADC input for Sharp IR range sensor 4
84 PK5/ADC13 ADC input for Sharp IR range sensor 5
83 PK6/ADC14 ADC input for Servo Pod 1
82 PK7/ADC15 ADC input for Servo Pod 2
1 Enabling ADC :
Set the ADEN bit of the ADC Control and Status Register ADCSRA
to logic 1.
1 Enabling ADC :
Set the ADEN bit of the ADC Control and Status Register ADCSRA
to logic 1.
2 ADC Prescaler Division Ratio :
Set the bits ADPS 2:0 of the Register ADCSRA. ADC needs clock
frequency between 50KHz to 200KHz
1 Enabling ADC :
Set the ADEN bit of the ADC Control and Status Register ADCSRA
to logic 1.
2 ADC Prescaler Division Ratio :
Set the bits ADPS 2:0 of the Register ADCSRA. ADC needs clock
frequency between 50KHz to 200KHz
3 Selecting reference voltage source for the ADC :
Select the reference voltage for ADC as AREF by making
REFS1:REFS0 as 00 (5 V)
1 Enabling ADC :
Set the ADEN bit of the ADC Control and Status Register ADCSRA
to logic 1.
2 ADC Prescaler Division Ratio :
Set the bits ADPS 2:0 of the Register ADCSRA. ADC needs clock
frequency between 50KHz to 200KHz
3 Selecting reference voltage source for the ADC :
Select the reference voltage for ADC as AREF by making
REFS1:REFS0 as 00 (5 V)
4 Left/Right Adjustment :
ADCH contains the two most significant bits and ADCL contains
the remaining eight bits. We left shift this data so that ADCH will
contain the eight bits including the MSB and ADCL will contain
remaining two LSBs
ADC Initilization
ADC Initilization
ADC Initilization
ADC Initilization
ADC Initilization
ADC Initilization
ADC Initilization
ADC Initilization
ADCSRA = 0x86
ADCSRB = 0x00
ADMUX = 0x20
ACSR = 0x80
ADC Initialization
ADC Initialization
void adc_init() //Set Register Values for starting ADC
{
ADCSRA =
ADCSRB =
ADMUX =
ADCSRA =
ACSR =
}
ADC Initialization
void adc_init() //Set Register Values for starting ADC
{
ADCSRA =
ADCSRB =
ADMUX =
ADCSRA =
ACSR =
}
Main Program
Main Program
int main(void)
{
init_devices();
lcd_init();
while(1)
{
print_sensor(1,1,0);
print_sensor(1,4,1);
print_sensor(1,8,2);
}
}
Main Program
int main(void)
{
init_devices();
lcd_init();
while(1)
{
print_sensor(1,1,0);
print_sensor(1,4,1);
print_sensor(1,8,2);
}
}
Main Program
int main(void)
{
init_devices();
lcd_init();
while(1)
{
print_sensor(1,1,0);
print_sensor(1,4,1);
print_sensor(1,8,2);
}
}
ADC_Value = ADC_Conversion(channel);
lcd_print(row, column, ADC_Value, 3);
Thank You!
Post your queries on: http://qa.e-yantra.org/