Analog-to-Digital Conversion (Part 2) Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

Similar documents
The 9S12 A/D converter Huang Section ATD_10B8C Block User Guide

The Successive Approximation Converter Concept - 8 Bit, 5 Volt Example

Analog Input & Output

nc... Freescale Semiconductor, I

Introduction to Mechatronics. Fall Instructor: Professor Charles Ume. Analog to Digital Converter

Analog to Digital Conversion

Introduction to Embedded Microcomputer Systems Lecture Discrete digital signal. Continuous analog signal

Interfacing Analog to Digital Data Converters. A/D D/A Converter 1

Point System (for instructor and TA use only)

Decade Counters Mod-5 counter: Decade Counter:

Dual Slope ADC Design from Power, Speed and Area Perspectives

Analog-to-Digital Converter

Experiment # 4 Counters and Logic Analyzer

Hello and welcome to this presentation of the STM32L4 Analog-to-Digital Converter block. It will cover the main features of this block, which is used

Tutorial Introduction

Converters: Analogue to Digital

successive approximation register (SAR) Q digital estimate

Laboratory 9 Digital Circuits: Flip Flops, One-Shot, Shift Register, Ripple Counter

Scans and encodes up to a 64-key keyboard. DB 1 DB 2 DB 3 DB 4 DB 5 DB 6 DB 7 V SS. display information.

Notes on Digital Circuits

SDA 3302 Family. GHz PLL with I 2 C Bus and Four Chip Addresses

Chapter 11 Sections 1 3 Dr. Iyad Jafar

ADC0804C, ADC BIT ANALOG-TO-DIGITAL CONVERTERS WITH DIFFERENTIAL INPUTS

Implementing a Rudimentary Oscilloscope

WINTER 14 EXAMINATION

EECS 373 Design of Microprocessor-Based Systems

Data Conversion and Lab (17.368) Fall Lecture Outline

Sources of Error in Time Interval Measurements

PHYSICS 5620 LAB 9 Basic Digital Circuits and Flip-Flops

DIGITAL ELECTRONICS MCQs

MBI5152 Application Note

Flip-flops, like logic gates are defined by their truth table. Flip-flops are controlled by an external clock pulse. C

16 Stage Bi-Directional LED Sequencer

Section bit Analog-to-Digital Converter (ADC)

Digital Clock. Perry Andrews. A Project By. Based on the PIC16F84A Micro controller. Revision C

Simple PICTIC Commands

SPI Serial Communication and Nokia 5110 LCD Screen

ELECTRICAL ENGINEERING DEPARTMENT California Polytechnic State University

S op o e p C on o t n rol o s L arni n n i g n g O bj b e j ctiv i e v s

WINTER 15 EXAMINATION Model Answer

A MISSILE INSTRUMENTATION ENCODER

VikiLABS. a g. c dp. Working with 7-segment displays. 1 Single digit displays. July 14, 2017

Logic Gates, Timers, Flip-Flops & Counters. Subhasish Chandra Assistant Professor Department of Physics Institute of Forensic Science, Nagpur

PESIT Bangalore South Campus

LCD Triplex Drive with COP820CJ

Hello and welcome to this training module for the STM32L4 Liquid Crystal Display (LCD) controller. This controller can be used in a wide range of

ECE 2274 Pre-Lab for Experiment Timer Chip

Experiment 13 Sampling and reconstruction

B. Sc. III Semester (Electronics) - ( ) Digital Electronics-II) BE-301 MODEL ANSWER (AS-2791)

TXZ Family. Reference Manual 12-bit Analog to Digital Converter (ADC-A) 32-bit RISC Microcontroller. Revision

FRQM-2 Frequency Counter & RF Multimeter

Digital (5hz to 500 Khz) Frequency-Meter

Microcontrollers and Interfacing week 7 exercises

Tutorial on Technical and Performance Benefits of AD719x Family

Notes on Digital Circuits

Chapter 29 Analog Digital Converter (ADC)

Fig. 1 Analog pins of Arduino Mega

A/D and D/A convertor 0(4) 24 ma DC, 16 bits

MSCI 222C Class Readings Schedule. MSCI 222C - Electronics 11/27/18. Copyright 2018 C.P.Rubenstein Class Seating Chart Mondays

