Analog to Digital Conversion

Similar documents
Lecture 7: Analog Signals and Conversion

9. Data Acquisition. Chapter 9

ME 461 Laboratory #3 Analog-to-Digital Conversion

ECE2049: Embedded Computing in Engineering Design C Term Spring Lecture #14: Using the ADC12 Analog-to-Digital Converter

16.1 ADC ADC ADC10

MSP430 Teaching Materials

Copyright 2015 by Stephen A. Zajac & Gregory M. Wierzba. All rights reserved..spring 2015.

Lecture 5 ECEN 4517/5517

Lab 5 Timer Module PWM ReadMeFirst

The University of Texas at Arlington Lecture 10 ADC and DAC

CHAPTER ELEVEN - Interfacing With the Analog World

Embedded Control. Week 3 (7/13/11)

Linear Integrated Circuits

ME 333 Assignment 7 and 8 PI Control of LED/Phototransistor Pair. Overview

IV B.Tech. I Sem (R13) ECE : Embedded Systems : UNIT -3 1 UNIT 3

ME 461 Laboratory #2 Timers and Pulse-Width Modulation

P a g e 1. Introduction

Analog I/O. ECE 153B Sensor & Peripheral Interface Design Winter 2016

Lab 10. Speed Control of a D.C. motor

Measuring Distance Using Sound

EEE3410 Microcontroller Applications Department of Electrical Engineering. Lecture 10. Analogue Interfacing. Vocational Training Council, Hong Kong.

Working with ADCs, OAs and the MSP430

MICROPROCESSORS A (17.383) Fall Lecture Outline

MSP430 Interfacing Programs

DASL 120 Introduction to Microcontrollers

ADC Resolution: Myth and Reality

Real Time Embedded Systems. Lecture 1 January 17, 2012

MARMARA UNIVERSITY CSE315 DIGITAL DESIGN LABORATORY MANUAL. EXPERIMENT 7: Analog-to-Digital Conversion. Research Assistant Müzeyyen KARAMANOĞLU

ME 461 Laboratory #5 Characterization and Control of PMDC Motors

EEE312: Electrical measurement & instrumentation

Page 1/10 Digilent Analog Discovery (DAD) Tutorial 6-Aug-15. Figure 2: DAD pin configuration

ECE 511: FINAL PROJECT REPORT GROUP 7 MSP430 TANK

Analog-to-Digital Converter (ADC) And Digital-to-Analog Converter (DAC)

ANALOG TO DIGITAL (ADC) and DIGITAL TO ANALOG CONVERTERS (DAC)

Iowa State University Electrical and Computer Engineering. E E 452. Electric Machines and Power Electronic Drives

Using Z8 Encore! XP MCU for RMS Calculation

MICROCONTROLLER TUTORIAL II TIMERS

Test Results of the HTADC12 12 Bit Analog to Digital Converter at 250 O C

UNIVERSITY OF VICTORIA FACULTY OF ENGINEERING. SENG 466 Software for Embedded and Mechatronic Systems. Project 1 Report. May 25, 2006.

Project Final Report: Directional Remote Control

Lab Exercise 6: Digital/Analog conversion

Exercise 3: Sound volume robot

QUICK START GUIDE FOR DEMONSTRATION CIRCUIT BIT DIFFERENTIAL INPUT DELTA SIGMA ADC LTC DESCRIPTION

EE 308 Spring S12 SUBSYSTEMS: PULSE WIDTH MODULATION, A/D CONVERTER, AND SYNCHRONOUS SERIAN INTERFACE

Enhancing Analog Signal Generation by Digital Channel Using Pulse-Width Modulation

Energy Efficient and High Performance Current-Mode Neural Network Circuit using Memristors and Digitally Assisted Analog CMOS Neurons

THE PERFORMANCE TEST OF THE AD CONVERTERS EMBEDDED ON SOME MICROCONTROLLERS

Microcontroller: Timers, ADC

Data Conversion and Lab Lab 4 Fall Digital to Analog Conversions

Data Converters. Lecture Fall2013 Page 1

E84 Lab 3: Transistor

CHAPTER 4 CONTROL ALGORITHM FOR PROPOSED H-BRIDGE MULTILEVEL INVERTER

