instructor: paul gordy office: h-115 phone: 822-7175 email: [email protected]

22
Instructor: Paul Gordy Office: H-115 Phone: 822-7175 Email: [email protected] EGR 262 Fundamental Circuits Lab Presentation for Lab #7 Successive Approximation A/D Converter Lecture #7 EGR 262 – Fundamental Circuits Lab 1

Upload: naida

Post on 23-Feb-2016

74 views

Category:

Documents


0 download

DESCRIPTION

Lecture #7 EGR 262 – Fundamental Circuits Lab. 1. EGR 262 Fundamental Circuits Lab Presentation for Lab #7 Successive Approximation A/D Converter. Instructor: Paul Gordy Office: H-115 Phone: 822-7175 Email: [email protected]. Lecture #7 EGR 262 – Fundamental Circuits Lab. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Instructor:  Paul Gordy Office:  H-115 Phone:  822-7175 Email:  PGordy@tcc.edu

Instructor: Paul GordyOffice: H-115Phone: 822-7175Email: [email protected]

EGR 262Fundamental Circuits Lab

Presentation for Lab #7Successive Approximation A/D Converter

Lecture #7 EGR 262 – Fundamental Circuits Lab 1

Page 2: Instructor:  Paul Gordy Office:  H-115 Phone:  822-7175 Email:  PGordy@tcc.edu

Digital-to-Analog ConversionIn order to control analog outputs, digital outputs must first be converted to analog form using a digital-to-analog converter (also referred to as a DAC or D/A converter).

Analog-to-Digital ConversionIn order to read analog inputs, the analog inputs must first be converted to digital form using a an analog-to-digital converter (also referred to as a ADC or A/D converter).

Digital Output from A/D Converter(or Digital Input to Arduino UNO

AnalogInput

A/D Converter Arduino UNO

Digital Output from Arduino UNO(or Digital Input to D/A Converter)

AnalogOutput Arduino UNO D/A Converter

Note: Labs 4 & 6 deal with digital-to-analog conversion.

Note: Labs 7 & 8 deal with analog-to-digital conversion.

Lecture #7 EGR 262 – Fundamental Circuits Lab 2

Page 3: Instructor:  Paul Gordy Office:  H-115 Phone:  822-7175 Email:  PGordy@tcc.edu

Analog-to-Digital ConversionThere are several methods of performing analog-to-digital conversion, including:• Simultaneous A/D converter – this method uses 2N comparators and an N-bit priority

encoder to produce an N-bit output.• Stairstep-ramp A/D converter – this method uses a D/A converter and a counter. As the

binary count advances, it is converted to an analog signal and compared to the analog input.

• Tracking A/D converter – similar to the stairstep-ramp A/D converter, but uses an UP/DOWN counter so that each successive conversion starts with the last digital value and counts up or down until the new analog input value is detected.

• Single-slope A/D converter – instead of using D/A converter like the previous two methods, this method uses a linear ramp generator to produce a constant-slope reference voltage. A counter is synchronized with the slope of the ramp.

• Dual-slope A/D converter – similar to the single-slope A/D converter, but the input charges a capacitor linearly, producing a negative, variable-slope ramp. The capacitor then discharges linearly with a positive slope. A counter runs as the capacitor discharges, yielding a count proportional to the voltage. This method is commonly used with voltmeters and other test equipment.

• Successive-approximation A/D converter – this is perhaps the most widely used method and is used in this lab. It has a much shorter conversion time than most other methods and the conversion time is the same for any analog input. In the following lab we will also see that the Arduino UNO has a built-in successive-approximation ADC.

Lecture #7 EGR 262 – Fundamental Circuits Lab 3

Page 4: Instructor:  Paul Gordy Office:  H-115 Phone:  822-7175 Email:  PGordy@tcc.edu

Successive-approximation ADC The successive-approximation ADC consists of:• DAC (such as the R-2R ladder network)• Comparator• Success-approximation register (or processing using the Arduino UNO)

Operation of the successive-approximation A/D converter:• The bits of the DAC are enabled one at a time, starting with the MSB.• As each bit is enabled, the comparator produces an output that indicates

whether the analog input voltage is greater or less than the output of the DAC. If the analog input is greater than the DAC output, the comparator output is HIGH and the bit is Reset (LOW). If the analog input is less than the DAC output, the comparator output is LOW, and we will Keep the bit (HIGH).

• This process is repeated for each bit.• See the example on the following page.

Lecture #7 EGR 262 – Fundamental Circuits Lab 4

Page 5: Instructor:  Paul Gordy Office:  H-115 Phone:  822-7175 Email:  PGordy@tcc.edu

Example: 4-bit successive approximation A/D converterTrace through Steps 1-4 below:

Lecture #7 EGR 262 – Fundamental Circuits Lab 5

Note: A 4-bit DAC is used where the analog output is 0-15V for digital inputs 0000 – 1111

Step 1: • Set the MSB, so SAR output = 1000• DAC is 8V• 8V > 4.9V input, so Reset the bit to 0

Step 2: • Set the next bit, so SAR output = 0100• DAC is 4V• 4V < 4.9V input, so Keep the bit

Step 3: • Set the next bit, so SAR output = 0110• DAC is 6V• 6V > 4.9V input, so Reset the bit to 0

Step 4: • Set the next bit, so SAR output = 0101• DAC is 5V• 5V < 4.9V input, so Keep the bit

Note: The SAR makes the decision when to Reset or Keep a bit. In this lab we will write a program for the Arduino UNO to replace the SAR.

Result: Analog input 4.9 V was converted to digital output 0101

4.9V

4.9V

4.9V

4.9V

Page 6: Instructor:  Paul Gordy Office:  H-115 Phone:  822-7175 Email:  PGordy@tcc.edu

Generic 4-bit successive- approximation ADC

3-bit successive-approximation ADC using the Arduino UNONotes:1) The SAR (successive-approximation

register) is replaced by the Arduino UNO.