MSCI 222C Fall 2018 Introduction to Electronics

DALHOUSIE UNIVERSITY Department of Electrical & Computer Engineering Digital Circuits - ECED 220. Experiment 4 - Latches and Flip-Flops

PCI-DAS6034, PCI-DAS6035, and PCI-DAS6036

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous)

35058-TE. PLJ-6LED-A LED Frequency Display Module Manual

DIGITAL ELECTRONICS: LOGIC AND CLOCKS

Today 3/8/11 Lecture 8 Sequential Logic, Clocks, and Displays

SWITCH: Microcontroller Touch-switch Design & Test (Part 2)

ADC Peripheral in Microcontrollers. Petr Cesak, Jan Fischer, Jaroslav Roztocil

CPE 310L EMBEDDED SYSTEM DESIGN (CPE)

EXPERIMENT #6 DIGITAL BASICS

A High-Resolution Flash Time-to-Digital Converter Taking Into Account Process Variability. Nikolaos Minas David Kinniment Keith Heron Gordon Russell

DT9857E. Key Features: Dynamic Signal Analyzer for Sound and Vibration Analysis Expandable to 64 Channels

Hello, and welcome to this presentation of the STM32 system window watchdog. It will cover the main features of this peripheral used to detect

DE2-115/FGPA README. 1. Running the DE2-115 for basic operation. 2. The code/project files. Project Files

Vorne Industries. 87/719 Analog Input Module User's Manual Industrial Drive Itasca, IL (630) Telefax (630)

SignalTap Plus System Analyzer

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) WINTER 2018 EXAMINATION MODEL ANSWER

Converting between Analog and Digital Domains

Reaction Game Kit MitchElectronics 2019

Synthesis Technology E102 Quad Temporal Shifter User Guide Version 1.0. Dec

Copyright 2011 by Enoch Hwang, Ph.D. and Global Specialties. All rights reserved. Printed in Taiwan.

Midterm Exam 15 points total. March 28, 2011

TV Synchronism Generation with PIC Microcontroller

Rensselaer Polytechnic Institute Computer Hardware Design ECSE Report. Lab Three Xilinx Richards Controller and Logic Analyzer Laboratory

Training Note TR-06RD. Schedules. Schedule types

7inch Resistive Touch LCD User Manual

Design and Implementation of Timer, GPIO, and 7-segment Peripherals

Specifications for Thermopilearrays HTPA8x8, HTPA16x16 and HTPA32x31 Rev.6: Fg

NI-DAQmx Device Considerations

Laboratory Exercise 4

o The 9S12 has a 16-bit free-running counter to determine the time and event happens, and to make an event happen at a particular time

VIRTUAL INSTRUMENTATION

V6118 EM MICROELECTRONIC - MARIN SA. 2, 4 and 8 Mutiplex LCD Driver

For Teacher's Use Only Q Total No. Marks. Q No Q No Q No

MBI5050 Application Note

o The 9S12 has a 16-bit free-running counter to determine the time and event happens, and to make an event happen at a particular time

Come and join us at WebLyceum

INTERNATIONAL JOURNAL OF PURE AND APPLIED RESEARCH IN ENGINEERING AND TECHNOLOGY

DIGITAL CIRCUIT COMBINATORIAL LOGIC

Triple RTD. On-board Digital Signal Processor. Linearization RTDs 20 Hz averaged outputs 16-bit precision comparator function.

Transcription:

Analog-to-Digital Conversion (Part 2)

Charge redistribution network Instead of a resistor ladder for the D/A converter, the microcontroller uses an-all capacitor system to generate the known voltages It is like a capacitor ladder, instead of a resistor ladder An advantage is that it allows the unknown voltage to be sampled and held, while the comparisons are taking place Recall basic formulas for capacitors: + + V C V C C 2 - - Q = CV Q = C V + C 2 V 2

Sample and hold Sample mode comparator Total charge is Q s = 6 V x assume V L = Hold mode Q h = ( V i )6 = -6 V i = Q s by charge conservation -6 V i = 6 V x so V i = -V x 3

Conversion Now, let s switch the largest capacitor up to V H The total charge on the capacitors is still the same Q = 8(V H V i ) + 8( V i ) = 8 V H 6 V i = 6 V x (charge conservation) so V i = (8/6)V H - V x The comparator compares V i against V L = ; if V i < it outputs a Or, it outputs a if V x > (/2) V H 4

