Presentation is loading. Please wait.

Presentation is loading. Please wait.

By: Shivanshi pandya(30) Ayushi chourasia (3) Pranavi chhikniwala(6)

Similar presentations


Presentation on theme: "By: Shivanshi pandya(30) Ayushi chourasia (3) Pranavi chhikniwala(6)"— Presentation transcript:

1 By: Shivanshi pandya(30) Ayushi chourasia (3) Pranavi chhikniwala(6)

2 Introduction In this chapter we will describe ADCs(Analog-to-Digital Converters) and interfacing of Sensors in AVR. In section 1, we describe ADCs(Analog-to-Digital Converters) chip. In section 2, we will program the ADC portion of th AVR chip. In section 3, we show the interfacing of the sensors.

3 Microcontroller connection to sensor via ADC

4 do Analog Input Start Conversation Vin D0 D7 Binary Data Output Vref An 8-bit ADC block diagram ATmega32 ADC features It is a 10-bit ADC. It has 8 Analog, 7 Differential, and 2 Differential INPUTS. The converted OUTPUT binary data is held by two special function registers. We have the option of making either the upper or lower 6-bits unused. Also we have three options for choosing Vref. The conversion time is detected by crystal frequency connected to XTAL pin.

5 PROGRAMMING of ADC in AVR In the AVR microcontroller 5 major registers are associated with the ADC that we deal in this topic. 1.ADCH(High data) 2.ADCL(Low data) 3.ADCSRA(ADC control and status register) 4.ADMUX(ADC Multiplexer Selection register) 5.SPIOR(Special Function I/O register)

6 REFS1 REFS0ADLARMUX4MUX3MUX2 MUX1MUX0 ADMUX(ADC MULTIPLEXER SELECTION) Register REF1:0 Bit 7:6 Reference Selection Bits These bits select the reference voltage for ADC ADLAR Bit 5 ADC Left Adjust Results This bit dictates either the left bits or the right bit bits of the result register ADCH:ADCL that are used to store the result. MUX4:0 Bit 4:0 Analog Channel and Gain Selection Bits The value of these bits selects the gain for the differential channels and also selects which combination of analog inputs are connected to the ADC.

7 REFS1REFS0Vref 00AREF pinSet Externally 01AVCC pinSame as VCC 10Reserved……… 11Internal 2.56 VFixed regardless of VCC

8 ADCL(A/D Result Low) and ADCH(A/D Result High) The converted output data is held by two special function registers call ADCL and ADCH. ADCH:ADCL registers gives us 16 bits and ADC data out is only 10 bits wide, 6 bits of the 16 are unused. We have the option of making either the upper 6 or the lower 6 bits unused. D9D8D7D6D5D4D3D2 D7D6D5D4D3D2D1D0 UNUSEDD9D8 D1D0UNUSED ADLAR=1 ADLAR=0 Left justified Right justified ADCH ADCL

9 MUX 4…0 MUX combination are used to choose the input channel i.e. select single-ended or differential input. We can also select the Op-amp gain. MUX4…0Single-ended input 00000ADC0 00001ADC1 00010ADC2 00011ADC3 00100ADC4 00101ADC5 00110ADC6 00111ADC7

10 ADCSRA register ADEN ADSCADATEADIFADIEADSP2 ADSP1ADSP0 ADEN Bit 7 ADC Enable This bit enable or disables the ADC. Setting this bit to one will enable the ADC, and clearing this bit to zero will Disable it even while a conversation is in progress. ADSC Bit 6 ADC Start Conversion To start each conversion you have to set this bit to one. ADATE Bit 5 ADC Auto Trigger Enable Auto Trigger ing of the ADC is enabled when you set this bit to one. ADIF Bit 4 ADC Interrupt Flag This bit is set when an ADC conversion completed and data registers are updated. ADIE Bit 3 ADC Interrupt Enable Setting this bit to one enables the ADC conversion complete interrupt. ADSP2:0 Bit2:0 ADC Prescaler Select Bits These bits Determine the division factor between the XTAL frequency and the input clock to the ADC.

11 ADPS2:0 (A/D conversion time) According to combination of this 3 bit we can select the conversion time with the different prescalers of crystal Frequency(Fosc) connected to AVR chip. ADPS2ADPS1ADPS0ADC Clock 000Reserve d 001Ck/2 010Ck/4 011Ck/8 100Ck/16 101Ck/32 110Ck/64 111Ck/128 7 Bit ADC Prescaler 1 2 3 4 5 6 7 Ck/2 Ck/4 Ck/8 Ck/16 Ck/32 Ck/64 Ck/128 ADPS0 ADPS1 ADPS2 ADC Clock Source

12 Moving forward to the awaited moment…… programming in AVR.. Task : write a program to glow the leds connected on port B and port D according to the reading of temperature sensor.

13 .INCLUDE”M32DEF.INC”; LDI R16,0XFF; OUT DDRD,R16; SBI DDRA,0; LDI R16,0X87; OUT ADCSRA,R16; LDI R16,E0; OUT ADMUX,R16; READ_DATA: SBI ADCSRA,ADSC; CHECK_INTERRUPT: SBIS ADCSRS,ADIF; JMP CHECK_INTERRUPT; SBI ADCSRA,ADIF; IN R16,ADCL; OUT DDRD,R16; IN R16,ADCH; OUT DDRB,R16; JMP READ_DATA;

14 THANK YOU…


Download ppt "By: Shivanshi pandya(30) Ayushi chourasia (3) Pranavi chhikniwala(6)"

Similar presentations


Ads by Google