2) A comparator is added to compare the output of the DAC to the analog input (output will be 5V if the input is greater than the DAC output and 0V if not).

3) The Arduino UNO will read the output of the comparator to decide which bits to Reset or Keep as in the previous example.

Lecture #7 EGR 262 – Fundamental Circuits Lab 6

ArduinoUNO

+_

ComparatorDAC(R-2R ladder

network)

AnalogInput(0-5V)

Digital Output(0 – 7 or 000 to 111)

4.9V

Page 7: Instructor:  Paul Gordy Office:  H-115 Phone:  822-7175 Email:  PGordy@tcc.edu

Lecture #7 EGR 262 – Fundamental Circuits Lab 7

Detailed ADC Schematic

ArduinoUNO

D2D3D4D5D6D7D8

D13

D12

D11

220

a

b

cde

f g

a bcdefg

+5V

D9

D10 DAC Output4.4k

4.4k

4.4k

2.2k

2.2k

4.4k

Digital Output(0 – 7, or 000 – 111 in binary)

+_

AnalogInput(0-5V)

10k

+5V

+5V

Comparator

Page 8: Instructor:  Paul Gordy Office:  H-115 Phone:  822-7175 Email:  PGordy@tcc.edu

Operational AmplifiersOperational amplifiers (or op amps) were covered in detail in EGR 271, but a few points are reviewed here. Refer to Chapter 5 in Electric Circuits, 9th Edition, by Nilsson for additional information.

Closed-loop versus open loop Closed-loop configuration• Includes nearly all op amp examples in EGR 271• A feedback resistor is used• Most common configuration with many applications• ACL, closed-loop gain, is often calculated and is typically small (|ACL| <10)Open-loop configuration• No feedback resistor is used• AOL, open-loop gain, is huge. Typical value: 100,000 (manufacturer spec)• Op amp output is typically equal to one of the supply voltages (saturated)• Key application: comparators or related circuits

Lecture #7 EGR 262 – Fundamental Circuits Lab 8

Page 9: Instructor:  Paul Gordy Office:  H-115 Phone:  822-7175 Email:  PGordy@tcc.edu

Closed-loop configuration:• Most commonly used• Feedback resistor used• Closed-loop gain, ACL, used

Lecture #7 EGR 262 – Fundamental Circuits Lab 9

Other components

Vo

+

_

Vin

Rfeedback

+

_

Open-loop configuration:• Rarely used, but is useful for

comparators• No feedback resistor used• Open-loop gain, AOL, used (typical

value: AOL = 100,000)

in

oCL

CL

VV A

gain loop-closed A

(typical) 100,000 A

gain loop-open V

V A

V - V V

OL

oOL

-

Vo

+

_

V +

_VDC1

VDC2

Page 10: Instructor:  Paul Gordy Office:  H-115 Phone:  822-7175 Email:  PGordy@tcc.edu

Example (closed-loop configuration)Determine an expression for Vo for the inverting amplifier shown below.Also find the closed-loop gain, ACL.

Lecture #7 EGR 262 – Fundamental Circuits Lab 10

