A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog...

28
A/D and D/A

Transcript of A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog...

Page 1: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

A/D and D/A

Page 2: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

OverviewOverview

• Introductiono Definitions

o Op amps -- a quick review

• Digital-to-analog conversions

• Analog-to-digital conversions

• Reading: Text, Section 8.8, Chapter 12

Page 3: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

Introduction to Analog I/OIntroduction to Analog I/O

• Physical phenomena typically involve analog signals (values taken from the continuous domain)o Examples include temperature, speed, position, pressure,

voltage, altitude, . . .• Microprocessors work with digital quantities (values taken from

the discrete domain)• To interact with analog signals, operate on continuous physical

values, conversion between analog and digital values is needed• For a digital system to interact with analog systems, conversion

between analog and digital values is needed• Building blocks to perform the conversions are:

o Digital to analog converters (DACs)o Analog to digital converters (ADCs)

Cont..

Page 4: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

Introduction to Analog I/OIntroduction to Analog I/O

Cont..

Page 5: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

Introduction to Analog I/OIntroduction to Analog I/O

• Transducers convert energy from one form to another (E.g., convert mechanical motion to a voltage waveform)o Sensors

Potentiometer (position)Strain gauge, piezoelectric device (force)Thermistor, thermocouple (temperature)Photoconductive cell, phototransistor (light)Current transformer, SENSEFET (current)Microphone (sound)

o ActuatorsSolenoids, relays, speakersDarlington transistors, Triacs, SCRs, Thyristors

Cont..

Page 6: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

Introduction to Analog I/OIntroduction to Analog I/O

• Transducers convert energy from one form to another (E.g., convert mechanical motion to a voltage waveform)o Sensors

Potentiometer (position)Strain gauge, piezoelectric device (force)Thermistor, thermocouple (temperature)Photoconductive cell, phototransistor (light)Current transformer, SENSEFET (current)Microphone (sound)

o ActuatorsSolenoids, relays, speakersDarlington transistors, Triacs, SCRs, Thyristors

Cont..

Page 7: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

Introduction to Analog I/OIntroduction to Analog I/O

• Signal conditioningo Most transducers (especially sensors) output low-level signals

Usually less than 1V, may be millivolts or microvoltso Signals are often noisyo For these reasons, we usually need to apply adjust

(“condition”) a signal before A/D conversionAmplificationFilteringLinearization

• Operational amplifiers (op amps)o Useful in the design of DACs and ADCs because of their

performance characteristics

Cont..

Page 8: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

Introduction to Analog I/OIntroduction to Analog I/O

Open loop gain of several hundred thousand

Input current approximately 0, output impedance approximately zero

• Fig. 12.2 Op amp circuits

Cont..

Page 9: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

Introduction to Analog I/OIntroduction to Analog I/O

• Definitions (for analog electrical signals)o Offset: minimum valueo Span: maximum value – minimum value

Some common spans:range of 0 V to 5 V: span = 5 Vrange of –12 V to 12 V: span = 24 Vrange of 4 mA to 20 mA: span = 16 mA

• Definitions (for ADCs and DACs)o Typically, the digital representation is an unsigned n-bit

integero Resolution: span / 2n

(also known as the step size)(this is the weight of the LSB)

Cont..

Page 10: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

Introduction to Analog I/OIntroduction to Analog I/O

(sometimes resolution is simply given as n)

o Example:

Analog signal in range +5 to -5 volts, 8-bit ADC:Offset = – 5 VSpan = 10 VStep size = 10 / 256 = 39.1 mVNotice that the MSB has a weight of 5 V (=span/2), and the LSB has a weight of .0391 V

Page 11: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

Digital to Analog ConversionDigital to Analog Conversion

• A DAC takes an n-bit digital input and output a corresponding analog voltage

• DAC systems normally consist of three components:o A reference voltageo The DAC itselfo An op amp for output buffering

• Ideal DAC would convert an n-bit code Bn-1 ... Bn-1 B1 B0 to output voltage as shown below:o Vout= Span ( Bn-1 2-1 + Bn-2 2-2 + ... B0 2-n ) + Offseto Vout will be a fractional value of the "full scale" voltage

(span-offset)Maximum is the digital value of 111111…111 (all 1s)

Cont..

Page 12: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

Digital to Analog ConversionDigital to Analog Conversion

• DAC system relationship (Sho87)

Cont..

Page 13: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

Digital to Analog ConversionDigital to Analog Conversion

• Weighted resistor DACs

o Use an op amp and a current divider network to implement the conversion function

Cont..

Page 14: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

Digital to Analog ConversionDigital to Analog Conversion

• Interfacing DAC to microprocessor systemo In principle, any DAC can be interfaced to any microprocessor

systemo In practice, some combinations of DACs and microprocessors

are easier than others and require much simpler hardware and software in the interface

o Interfacing an 8-bit DAC to an 8-bit microprocessor is easy: Write to port connected to DAC and signal DAC to begin

o When DAC word > uP word, some problems can exist How do we interface a 12-bit DAC to an 8-bit I/O bus

without having glitches in the analog output? Must use a double buffering scheme, as described in the

text but best illustrated from [Sho87]

Cont..

Page 15: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

Digital to Analog ConversionDigital to Analog Conversion

• Double buffering example of DAC interface [Sho87]

Cont..

Page 16: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

Digital to Analog ConversionDigital to Analog Conversion

• D/A with the 68HC11o No on-board D/A

o Must use an external converter Ex. DAC0808

• 8-bit D/A

• Connect to a parallel I/O port

• See example circuit on CEL web pages

Page 17: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

Analog to Digital ConversionAnalog to Digital Conversion

