Download presentation

Presentation is loading. Please wait.

Published byMicah Collinge Modified over 2 years ago

1
EET 2261 Unit 14 INCOMPLETE Analog-to-Digital Conversion (ADC) & Digital-to-Analog Conversion (DAC) Read. Homework #13 and Lab #13 due next week. Quiz next week.

2
Most physical quantities (temperature, pressure, light intensity, etc.) are analog quantities. Transducers are devices that convert one of these physical quantities to an analog voltage or current. Example, a temperature sensor might produce a voltage in mV that is proportional to the temperature in degrees Fahrenheit. Analog Quantities

3
Before a microprocessor can work on analog information, we must first use an analog-to- digital converter (ADC) to transform the analog values into digital binary values. Conversely, we use a digital-to-analog converter (DAC) to transform digital values from the microprocessor into analog values that can be used to control analog devices. See Chapter 12 of Floyd’s Digital Electronics for details on ADCs and DACs. Interfacing to the Analog World

4
A Typical Application Transducer Physical variable ADCDAC Actuator Micro- processor Control physical variable............ Analog input (voltage or current) Digital inputs Digital outputs Analog output (voltage or current)

5
The ADC periodically samples the analog signal, and converts each sampled value of the analog signal into a binary code. The more bits that are used in this code, the more accurate is the representation of the original signal. The following slides (from Floyd’s Chapter 12) show an example of how using 2 bits results in much less accuracy than using 4 bits. Number of Bits and Accuracy

6
Copyright ©2009 by Pearson Higher Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Digital Fundamentals, Tenth Edition Thomas L. Floyd Figure 12.8 Light gray = original waveform. Blue = Reconstructed waveform using four quantization levels (2 bits).

7
Copyright ©2009 by Pearson Higher Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Digital Fundamentals, Tenth Edition Thomas L. Floyd Figure 12.10 Light gray = original waveform. Blue = Reconstructed waveform using sixteen quantization levels (4 bits).

8
Several common ways of specifying an ADC’s resolution: Number of bits, n Number of output codes, = 2 n, or number of steps in the output, = 2 n − 1 Percentage resolution, = 1 / (2 n − 1), expressed as a percentage Step size, = V ref / 2 n Resolution

9
Resolution: Examples Formula4-bit ADC10-bit ADC Number of bits n 4 Number of output codes 2n2n 16 Number of steps in the output 2 n −1 15 Percentage resolution 1 / (2 n −1) 6.67% Step size (assuming 5 V reference voltage) V ref / 2 n 312.5 mV

10
Many analog-to-digital converter chips are available. Example: the ADC0804 is a popular 8-bit ADC chip.ADC0804 Our PIC chip has a built-in 10-bit ADC. ADC Hardware

11
Seven of the PIC chip’s pins (labeled AN0 through AN7) can be configured as analog inputs to the chip’s internal ADC. The PIC Chip’s Analog Inputs

12
How do we tell the PIC chip whether we want to use these pins as analog inputs or as digital I/O? Example: How do we tell it whether we want pin 8 to act as AN5 or as bit 0 of PORT E? Configuring the Analog Inputs

13
On the LAB-X1 board, three of these pins (AN0, AN1, AN3) are permanently connected to the wipers on three potentiometers. Analog Inputs on the LAB-X1

14
ADCIN command PAUSEUS command / operator // operator New PICBASIC Commands & Operators in Lab #4

15
Tells the PIC chip to perform an analog-to- digital conversion using its built-in A/D converter, and then saves the result of this conversion. Example: ADCIN 0 result performs an A/D conversion on the voltage present at analog input 0, and stores the result in the variable named result. Don’t confuse the ADCIN command with ADCON0 and ADCON1, which are special function registers on the PIC chip. ADCIN (p. 45 in PICBASIC manual)

16
Recall that the PAUSE command inserts a time delay into your program. This delay is measured in milliseconds. Example: PAUSE 500 causes a 500 ms delay. The PAUSEUS command is very similar, but the delay is measured in microseconds instead of milliseconds. Example: PAUSEUS 500 causes a 500 s delay. PAUSEUS (p. 113 in PICBASIC manual)

17
Recall the difference between integers (such as 2 or 47 or 365) and floating-point numbers (such as 3.14 or 1.5 or 16.97). PICBASIC can only deal with integers, not floating-point numbers. All math operations give integer results. This requires us to play some tricks if we need to work with floating-point numbers. Integer Math

18
We know that 7÷2 = 3.5 Recall that another way to say this is that 7÷2 = 3 with a remainder of 1. In this example, 3 is called the quotient and 1 is called the remainder. Another example: If you take 20÷8, what is the quotient and what is the remainder? Quotient and Remainder

19
The / operator returns the quotient part of a division. Example: 7 / 2 in a PICBASIC program will return a result of 3. / Operator (p. 35 in PICBASIC manual)

20
The // operator returns the remainder part of a division (sometimes called the modulus). Example: 7 // 2 in a PICBASIC program will return a result of 1. By using both / and //, we can keep track of both the quotient and the remainder part of a division. // Operator (p. 35 in PICBASIC manual)

21
Look at program called A-D Conversion3.pbp Recall that for a 10-bit A/D conversion using a reference voltage of 5 V, the step voltage is about 4.9 mV. So to find the voltage (in mV) corresponding to an A/D result, we need to multiply by 4.9. But since PICBASIC can only handle integers, it can’t handle 4.9. So instead, we multiply by 49 and then divide by 10. Integer Math in Lab #4

22
Now that we have the voltage in mV, we want to print it on the LCD in V. Example: if the voltage = 2141 mV, then we want to print 2.141 V. To get the part before the decimal point, take 2141 / 1000. (This returns an answer of 2.) To get the part after the decimal point, take 2141 // 1000. (This returns an answer of 141.) Then print those two answers, separated by a decimal point: 2.141. Integer Math in Lab #4 (Continued)

23
For another use of these integer math tricks, see these documents in the “Documents PIC” folder on the R: shared drive: “Convert Celsius to Fahrenheit using Integer Math.docx” “Convert Fahrenheit to Celsius using Integer Math.docx” Another Application

Similar presentations

OK

Figure 2–1 Illustration of a simple binary counting application. Thomas L. Floyd Digital Fundamentals, 9e Copyright ©2006 by Pearson Education, Inc. Upper.

Figure 2–1 Illustration of a simple binary counting application. Thomas L. Floyd Digital Fundamentals, 9e Copyright ©2006 by Pearson Education, Inc. Upper.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on types of research methods and designs Ppt on ministry of corporate affairs notification Ppt on evolution of life Ppt on different types of houses for kids Ppt on limits and continuity problems Ppt on beach tourism in india Ppt on computer languages types S tv do ppt online Ppt on sbi home loan Ppt on grease lubrication symbol