63
Analog

Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Embed Size (px)

Citation preview

Page 1: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

An

alo

g

Page 2: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Real Time Embedded Systems

www.atomicrhubarb.com/embeddedLecture 1 – January 17, 2012

Topic

Page 3: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Section Topic

• Where in the books– Catsoulis chapter/page– Simon chapter/page– Zilog UM197 (ZNEO Z16F Series Flash Microcontroller Contest Kit User Manual)

– Zilog UM171 (ZiLOG Developer Studio II—ZNEO User Manual)

– Zilog PS220 (ZNEO Z16F Series Product Specification)

– Zilog UM188 (ZNEO CPU Core User Manual)

– Assorted datasheets

Page 4: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of
Page 5: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Signals

Analog

DigitalReferencevoltage

Page 6: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Digital-Analog Connecting a sensor to digital circuitry is

simple if the sensor provides digital output.

We have seen that switches, and logic encoders are easily interfaced with gate circuits due to the nature of their signals.

When analog sensors are involved the interfacing becomes more complex.

We need a way to electronically translate analog signals into digital quantities, and visa-versa.

Page 7: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Analog Signals

How do we input and output analog signals?

Page 8: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Signal Converters

Analog to Digital signal converter on the inputs

Digital to Analog signal converter on the outputs

Page 9: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Digital -> Analog

A Digital to Analog converter is an electronic circuit which accepts a digital number at its input and produces a corresponding analog signal (usually a voltage) at the output

Page 10: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Digital -> Analog

DAC Several Types

PWM output + low pass filter Binary Weighted DAC R2R Ladder Kelvin Divider

Page 11: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

DAC

Kelvin Divider

Page 12: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

DAC

R-2R ladder network is a simple Digital-Analog converter.

Only two resistance values are used anywhere in the entire circuit.

Modern DACs use the ‘R-2R ladder’

Page 13: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

But ...

We don't have a Digital to Analog converter on the ZNEO (or any of the Zilog microcontrollers).

Page 14: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Fortunately we know how to add that capability if we need

it Add a DAC chip I2C, SPI, 1-wire, … Or parallel digital input 1000's to choose from (really!)

Page 15: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Like this one!

Page 16: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of
Page 17: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Analog -> Digital

An Analog to Digital converter is an electronic circuit which accepts an analog input signal (usually a voltage) and produces a corresponding digital number at the output

Page 18: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

ADC

Analog-to-Digital Conversion The workhorse of the test and

measurement world. Providing a means for a micro-

controller to measure analog signals.

Page 19: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

ADC Several Types (ways to convert analog

to digital) Digital Ramp Successive Approximation Subranging Tracking Slope Integration Flash Sigma Delta

Page 20: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Flash ADC

Start with a voltage comparator Determines of a signal is greater than a

reference signal (a 1-bit analog to digital converter).

Vref

Vin

VoutVref

Vin

Vout

+

Page 21: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Flash ADC

n-bit resolutionrequires2n-1 comparators

8-bit means255 comparators

10-bit means1023 comparators

Page 22: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Digital Ramp A binary counter counts up

from 0. The output of the counter to feed into a digital to analog converter.

The generated analog signal is compared to the input signal.

When the generated signal is greater than the input signal the counter stops and the binary value is the digital value for this signal

Page 23: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Sigma Delta ADC

High resolution and Low cost The Z16 uses Sigma-Delta ADC One of the more advanced ADC

technologies

Page 24: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Why so many different ways?

Page 25: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Resolution vs Speed

Page 26: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

ADC Signal Sampling

Sampling can cause errors (aliasing)

Nyquist rate = 2x highest frequency of interest

Practically: always sample at least 5x, or higher

Page 27: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

What kinds of things can you measure with an ADC?

Page 28: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Sensors

Sensors with analog output Temperature Pressure Light intensity Position Velocity, RPM ...

Page 29: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Analog Input

Don't like the ADC on your microcontroller?

Add an external one. Many to choose from Parallel data out I2C, SPI, 1-wire, ....

Page 30: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

MAX19588

100 Million samples per second 16 bit

Page 31: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of
Page 32: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

MAX1072 1.8 Million samples per second 10-bit data 1 micro amp in shutdown

Page 33: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of
Page 34: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Why so many different ADC?

Page 35: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Why

Speed (samples/second) Low Power for battery/portable

applications Resolution (8,10,12,14,18 bits) Number of channels Interface Range of analog input (3v, 12v, +/- 12v,

...)

Page 36: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Z16 ADC

One ADC 12 Switched inputs 10-bit resolution Internal voltage reference generator Ability to supply external reference

voltage.

Page 37: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Z16 ADC

Page 38: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

The Pins

ANA0..11 AVDD, AVSS VREF

Page 39: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

ADC

10 bit conversion (needs 2 bytes for result)

12 analog input sources are multiplexed with general-purpose I/O ports

Interrupt upon conversion complete Internal voltage reference generator

Page 40: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

ADC

• Each ADC measurement consists of three phases:

1. Input sampling (programmable, minimum of 1.0 μs).

2. Sample-and-hold amplifier settling (programmable, minimum of 0.5 μs).

3. Conversion is 12 ADCLK cycles.

Page 41: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of
Page 42: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Z16 ADC Registers

ADC0CTL – Control Register ADC0DH, ADC0DL – ADC data ADCSST – Sample Settling Time ADCST – Sample Time ADCCP – Clock Prescaler ADC0MAX – Max Chanel Register ADCTCAP_H,L – Timer0 Capture

Register

Page 43: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Z16 ADC Registers

Don't forget GPIO alternate functionand interrupt control registers

Page 44: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

ADC0CTL

Page 45: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of
Page 46: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

ADC0D_H,L

Page 47: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Interrupt?

Why do I want to generate an interrupt on conversion?

Page 48: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Single ShotADC

Single ADC

1. Enable the alternate function of the GPIO pins that you want to use for analog inputs (PORT B & H)2. Write to ADC0CTL to configure which input source (one

source can be active at a time)3. Set ADCCTL START0 to enable conversion.4. Watch STAT0 bit until conversion is complete. 5. Read value from ADC0D_H, ADC0D_L

Page 49: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Example Example

Analog_Photodiode

Page 50: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Photodiode

Like a diode (allows current to flow in one direction and not the reverse)

BUT, light changes that and allows current to flow in the reverse direction also.

Dark = little current flow More light = more current flow

Page 51: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

5v_| Photo| diode LED 100+---|<----+--->|--------/\/\/\----+

| || v GND+--> ANA0

LED for visualindicator

Page 52: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Photodiodeis blocked, LED not on

Photodiodeis blocked, LED not on

Page 53: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Photodiodeis illuminated, LED is on

Photodiodeis illuminated, LED is on

Page 54: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

Why would we want an External Reference Voltage?

Page 55: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of
Page 56: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of
Page 57: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

External Reference

This circuit gives us access to supply our own reference voltage (on J7) or

Use a MAX6160 voltage reference (and potentiometer) to provide a variable VREF

Page 58: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of
Page 59: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of
Page 60: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of
Page 61: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of
Page 62: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of
Page 63: Analog - Atomic Rhubarb Analog.pdf · When analog sensors are involved the interfacing becomes more complex. ... We don't have a Digital to Analog converter on the ZNEO (or any of

VREF

Internal VREF=3.3v 3FF 10 bits 3.3v 0FF 8 bits 0.82v 00F 4 bits 0.05v 001 1 bit

0.003v

With external VREF=1v 3FF 10 bits 1.0v 0FF 8 bits 0.25v 00F 4 bits 0.0156v 001 1 bit 0.001v