Vo

+

_

Vin = 2V

40 k

10 k

+_

4- 2V8V-

VV A

8V- 2V 10k40k- V

RR- V

:Solution

in

oCL

in1

Fo

Page 11: Instructor:  Paul Gordy Office:  H-115 Phone:  822-7175 Email:  PGordy@tcc.edu

Comparator An op amp in the open-loop configuration can be easily used to determine which is the larger of two inputs. Such a circuit is called a comparator.To illustrate how a comparator works, suppose that V+ is slightly larger than V-:

Lecture #7 EGR 262 – Fundamental Circuits Lab 11

Vo

+

_

V +

_+12V

-12V

2.499 V

2.500 V saturated) is amp op (the 12V V so tagesupply vol positive theexceedcannot Vbut

V, 100 mV)(100000)(1 VA VmV 1 V 0.001 2.499 - 2.500 V - V V

o

o

OLo

-

Vo

+

_V

+

_+12V

-12V

2.501 V

2.500 V saturated) is amp op (the 12V V sotagesupply vol negative than theless becannot Vbut

V, 100- 1mV)(100000)(- VA VmV 1- V 0.001- 2.501 - 2.500 V - V V

o

o

OLo

-

Now suppose that V+ is slightly less than V-:

So the comparator indicates which input is larger:

-

-

o V V if 12VV V if 12V

V

Page 12: Instructor:  Paul Gordy Office:  H-115 Phone:  822-7175 Email:  PGordy@tcc.edu

Comparator - continuedFor digital circuits, it is useful to use 0V and 5V for the supply voltages as shown below:

Lecture #7 EGR 262 – Fundamental Circuits Lab 12

-

-

o V V if V0V V if V5

VVo

+

_V-

5V

0V

V+

Pinout for the LMC660:

We will use the LMC 660 op amp in lab. Recall that the successive-approximation ADC compares the DAC output with the analog input.

Input Analog Output DAC if V0Input Analog Output DAC if V5

Vo

Vo

+

_Analog Input

5V

0V

DAC Output

Page 13: Instructor:  Paul Gordy Office:  H-115 Phone:  822-7175 Email:  PGordy@tcc.edu

Connecting a potentiometer as a voltage divider (review)

R1

R2

+_Vsource +

_

21

2source2 R R

RV V

R1

R2

Vsource

21

2source2 R R

RV V

Rotate knob on potentiometer to adjust

Analog Input from 0V to 5V 5V

Analog Input

Lecture #7 EGR 262 – Fundamental Circuits Lab 13

Page 14: Instructor:  Paul Gordy Office:  H-115 Phone:  822-7175 Email:  PGordy@tcc.edu

Using a potentiometer to adjust the Analog InputWe will use a potentiometer to simulate an Analog Input (to be converted to a digital

value) as shown below.

Lecture #7 EGR 262 – Fundamental Circuits Lab 14

10 k pot

5V _

+

AnalogInput

DAC Output5V

0V

LMC660

Analog Input varies from 0V to 5V as the potentiometer is adjusted

Input Analog Output DAC if V0Input Analog Output DAC if V5

Vo

Page 15: Instructor:  Paul Gordy Office:  H-115 Phone:  822-7175 Email:  PGordy@tcc.edu

Lecture #7 EGR 262 – Fundamental Circuits Lab 15

ArduinoUNO

D2D3D4D5D6D7D8

D13

D12

D11

220

a

b

cde

f g

a bcdefg

+5V

D10 DAC Output4.4k

4.4k

4.4k

2.2k

2.2k

4.4k

Digital Output(0 – 7, or 000 – 111 in binary)

+_

AnalogInput(0-5V)

10k

+5V

+5V

Comparator

Detailed ADC Schematic

Page 16: Instructor:  Paul Gordy Office:  H-115 Phone:  822-7175 Email:  PGordy@tcc.edu

Writing a program to complete the ADCThe design for the ADC will be completed by adding software that will make a series of guesses in order to determine the binary value that represents the analog input.

Guessing Game Consider the following game. The instructor will pick a number from 0 to 100. You try to guess the number as quickly as possible.Strategy: Each time guess as closely as possible to the midpoint of the remaining range after each guess.

Example: Let’s try it (instructor writes a number on the board behind the screen).

Guess Larger or smaller?

Lecture #7 EGR 262 – Fundamental Circuits Lab 16

Page 17: Instructor:  Paul Gordy Office:  H-115 Phone:  822-7175 Email:  PGordy@tcc.edu

Now let’s modify the game to use binary values. We can guess an N-bit number using N guesses. For example, a 4-bit number can be guessed using 4 guesses.

Example: Try using the flowchart for:Value = 3

Flowchart – Guessing Game with Binary Values

Lecture #7 EGR 262 – Fundamental Circuits Lab 17

Upper = 2N

Lower = 0

Guess > Value?

Lower = Guess

for I = 1 to N

Upper = Guess

Read Value

Display Guess

T

F

Guess = (Upper + Lower)/2

Guess = (Upper + Lower)/2

Page 18: Instructor:  Paul Gordy Office:  H-115 Phone:  822-7175 Email:  PGordy@tcc.edu

Binary Search The guessing game is an example of a binary search. A/D converters based on a binary search are called successive approximation A/D converters.

We begin by assuming that some input analog voltage is applied and we would like to convert it to a digital value. For our 3-bit A/D converter, we will assume that the input is between 0V and 5V and we wish to convert it to a binary value as shown below (using the table from the last lab):

Analog Input (V)

Binary Value

Decimal Value

0.000 – 0.625 000 00.625 – 1.250 001 11.250 – 1.875 010 21.875 – 2.500 011 32.500 – 3.125 100 43.125 – 3.750 101 53.750 – 4.375 110 64.375 – 5.000 111 7

Lecture #7 EGR 262 – Fundamental Circuits Lab 18

Page 19: Instructor:  Paul Gordy Office:  H-115 Phone:  822-7175 Email:  PGordy@tcc.edu

Example:Trace through the ADC schematic for an analog input of 3.5V. Add binary values and voltages to the schematic.

Lecture #7 EGR 262 – Fundamental Circuits Lab 19

ArduinoUNO

D2D3D4D5D6D7D8

D13

D12

D11

220

a

b

cde

f g

a bcdefg

+5V

D10 DAC Output4.4k

4.4k

4.4k

2.2k

2.2k

4.4k

Digital Output(0 – 7, or 000 – 111 in binary)

+_

AnalogInput(0-5V)

10k

+5V

+5V

Comparator

I Upper Lower Guess DAC Output

Test

1 8 0 4 2.5V 2.5 > 3.5?(False)

2 8 4 6 3.75V 3.75 > 3.5?(True)

3 6 4 5 3.125 3.125 > 3.5?(False)

Result: 3.5V converted to 5 = 101

Page 20: Instructor:  Paul Gordy Office:  H-115 Phone:  822-7175 Email:  PGordy@tcc.edu

Example:Trace through the ADC schematic for an analog input of 0.8V. . Add binary values and voltages to the schematic.

Lecture #7 EGR 262 – Fundamental Circuits Lab 20

ArduinoUNO

D2D3D4D5D6D7D8

D13

D12

D11

220

a

b

cde

f g

a bcdefg

+5V

D10 DAC Output4.4k

4.4k

4.4k

2.2k

2.2k

4.4k

Digital Output(0 – 7, or 000 – 111 in binary)

+_

AnalogInput(0-5V)

10k

+5V

+5V

Comparator

I Upper Lower Guess DAC Output

Test

Result: 0.8V converted to ________

Page 21: Instructor:  Paul Gordy Office:  H-115 Phone:  822-7175 Email:  PGordy@tcc.edu

Pre-lab Task: Write a C++ program for the Arduino UNO to use a binary search to implement a successive-approximation ADC where:• The 3-bit binary guess will be output to an R-2R ladder network using the

function R2R( ) from Lab 4.• The value of the binary guess will be displayed on a 7-segment display using

the function display_digit( ) from Labs 3-4.• No buttons are required, so the functions for debouncing button inputs are not

needed.• An outline of the program might look as follows (see next slide):

Lecture #7 EGR 262 – Fundamental Circuits Lab 21

Page 22: Instructor:  Paul Gordy Office:  H-115 Phone:  822-7175 Email:  PGordy@tcc.edu

Lecture #7 EGR 262 – Fundamental Circuits Lab 22

void setup( ) { // Define input and output pins } void loop( ) { // Assign initial values to upper, lower and N // guess = (upper + lower)/2 // for i = 1 to N

{ // Call R2R( ) to send guess to output pins // Read comparatorInput on D10 if(comparatorInput == 1) // guess > analog input upper = guess else lower = guess

// guess = (upper + lower)/2 } // display guess on 7-segment display} void display_digit(int N) { // Use code from Lab #3 (do not make any changes)} void R2R(int N) { // Use code from Lab #4