Top Banner
ATmega128 Analog Interfacing
27

Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

Jul 07, 2018

Download

Documents

phungdat
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

ATmega128

Analog Interfacing

Page 2: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

Waveform Sampling and Quantization

A waveform is sampled at a constant rate – every ∆t Each such sample represents the instantaneous amplitude at

the instant of sampling “At 37 ms, the input is 1.91341914513451451234311… V” Sampling converts a continuous time signal to a discrete time

signal The sample can now be quantized (converted) into a digital value

Quantization represents a continuous (analog) value with the closest discrete (digital) value

“The sampled input voltage of 1.91341914513451451234311… V is best represented by the code 0x018, since it is in the range of 1.901 to 1.9980 V which corresponds to code 0x018.”

time

Dig

ital v

alue

Page 3: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

Sample and Hold Devices

Some A/D converters require the input analog signal to be held constant during conversion, (eg. successive approximation devices)

In other cases, peak capture or sampling at a specific point in time necessitates a sampling device.

This function is accomplished by a sample and hold device as shown to the right:

These devices are incorporated into some A/D converters

Analog InputSignal

Samplingswitch

HoldCapacitor

OutputSignal

Page 4: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

A/D Converter

Page 5: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

A/D Converter

Multi-comparator “flash” Integrating Tracking (counter-comparator) Successive approximation

Page 6: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

Multi-comparator “flash”

Page 7: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

Integrating

Page 8: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

Tracking (counter-comparator)

Page 10: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

D/A Converter

Page 11: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

D/A Converter

Page 12: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

PWM (Pulse Width Modulation)

Page 13: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

PWM (Pulse Width Modulation)

Page 14: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

ATmega128 ADC

Page 15: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

ADC Multiplexer Selection Register

Page 16: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

ADC Multiplexer Selection Register

Page 17: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

ADC Control & Status Register

Page 18: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

ADC Control & Status Register

Page 19: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

ADC Data Register

Page 20: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

ADC Differential Mode

Page 21: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

Timer PWM mode

Page 22: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

Timer PWM mode

Page 23: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

Timer PWM mode

Page 24: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

Timer PWM mode

Page 25: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

Sample Code (1)

int main(void) { MCUCR = 0x80; XMCRA = 0X40; XMCRB = 0X80; DDRD = 0xff; DDRB = 0xff; PORTD = 0xff; FunctionSet(); DisplayOnOffControl(); DisplayClear(); EntryModeSet(); ADCH = 0x00; ADCL = 0x00; ADMUX = 0x00; TCCR0 = 0x7c; /* Timer0 Fast PWM clk/64 */

Page 26: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

Sample Code (2)

while(1) { ADCSR = 0xc7; while((ADCSR & 0x10)==0); ADC_L = ADCL; ADC_H = ADCH; PORTD = ~(ADC_L << 4); OCR0=(ADC_L>>2) | (ADC_H<<6); ADC_RESULT = 0x00; ADC_RESULT = ADC_RESULT | ADC_H; ADC_RESULT = 0x0300 & (ADC_RESULT << 8); ADC_RESULT = ADC_RESULT | ADC_L;

Page 27: Analog Interfacing - Hanyangccrs.hanyang.ac.kr/webpage_limdj/microprocessor/Analog.pdf · Analog Interfacing . ... into a digital value Quantization represents a continuous (analog)

Sample Code (3)

c4 = ADC_RESULT / 1000; c3 = (ADC_RESULT % 1000) / 100; c1 = ADC_RESULT % 100; c2 = c1/10; c1 = c1 % 10; SetLCDAddress(LINE1); DisplayString((unsigned char*)"ADC:"); DisplayChar(c4+0x30); DisplayChar(c3+0x30); DisplayChar(c2+0x30); DisplayChar(c1+0x30); delay_ms(5); } }