Conversion (continued) Let s say that the unknown voltage is V x > (/2) V H Next step is to switch the next largest capacitor up to V H Q = (8+4)(V H V i ) + 4( V i ) = 2 V H 6 V i = 6 V x (charge conservation) so V i = (2/6)V H - V x The comparator compares V i against V L = ; if V i < it outputs a Or, it outputs a if V x > (3/4) V H 5

Conversion (continued) Each step switches the next largest capacitor up to V H The output of the comparator determines if the capacitor remains at V H or is returned to V L Continue for a total of n steps (for n bit conversion) Example 3 rd step V i =? Example 4 th step V i =? 6

Successive approximation method Analog switches are transistors To get resistance as low as possible, the voltage on the gates must be high To get a high voltage (7 to 8V), a charge pump is used That s why you only turn on the A/D converter if you need it 7

Output code Quantization error Statistically, a quantization error of ±½ is better than - error To offset by ½ bit, a fixed capacitor of value ½ is used 2 n - V DD /2 n V DD Voltage Figure 2.3 Output characteristic of an ideal n-bit A/D converter 8

8 bit A/D To avoid needing a wide range of capacitor values, the ladder is split into two, with a small capacitor in series 9

HCS2 A/D Converter The HCS2 uses a successive approximation A/D converter, with either 8 or bit resolution The highest frequency of the conversion clock is 2 MHz (period is.5 microseconds) A/D conversion time is the sum of the converter time and the sample time At 2 MHz ATD clock frequency, an 8-bit conversion takes 8 clock steps, or 4 microseconds The sample time takes two clock steps (to charge the sample capacitor) and an additional 2, 4, 8, or 6 cycles (to store the charge in the storage node) Table 2.8 ATD conversion timings ATD clock frequency resolution converter time 2+2 sample clocks 2+4 sample clocks 2+8 sample clocks 2+6 sample clocks 2 MHz 2 MHz 5 KHz 5 KHz 8-bit () -bit (2) 8-bit -bit 4 s 5 s 6 s 2 s 2 s 3 s 8 s 2 s 5 s 9 s 2 s 36 s Note.. The fastest 8-bit resolution conversion time is 4 s + 2 s = 6 s. 2. The fastest -bit resolution conversion time is 5 s + 2 s = 7 s.

HCS2 A/D Converter You can generate an interrupt when conversion is done, or just poll a flag You can select from among 8 analog inputs Conversion is started by writing a value to a control register The conversion result can be right-justified unsigned, left-justified signed, and left-justified unsigned

An HCS2 can have two A/D converters Our chip (the C version) has only one VRH, VRL (reference high and reference low) usually tied to Vcc and gnd VDDA, VSSA are power supply inputs for the A/D (tie to Vcc and gnd) From the MC9S2C Family Reference Manual 2

Bus clock Clock prescaler ATD clock Results are always stored in order, in the result registers starting with ATD (ATDDR) Confusing: the result from say, input AN2 doesn t necessarily go into result register ATD 2 Conversion complete interrupt V RH V RL VDDA VSSA AN7/PAD7 AN6/PAD6 AN5/PAD5 AN4/PAD4 AN3/PAD3 AN2/PAD2 AN/PAD AN/PAD Analog MUX Mode and timing control Successive apparoximation Register (SAR) and DAC results ATD ATD ATD 2 ATD 3 ATD 4 ATD 5 ATD 6 ATD 7 sample and hold ATD input enable register Port AD data register + - comparator Figure 2.8 The HCS2 ATD block diagram 3

Channel Selection CC, CB, and CA (ATDCTL5) select channel (storing starts conversion) MULT bit: =single input, =multiple inputs SCAN bit: =scan continuously, =do once As each conversion completes and is stored into a result register, the corresponding CCF bit in ATDSTAT is set When all conversions complete, the SCF bit in ATDSTAT is set 4

Multiple Inputs 5

A/D registers Each A/D module has the following registers: Four control registers: ATDxCTL2 - ATDxCTL5 Two status registers: ATDxSTAT and ATDxSTAT Two testing registers: ATDxTEST and ATDxTEST One input enable register: ATDxDIEN One port data register: PTADx Eight 6-bit result registers ATDxDR~ATDxDR7 where x = or In our chip (the C version) we only have one module, so the x is not needed 6

