Presentation is loading. Please wait.

Presentation is loading. Please wait.

Digital to Analogue Converter

Similar presentations


Presentation on theme: "Digital to Analogue Converter"— Presentation transcript:

1 Digital to Analogue Converter
Unitec New Zealand Digital to Analogue Converter © Unitec New Zealand

2 ADC Characteristics All real world quantities are analog in nature. We need to convert that analog quantities to digital as computer understand the world of 1’s and 0’s. Then we are able to display an analog quantity. © Unitec New Zealand

3 Temperature sensor © Unitec New Zealand

4 ADC resolution ADC has n-bit resolution, where n can be 8, 10, 12, 16 or 24 bits. The higher resolution provides a smaller step size, where step size is the smallest change that can be discerned by an ADC. Although the resolution of ADC chip is decided at the time of its design and cannot be changed, but we can control the step size with the help of what is called vref. © Unitec New Zealand

5 Resolution of ADC Resolution vs step size for ADC (vref=5V) N-bit
Number of steps Step size (mV) 8 256 5/19.53=19.53 10 1024 5/1024=4.88 12 4096 5/4096=1.2 16 65536 5/65536=0.076 © Unitec New Zealand

6 Conversion time Conversion time is defined as the time, it takes to convert the analog input to a digital (binary ) number. The conversion time is dictated by the clock source connected to the ADC in addition to the method used for data conversion and technology used in the fabrication of ADC chip such as MOS or TTL technology © Unitec New Zealand

7 V reference Vref is input voltage used for the reference voltage.
The voltage connected to this pin, along with the resolution of the ADC chip, dictate the step size. For an 8-bit ADC, the step size is Vref/256. © Unitec New Zealand

8 Vref relation to Vin range for an 8bit ADC
Vref (V) Vin (V) Step size (mV) 5 0 to 5 5/256=19.53 4 0 to 4 4/256=15.62 3 0 to 3 3/256=11.71 2 0 to 2 2/256=7.81 1 0 to 1 1/256=3.9 © Unitec New Zealand

9 Vref relation to Vin range for an 10bit ADC
Vref (V) Vin (V) Step size (mV) 5 0 to 5 5/1024=4.88 4.096 0 to 4.096 4.096/1024=4 3 0 to 3 3/1024=2.93 2.048 0 to 2.048 2.048/1024=2 1.024 0 to 1.024 1.024/1024=1 In some applications, we need the differential reference voltage where Vref=Vref(+) – Vref(-). © Unitec New Zealand

10 Digital data output In an 8 bit ADC, we have an 8 bit digital data output of D0-D7 while in the 10 bit ADC the data output is D0-D9. To calculate the output voltage, the formula used is Dout= Vin/ step size Where Dout =digital data output (in decimal), Vin=analog input voltage and step size (resolution) is the smallest change, which is Vref/256 for an 8 bit ADC. © Unitec New Zealand

11 Example For an 8 bit ADC, we have Vref=2.56 V. calculate the D0-D7 output if analog input is 1.7 V 2.1 V Solution:- A)Step size is 2.56/256= 10 mv, Dout= 1.7/10mv =170 in decimal Binary 170= Find out solution for b. © Unitec New Zealand

12 Analog input channels Normally, many data acquisition systems have more than one ADC channels. PIC16F877a have 11 Analog channels and it can accept 11 analog sources to be digitized but only one input channel can be digitized at a time. © Unitec New Zealand

13 Start conversion and end of conversion signals
In case of multiple analog input channels and a single digital output register makes it necessary for start conversion (SC) and end of conversion (EOC) signals. When SC activated, the ADC starts converting the analog input value of Vin to an n-bit digital number. The amount of time it takes to convert varies depending on the conversion method. When the data conversion is complete, the end EOC signal notifies the CPU that the converted data is ready to be picked up. © Unitec New Zealand

14 Steps to follow for ADC Chip
Select a channel Activate the start of conversion (SC) signal to start the analog input. Keep monitoring the end of conversion signal After the EOC has been activated, read the data out from ADC chip © Unitec New Zealand

15 ADC in PIC Following registers control the functionality of ADC in PIC 16f877a. ADCON0, ADCON1 ADRESH, ADRESL ADSELH, ADSEL INTCON, PIE1, PIR1 PORTA, B, C TRISA, B, C © Unitec New Zealand

16 ADC in PIC microcontroller.
PIC has 10 bit resolution Analog-to-Digital Converter. This device uses analog inputs, which are multiplexed into a single sample and hold circuit. The output of the sample and hold is connected to the input of the converter. The converter generates a 10-bit binary result via successive approximation and stores the conversion result into the ADC result registers (ADRESL and ADRESH). The ADC voltage reference is software selectable to either VDD or a voltage applied to the external reference pins. The ADC can generate an interrupt upon completion of a conversion. This interrupt can be used to wake-up the device from Sleep. © Unitec New Zealand