• The function of ADCs is to quantize the analog voltage and then output the corresponding digital code value

• As with the DAC conversion, a full-scale analog voltage will be divided into 2n quantization levels or steps for an n-bit digital coding scheme

• Slow approach -- counting conversion

• Counting converter [Sho87]

Cont..

Page 18: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

Analog to Digital ConversionAnalog to Digital Conversion

• Successive approximation is a much faster method

• Figure 12.6 Successive approximation ADC

Page 19: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

The Analog to Digital subsystem in The Analog to Digital subsystem in the 68HC11the 68HC11

• The ADC system in the 68HC11 uses a variation of the successive approximation convertero DAC is replaced by a series of capacitors that are charged to

the voltages that correspond to the weights of each bit Much like a capacitive ladder network

o Capacitors are charged during a sample period then held during the approximation phase

o Each capacitor starting with the one that corresponds to the MSB is switched in turn into the SAR circuit for the comparison process

Cont..

Page 20: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

The Analog to Digital subsystem in The Analog to Digital subsystem in the 68HC11the 68HC11

• Capacitor ladder network for A/D conversions [HC11]

Cont..

Page 21: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

The Analog to Digital subsystem in The Analog to Digital subsystem in the 68HC11the 68HC11

• 68HC11 A/Do Supports 8 input ADC channelso Channels are located on port E

Channel 0 on PE0 -- not available on EVBU due to use of jumper J2!

Channel 1 on PE1, etc.o In performing A/D conversions, 4 conversions are performed

as a "block," each taking 32 cycles -- 128 cycles totalo Control registers:

OPTION ($1039)• ADPU and CSEL bits

ADCTL ($1030)• Control and status information

Cont..

Page 22: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

The Analog to Digital subsystem in The Analog to Digital subsystem in the 68HC11the 68HC11

ADR1 - ADR4 ($1031 - $1034)• Result registers

• To enable A/D operations on the HC11o Enable the capacitor charging operations

The system charge pump must be enabled at reset by setting the A/D power up bit (ADPU) in the system OPTION register

This is used to charge the capacitors for the successive-approximation circuit

Disabled by default to conserve power After enabling charge pump, the MCU should wait at least

100 usec before initiating A/D conversion (This allows capacitor voltages to stabilize)

Cont..

Page 23: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

The Analog to Digital subsystem in The Analog to Digital subsystem in the 68HC11the 68HC11

• To enable A/D operations on the HC11o Select clock for successive-approximation register (SAR)

circuitry A/D can use the E clock or an internal RC circuit

• Use E clock if it is greater than 750 KHz (it is for the EVBU!)

CSEL bit in OPTION register selects clock source (0 = E clock, 1 = RC circuit)

o Must also apply high and low reference voltages (VRH and VRL) to the chip that fixes span and offset -- 3 volt span is recommended minimum (VDD and VSS hardwired to the reference inputs on the EVBU)

Cont..

Page 24: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

The Analog to Digital subsystem in The Analog to Digital subsystem in the 68HC11the 68HC11

• Single vs. continuous conversiono Single conversion

HC11 performs one set of conversions and stops• Remember that one set is actually 4 conversions

To select this, set the SCAN bit in ADCTL to 0 Writing to ADCTL initiates conversion

• Also clears the CCF bit When conversion is complete, CCF bit is set

• No interrupt, so you must poll• Read data from ADR1-ADR4

To start another conversion, you must write to ADCTL again

Cont..

Page 25: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

The Analog to Digital subsystem in The Analog to Digital subsystem in the 68HC11the 68HC11

o Continuous conversion Set SCAN bit to 1 Writing to ADCTL initiates conversion

• Also clears CCF CCF set after first block of 4 conversions is complete ADR1 - ADR4 continue to be updated

• Round-robin fashion

• Each register will be updated every 128 cycles (32 cycles for each conversion)

o When you read a register, value may be up to 128 cycles old

Cont..

Page 26: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

The Analog to Digital subsystem in The Analog to Digital subsystem in the 68HC11the 68HC11

• Single channel vs. multiple channelo Single channel

Channel is sampled 4 consecutive times and the resulting 4 conversions are placed into ADR1-4

• Each conversion takes 32 clock cycles Set MULT bit to 0 in ADCTL register Use CC, CB, and CA bits in ADCTL to select the channel

to be converted• Always set CD to 0 (CD=1 is used for factory testing)

Can use this with single or continuous conversion• Allows you to sample a single input every 32 cycles

(62,500 samples per second with 2MHz E-clock)

Cont..

Page 27: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

The Analog to Digital subsystem in The Analog to Digital subsystem in the 68HC11the 68HC11

o Multiple channels Conversions for 4 channels will be performed Set the MULT bit in ADCTL to 1 Use bit CC of the ADCTL to specify which group of 4

channels is to be converted

• CC = 0 -- inputs 0-3 in ADR1-4

• CC = 1 -- inputs 4-7 in ADR1-4

• CD should always be 0, CB and CA are don’t cares Can use this with single or continuous conversion

• Each input is sampled every 128 clock cycles (15,625 samples per second)

Page 28: A/D and D/A. Overview Introduction oDefinitions oOp amps -- a quick review Digital-to-analog conversions Analog-to-digital conversions Reading: Text,

SummarySummary

o Transducerso Signal conditioningo D/A conversion Must use external converter for HC11o A/D conversion HC11 has built-in A/D converter• Uses port E• Can convert 8 channels• Operation:

Enable charge pump, select clock source during initializationSelect single or continuous conversion, single or multiple channelsInitiate conversion by writing to ADCTLWait for CCF flag to indicate conversion is completeRead results