A/D Control Registers ATDCTL2 ADPU power up ATD system AFFC fast flag clear reset: 7 6 5 4 3 2 ADPU AFFC AWAI ETRIGLE ETRIGP ETRIGE ASCIE ASCIF ADPU: ATD power down bit = power down ATD = normal ATD operation AFFC: ATD fast flag clear all bit = ATD flag is cleared normally, i.e., read the status register before reading the result register = any access to a result register will cause the associated CCF flag to clear automatically if it is set at the time AWAI: ATD power down in wait mode bit = ATD continues to run when the HCS2 is in wait mode = halt conversion and power down ATD during wait mode ETRIGLE: External trigger level/edge control This bit controls the sensitivity of the external trigger signal. Details are shown in Table 2.. ETRIGP: External trigger polarity This bit controls the polarity of the external trigger signal. See Table 2. for details. ETRIGE: External trigger mode enable = disable external trigger on ATD channel 7 = enable external trigger on ATD channel 7 ASCIE: ATD sequence complete interrupt enable bit = disables ATD interrupt = enables ATD interrupt on sequence complete (ASCIF = ) ASCIF: ATD sequence complete interrupt flag = no ATD interrupt occurred = ATD sequence complete interrupt pending Figure.9 ATD control register 2 (ATDxCTL2, x = or ) 7

A/D Control Registers ATDCTL3 (S8C..SC): successive conversions are placed into successive result registers Examples: conversion: result always goes into ATDDR 4 conversions: successive results go into ATDDR..ATDDR3 reset: 7 6 5 4 3 2 S8C S4C S2C SC FIFO FRZ FRZ S8C,S4C,S2C,SC: Conversion sequence limit = 8 conversions = conversion = 2 conversions = 3 conversions = 4 conversions = 5 conversions = 6 conversions = 7 conversions xxx = 8 conversions FIFO: Result register FIFO mode = conversion results are placed in the corresponding result register up to the selected sequence length = conversion results are placed in consecutive result registers (wrap around at end) FRZ and FRZ: background debug (freeze) enable bit : continue conversions in active background mode : reserved : finish current conversion, then freeze : freeze immediately when background mode is active Figure. ATD control register 3 (ATDxCTL3, x = or ) 8

A/D Control Registers ATDCTL4 PRS3:PRS: The maximum clock is 2 MHz So if we have a 24 MHz E clk, should set this to 5 (24 MHz/6 = 2 MHz) SMP:SMP determine sample time The sample time is 2 clock periods, but you can add time for more accuracy reset: 7 6 5 4 3 2 SRES8 SMP SMP PRS4 PRS3 PRS2 PRS PRS SRES8: ATD resolution select bit = -bit operation = 8-bit operation SMP and SMP: select sample time bits These bits are used to select the length of the second phase of the sample time in units of ATD conversion clock cycles. See Table 2.2. PRS4--PRS: ATD clock prescaler bits These five bits are the binary value prescaler value PRS. The ATD conversion clock frequency is calculated as follows: ATDclock = [bus clock] PRS + The ATD conversion frequency must be between 5KHz and 2 MHz. The clock prescaler values are shown in Table 2.3. Figure 2. ATD control register 4 (ATDxCTL4, x = or ) Table 2.2 Sample time select.5 SMP SMP Length of 2nd phase of sample time 2 A/D conversion clock periods 4 A/D conversion clock periods 8 A/D conversion clock periods 6 A/D conversion clock periods 9

A/D Control Registers ATDCTL5 Set SCAN= to do continuous conversions Set MULT= to convert only one input CC,CB,CA selects input Table 2.4 Analog input channel select code reset: 7 6 5 4 3 2 DJM DSGN SCAN MULT CC CB CA DJM: Result register data justification = left justified data in the result registers = right justified data in the result registers DSGN: Result register data signed or unsigned representation = unsigned data representation in the result registers = signed data representation in the result registers (not available in right justification) SCAN: Enable continuous channel scan bit = single conversion sequence = continuous conversion sequences (scan mode) MULT: Enable multichannel conversion bit = sample only one channel = sample across several channels CC, CB, and CA: Channel select code The channel selection is shown in Table 2.4. Figure 2.2 ATD control register 5 (ATDxCTL5, x = or ) CC CB CA analog input channel AN AN AN2 AN3 AN4 AN5 AN6 AN7 2