17 ADC Block diagram © Unitec New Zealand

18 ADC Configuration When configuring and using the ADC the following functions must be considered: Port configuration Channel selection ADC voltage reference selection ADC conversion clock source Interrupt control Results formatting © Unitec New Zealand

19 PORT CONFIGURATION and channel selection
The ADC can be used to convert both analog and digital signals. When converting analog signals, the I/O pin should be configured for analog by setting the associated TRIS and ADCON1 bits. The CHS bits of the ADCON0 register determine which channel is connected to the sample and hold circuit. When changing channels, a delay is required before starting the next conversion. The required delay is basically the time allowed to discharge the capacitor © Unitec New Zealand

20 CONVERSION CLOCK The ADC conversion clock is the time that will be used to convert the analog voltage present on the pin to a 10-bit value in the ADRESH:ADRESL registers. It takes 11 of these conversion clock cycles to perform a complete ADC. If the conversion clock period is insufficient, an incomplete ADC result will occur. The electrical specifications for the PIC16F877a state that the conversion clock must have a period of at least 1.5 μSeconds or a frequency of approximately 667 kHz. © Unitec New Zealand

21 CONVERSION CLOCK The source of the conversion clock is software selectable via the ADCS bits of the ADCON0 AND ADCON1 register. There are seven possible clock options: FOSC/2 FOSC/4 FOSC/8 FOSC/16 FOSC/32 FOSC/64 FRC (dedicated internal oscillator) The time to complete one bit conversion is defined as TAD. One full 10-bit conversion requires 11 TAD periods © Unitec New Zealand

22 Acquisition time When an specific channel is selected the voltage from that input channel is stored in an internal holding capacitor. It takes some time for the capacitor to get fully charged and become equal to the applied voltage. This time is called acquisition time.  Once acquisition time is over the input channel is disconnected from the source and the conversion begin. The acquisition times depends on several factor like the source impedance, Vdd of the system and temperature. © Unitec New Zealand

23 INTERRUPTS The ADC module allows for the ability to generate an interrupt upon completion of an Analog-to-Digital conversion. The ADC interrupt flag is the ADIF bit in the PIR1 register. The ADC interrupt enable is the ADIE bit in the PIE1 register. The ADIF bit must be cleared in software. This interrupt can be generated while the device is operating or while in Sleep. If the device is in Sleep, the interrupt will wake-up the device. Upon waking from Sleep, the next instruction following the SLEEP instruction is always executed. If the user is attempting to wake-up from Sleep and resume in-line code execution, the global interrupt must be disabled. If the global interrupt is enabled, execution will switch to the interrupt service routine. © Unitec New Zealand

24 Result formating The 10-bit A/D conversion result can be supplied in two formats, left justified or right justified. The ADFM bit of the ADCON0 register controls the output format. © Unitec New Zealand

25 © Unitec New Zealand

26 © Unitec New Zealand

27 ADC Result register high for ADFM=0
© Unitec New Zealand

28 ADC result register high ADFM=1
© Unitec New Zealand

29 A/D CONVERSION PROCEDURE
This is an example procedure for using the ADC to perform an Analog-to-Digital conversion: 1. Configure Port: Disable pin output driver (See TRIS register) Configure pin as analog 2. Configure the ADC module: Select ADC conversion clock Configure voltage reference Select ADC input channel Select result format Turn on ADC module © Unitec New Zealand

30 3.Configure ADC interrupt (optional):
Clear ADC interrupt flag Enable ADC interrupt Enable peripheral interrupt Enable global interrupt(1) 4. Wait the required acquisition time 5. Start conversion by setting the GO/DONE bit. 6. Wait for ADC conversion to complete by one of the following: Polling the GO/DONE bit Waiting for the ADC interrupt (interrupts enabled) 7. Read ADC Result 8. Clear the ADC interrupt flag (required if interrupt is enabled). © Unitec New Zealand

31 Steps in programming the A/D converter using polling
Make the pin for the selected ADC an input channel. Select voltage reference and A/C input channel. Select the conversion clock. Wait for the required acquisition time. Turn on the ADC module . Activate the start conversion bit of Go/Done. Wait for the conversion to be completed by polling the end of conversion bit. After the GO/DONE bit has gone LOW, read the ADRESL and ADRESH register Go to step 5. © Unitec New Zealand


Download ppt "Digital to Analogue Converter"

Similar presentations


Ads by Google