Improving Loop-Gain Performance In Digital Power Supplies With Latest- Generation DSCs

Getting Precise with MSP430 Sigma-Delta ADC Peripherals Vincent Chan MSP430 Business Development Manager TI Asia

Exercise 5: PWM and Control Theory

Bend Sensor Technology Electronic Interface Design Guide

Generating DTMF Tones Using Z8 Encore! MCU

Electronics Design Laboratory Lecture #9. ECEN 2270 Electronics Design Laboratory

Analog-to-Digital Conversion

CSE 3215 Embedded Systems Laboratory Lab 5 Digital Control System

Experiment P48: Transistor Lab 1 The NPN Transistor as a Digital Switch (Power Amplifier, Voltage Sensor)

Activity P55: Transistor Lab 1 The NPN Transistor as a Digital Switch (Power Output, Voltage Sensor)

SOLAR PATIO UMBRELLA

EE283 Electrical Measurement Laboratory Laboratory Exercise #7: Digital Counter

8-Bit A/D Converter AD673 REV. A FUNCTIONAL BLOCK DIAGRAM

Data Conversion Circuits & Modulation Techniques. Subhasish Chandra Assistant Professor Department of Physics Institute of Forensic Science, Nagpur

Module 3. Embedded Systems I/O. Version 2 EE IIT, Kharagpur 1

University of Texas at El Paso Electrical and Computer Engineering Department

B.E. SEMESTER III (ELECTRICAL) SUBJECT CODE: X30902 Subject Name: Analog & Digital Electronics

UNISONIC TECHNOLOGIES CO., LTD M1008 Preliminary CMOS IC

DSP Project. Reminder: Project proposal is due Friday, October 19, 2012 by 5pm in my office (Small 239).

EE320L Electronics I. Laboratory. Laboratory Exercise #2. Basic Op-Amp Circuits. Angsuman Roy. Department of Electrical and Computer Engineering

Timer A (0 and 1) and PWM EE3376

Analyzing A/D and D/A converters

Experiment 15: Diode Lab Part 1

The PmodIA is an impedance analyzer built around the Analog Devices AD bit Impedance Converter Network Analyzer.

ANALOG TO DIGITAL CONVERTER ANALOG INPUT

PIC ADC to PWM and Mosfet Low-Side Driver

Course Introduction. Content 20 pages 3 questions. Learning Time 30 minutes

AN3137 Application note

Gentec-EO USA. T-RAD-USB Users Manual. T-Rad-USB Operating Instructions /15/2010 Page 1 of 24

Data Logger Subsystems Mark Buccini February 2012

Embedded Test System. Design and Implementation of Digital to Analog Converter. TEAM BIG HERO 3 John Sopczynski Karim Shik-Khahil Yanzhe Zhao

Module: Arduino as Signal Generator

AE Agricultural Customer Services Play-by-Play Tekscope Manual

PreLab 6 PWM Design for H-bridge Driver (due Oct 23)

EECS 373 Design of Microprocessor-Based Systems

Input Drive Circuitry for SAR ADCs. Section 8

EE445L Spring 2018 Final EID: Page 1 of 7

ES /2 DMM. Features. General Description. Absolute Maximum Ratings

MAX1002/MAX1003 Evaluation Kits

DC - 20 GHz Programmable 1,2,4,8 Binary Prescaler

Complete 14-Bit CCD/CIS Signal Processor AD9822

Module 5. DC to AC Converters. Version 2 EE IIT, Kharagpur 1

EE 3305 Lab I Revised July 18, 2003

Real Analog - Circuits 1 Chapter 11: Lab Projects

ESE 350 Microcontroller Laboratory Lab 5: Sensor-Actuator Lab

Low Power Design of Successive Approximation Registers

Using Magnetic Sensors for Absolute Position Detection and Feedback. Kevin Claycomb University of Evansville

Module 9C: The Voltage Comparator (Application: PWM Control via a Reference Voltage)

Transcription:

Analog to Digital Conversion The MSP in the name of our microcontroller MSP430G2554 is abbreviation for Mixed Signal Processor. This means that our microcontroller can be used to handle both analog and digital signals. The analog signal is interfaced with the microcontroller via simple comparators or more complicated analog to digital converters (ADCs). In this lab we are going to introduce to you the ADC module, its design parameters and how to implement analog to digital conversion. Overview Analog to digital converters, as the name implies, are used to convert continuous analog signals to digital values. The transfer function of the ADC is shown in the figure below and also in its equation form. The analog input with a range between Vr- and Vr+ Volts appears on the horizontal axis while the output appears on the vertical axis. The thin line represents the transfer function that would give us an analog output that is proportional to the analog input while the bold stepped line is the transfer function of the actual ADC which would give us a digital output signal. As you can see on the horizontal axis, the input signal is divided into a number of small divisions and each division is represented by a discrete number. The number of divisions is given by the number of bits of the ADC. For example in the diagram we assumed a 10 bit ADC which means the digital output is ranging from 0 to 2 10-1 = 1023. And the small horizontal division is therefore: (Vr+ - Vr-) /2 10 V. If the input analog signal drops below Vr- the output will be 0, similarly if the analog signal is above Vr+ then the output will be 1023.

... ADC Result NADC (Digital) 1023 1022 1 0 Vr- Vr+ Signal Input Vin (Analog) Fig 1. Ideal ADC transfer function NADC: Digital representation of sampled analog signal 1023: 2^(10)-1. This number defines the resolution of ADC VIN: Input signal voltage level VR- and VR+: Lower reference and Upper reference. These two values determine the range of input value that can be converted. How Successive Approximation ADC Works There are different workings of ADCs. The ADC we are using is called Successive Approximation (Register) ADC or SAR for short. A short hand block diagram is as shown below.

DAC = Digital-to-Analog converter EOC = end of conversion SAR = successive approximation register S/H = sample and hold circuit V in = input voltage V ref = reference voltage Fig2. SAR Block Diagram Briefly speaking, the ADC start with the MSB of SAR initialized to 1 and other bits cleared to 0. The DAC convert the SAR value to analog signal, therefore at this time the DAC output should be Vref/2. The input signal is sampled and hold and then compare with the DAC output through a comparator. If the DAC output exceed the sampled input voltage, the MSB will be reset; otherwise the MSB remains as 1. Then the second MSB is set and compared with the sample. The above procedure is repeated until all the bits are determined. After that, the result is saved in a specified register and the next sample is taken in. Mathematical expression for this procedure is: Let Vin = xvref, so x in [-1, 1] is the normalized input voltage. The objective is to approximately digitize x to an accuracy of 1/2 n. 1. Initial approximation x0 = 0. 2. ith approximation xi = xi-1 - s(xi-1 - x)/2 i. where, s(x) is the signum-function(sgn(x)) (+1 for x 0, -1 for x < 0). It follows using mathematical induction that xn - x 1/2 n.

Design Considerations To choose an ADC and its parameters for your design, here are some basic parameters you need to consider: 1. Input Range Input range is the range of analog input your ADC can handle. In most cases we would like to maximize the use of this range to give us finer representation of our analog input by manually setup our upper and lower reference. For example, if you know your signal is in range of 1.5 to 3V, using a reference of 0 to 3.5V will waste a lot of your ADC resolution. The references can be selected from either internal voltage references or from an external supply depending on the mixed signal microcontroller you are using. 2. Signal to Noise Ratio (SNR) Signal to noise ratio is a measure of the percentage actual signal with the noise imposed on the signal. When selecting your ADC, you do not just go for the highest resolution. For example if you have an analog signal which goes from 0 to 3V and a 10 bit ADC then a distinct digital output will be given when your analog signal differs by (3-0)/1024 = 3mV. Think about the case that you have noise super imposed on your signal that in average is 30mV. Then your output values differ by 10 may simply come from noise but not the signal you are converting. Necessary conditioning circuitry is needed to reduce noise level or improve your SNR. 3. Timing Constrains 4. Non ideal ADC There is a limit on how fast you can sample your analog input and convert to digital signal. In the case of SAR, this timing constraint is dependent on the ADC circuitry s time constant. We will give a detailed example in the next section when discussing the ADC module in G2553. Ideally ADC will behave as shown in Fig 1. Real world ADCs can deviates from this ideal behavior. For example, you may have an offset error that the best fit line of your transfer function missing the lower reference. These non ideal parameters can be found in the device specific data sheet. We are not going to cover this in detail, but we recommend reading the text book s section 9.2.1. as a supplement.