A/D Status Registers ATDSTAT SCF: Use to check when sequence is complete CC2:CC: indicates the number of the result register that will hold the result reset: 7 6 5 4 3 2 SCF ETORF FIFOR CC2 CC CC SCF: Sequence complete flag = conversion sequence not completed = conversion sequence has completed ETORF: External trigger overrun flag = no external trigger overrun has occurred = external trigger overrun has occurred FIFOR: FIFO overrun flag = no overrun has occurred = an overrun has occurred CC2, CC, CC: conversion counter The conversion counter points to the result register that will receive the result of the current conversion. In non-fifo mode, this counter is reset to at the begin and end of the conversion. In FIFO mode, this counter is not reset and will wrap around when its maximum value is reached. Figure 2.3 ATD status register (ATDxSTAT, x = or ) 2

A/D Status Registers ATDSTAT Conversion complete flags for all channels You can poll this to find out when conversion is done If fast flag clear is selected, the flag is cleared by reading the result register reset: 7 6 5 4 3 2 CCF7 CCF6 CCF5 CCF4 CCF3 CCF2 CCF CCF CCFx: conversion complete flag x (x = 7~) = conversion number x not completed = conversion number x has completed, result in ATDyDRx Figure 2.5 ATD status register (ATDxSTAT, x = or ) 22

Summary of A/D Registers Red - used for initialization Green - for interrupt configuration Black = for channel selection and making measurements Results go into ATDDR..ATDDR7 Register 7 6 5 4 3 2 ATDCTL2 ADPU AFFC AWAI ETRIGLE ETRIGP ETRIGE ASCIE ASCIF ATDCTL3 S8C S4C S2C SC FIFO FRZ FRZ ATDCTL4 SRES8 SMP SMP PRS4 PRS3 PRS2 PRS PRS ATDCTL5 DJM DSGN SCAN MULT CC CB CA ATDSTAT SCF ETORF FIFOR CC2 CC CC ATDSTAT CCF7 CCF6 CCF5 CCF4 CCF3 CCF2 CCF CCF 23

Initialization ADPU bit enables the ATD module (is disabled by default to conserve power) Takes microseconds for the ATD to become operating after setting the ADPU Example: Set up A/D to digitize continuously on channel 2 ATDCTL2 = xc; // turn on ATD and enable fast flag clear ATDCTL3 = x8; // set the ATD for channel conversion ATDCTL4 = x85; // set the ATD for 2 MHz,2 sample clks,8 bits ATDCTL5 = xa2; // right justified, continuous conversions of AD2 /* A/D results appear in ATDDRL */ 24

Example Set up A/D to convert and average 4 successive voltage readings on channel 3, using bits ATDCTL2 = xc; // turn on ATD and enable fast flag clear : //wait microseconds to power up ATDCTL3 = x2; ATDCTL4 = x5; // set the ATD for 4 conversions // set the ATD for 2 MHz,2 sample clks, bits // Start the conversion ATDCTL5 = x83; // right justified, single conversion of AD3 while (!(ATDSTAT & x8)) ; // wait for SCF = // Read and average the four measurements result = (ATDDR + ATDDR + ATDDR2 + ATDDR3)/4; 25

A to D Converter Types Successive Approximation Tracking A/D Converter Dual-slope A/D Converter Parallel (flash) A/D Converter Two-stage parallel A/D Converter 26

Tracking A/D Converter Very fast digitization as long as signal changes slowly 27

Dual-Slope A/D Converter Integrate input voltage for a fixed time T Then discharge it, and time how long it takes to reach zero Can be very accurate where speed isn t a concern (e.g., a multimeter) If you have periodic noise (e.g., 6Hz), can cancel it by making T equal to the period 28

Flash A/D Converter Very fast, but expensive 29

Summary / Questions The HCS2 uses a successive approximation A/D converter. A charge redistribution network (composed of capacitors) is used to generate known voltages. Why does a -bit conversion take longer than an 8- bit conversion? 3