MSP430G2553 ADC Module ADC10 The ADC Module of MSP430G2553 is called ADC10. It is a 10 bit SAR ADC which supports 8 external input channels and 4 internal channels. There are 4 different internal voltage levels that can be used for ADC reference selects: Vss = 0V (ground), 1.5V, 2.5V and Vcc. You can supply external references as well. The block diagram, grouped by functionality can be seen in Fig 3. Here we provide a basic summary for setting up an ADC. Make sure ENC bit is 0 when you modify ADC setups. 1) Input Select (ADC10CTL1, ADC10AE0) a. Decide which channel or channels of input do you want b. Set the pin as analog input pin by setting INCHx bit in ADC10CTL1 and enable corresponding bits in ADC10AE0 register. c. ADC10AE0 register will configure the pin to be analog port and overwrites pin select (PxSEL) and pin direction (PxDIR) d. Select conversion mode via CONSEQx bit in ADC10CTL1. You can choose from: single-channel-single-conversion, sequence-of-channels, repeatsingle-channel and repeat-sequence-of channels. In this lab we will be using repeat-single-chanel. 2) Reference Setup (ADC10CTL0) a. Based on your signal, choose what upper and lower reference you want for your ADC. b. This is done by using SREFx bits in ADC10CTL0: c. If you select to use internal reference, make sure you turn the reference on by setting REFON bits. d. REFBURST can be set to turn off reference buffer when not in use e. You can also output your ADC references via REFOUT bit.

Reference Setup ADC Clock S/H Setup Input Select Output Handling

3) ADC Clock (ADC10CTL1) a. ADC Clock times the sample and hold and conversion of ADC. b. It can be selected from the internal oscillator (ADC10OSC, around 5MHz), ACLK, MCLK or SMCLK. c. Clock select is done via ADC10SSELx and ADC10DIVx bits in ADC10CTL1 register 4) Sample and Hold Interval (ADC10CTL0, ADC10CTL1) a. At what interval you want to sample and covert your signal (SAMPCON) b. Timing of sample and hold interval can be done via Timer outputs (TA0, TA1) or by software (ADC10SC). This gives you SHI (Sample and Hold Interval). c. SAMPCON is set when it sees a rising edge of SHI. d. SAMPCON needs to be on for long enough time for sampling. SAMPCON should be ON for 0.622 μs if you use a signal generator and 30.2 μs if you are using the temperature sensor. e. This is found via the following equation: For our microcontroller we use: In the case of signal generator, Rs = 50 Ω. After plugging in the value we find tsample > 0.422 μs Therefore, SAMPCON needs to be high for at least 0.622μs = 0.2μs + 0.422μs for sampling to take place properly. Here 0.2μs is the time period of the ADC10CLK which is connected to ADC10OSC in the experiments of this lab. ADC10OSC is running at 5 MHz, 1/(5 MHz) = 0.2μs.

f. SAMPCON time period is gotten by multiplying ADC10CLK period by the ADC10SHTx multiplier. g. Normally the sampling time is set by the SHI time period. However we can set the ADC to sample as soon as it it done with the previous sampe and conversion by setting the MSC bit. 5) Output Handling (ADC10MEM, ADC10CTL1, ADC10DTC0 and 1, ADC10SA) a. The result of conversion is stored in ADC10MEM b. The result of ADC can be stored in either straight binary format or 2s compliment format by setting ADC10DF bit in ADC10CTL1 c. (Optional) Set up the ADC10IE interrupt if needed. After all the setup has been put in place, remember to turn on the ADC (ADC10ON). To start conversion there has to be a raising edge on the SHI signal, this can be accomplished by toggling ENC from zero to one after the ADC has been turned enable conversion by setting. In single conversion mode (single-channel-single-conversion and repeated-single-channel-mode), ENC need to be toggled (in an ISR) every time if you want the next conversion. Experiment 1 Repeat Single Channel Mode, Individually Triggered In Experiment 1 we are going to apply analog to digital conversion on a 500Hz sine wave (originating from a signal generator) which varies between 0 to 3.5V, and store two periods of this sine wave into an array of 50 words. First select your input port. Let us use Pin 2 or GPIO P1.0 (ADC s A0 channel) select INCH_0 enable BIT0 of ADC10AE0 for analog port In order to accomplish this conversion we need to setup ADC reference Vr- = 0 and Vr+ = Vcc. use SREF_0 to select Vr+ = Vcc, Vr- = Vss Use internal oscillator for ADC clock.

use ADC10SSEL_0 to select ADC10OSC as clock source ADC10OSC is around 5MHz. tsample > 0.422μs if we use a signal generator with a source resistance of 50 ohm. By default ADC10SHTx is set to 00 which corresponds to sample and hold time of 4 times the ADC10CLK period = 4/5 μs = 0.8μs > 0.422μs. Therefore timing constraint for sampling is satisfied. Set conversion mode to be in Repeat Single Channel mode. use CONSEQ_2 to select repeated single channel mode The sample should be triggered on Timer A0 output. We want 25 samples per sine wave period. use SHS_2 to source SHI from TA0 Set Timer A0 clock to SMCLK at 1MHz in up mode. Set TA0 output in toggle mode which gives a period of TTA0OUT = 2 x TACCR0 x TTACLK at Tiner A0 output. TTA0OUT = 2 x TACCR0 x TTACLK > TADC10CLK + tsample + 13TADC10CLK = 0.20μs +.422μs + 13(0.20μs) = 3.2μs To have 25 samples per period, TA0 output period should be (our signal period)/25 = 80 μs2 x TACCR0 x TTACLK = 80 μs > 3.2μs, therefore timing constraint is satisfied. This gives: TACCR0 = 40 Set ADC10 interrupt: set ADC10IE Now check if all the settings and Enable ADC10 by setting ADC10ON Set ENC bit to enable conversion Enable Global Interrupts.

Inside the interrupt service routine read the sampled value of the signal from the register ADC10MEM and store the sample result in an array of length 50 samples. Increase your array index, when the array index reaches 50 set the array index to 0 and start saving in the array memory from the beginning again. Set a break point at the line where you reset the index to 0. Observe the digitized array stored in the memory when your program reaches this break point. Plot the array in CCS and include a screenshot in your lab report. Experiment 2 Temperature Sensor There is an on-chip temperature sensor in the G2553. The temperature sensor is connected to an input channel of the ADC by selecting INCH_10. select INCH_10 for ADC input When you select the temperature sensor channel, the on-chip reference for the temperature sensor automatically turns on and gives you a Vref+ = 1.5V. Use this Vref+ and Vref- = 0 as your ADC range. You do not need to setup Vref+ = 1.5V for temperature sensor but you need to enable the reference by setting the REFON bits. Based on the output resistance of the temperature sensor use tsample = 30μs. Modify your code in Experiment 1 to satisfy the temperature sensor constraints. Use 4 ADC10CLK with a clock divider (ADC10DIV) value of 8. Set Sample Timer divider (ADC10SHTx) to be divided by 64. Use the same settings for TimerA that you used in Experiment 1. Collect 50 sampled values of the temperature just as in Experiment 1. Show in your lab report that the above settings satisfy both of the timing constrains introduced in Experiment 1. Is the timing constrain satisfied when ADC10DIV is set to divided by 2? If everything is setup correctly, your sampled data should have a fluctuation of the order of 20 or less. Explain how you have setup your ADC to match the time constraints. Also include a screenshot of the plot of 50 of your temperature sensor sampled readings and show the highest and lowest values on your graph. The datasheet gives the following relationship between the temperatures in degree Celsius vs the sampled value of the temperature:

Export the sampled temperature data from the CCS debugger and use MATLAB to convert your data into Celsius degrees. Notice that the temperature sensor has an offset that may deviate from the equation shown above, so your result might not look reasonable. Short Answer Questions 1. What other conversion modes are supported in this microcontroller? Briefly describe each of them. 2. The temperature can now be easily converted into PWM. The PWM signal can, for example drive the motor of a fan. What PWM sampling period and PWM resolution would you use?