ME 461 Laboratory #3 Analog-to-Digital Conversion

Similar documents
ME 461 Laboratory #2 Timers and Pulse-Width Modulation

Analog to Digital Conversion

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

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

University of North Carolina-Charlotte Department of Electrical and Computer Engineering ECGR 3157 Electrical Engineering Design II Fall 2013

ME 461 Laboratory #5 Characterization and Control of PMDC Motors

Lecture 7: Analog Signals and Conversion

UNIVERSITY OF NORTH CAROLINA AT CHARLOTTE Department of Electrical and Computer Engineering

Lecture 5 ECEN 4517/5517

Fill in the following worksheet-style pages. A colored pen or pencil works best. The procedure is:

EE283 Electrical Measurement Laboratory Laboratory Exercise #7: Digital Counter

University of North Carolina, Charlotte Department of Electrical and Computer Engineering ECGR 3157 EE Design II Fall 2009

ECE3204 D2015 Lab 1. See suggested breadboard configuration on following page!

Pre-Lab. Introduction

Design and Implementation of Digital Stethoscope using TFT Module and Matlab Visualisation Tool

ESE 350 Microcontroller Laboratory Lab 5: Sensor-Actuator Lab

Measuring Distance Using Sound

11. Audio Amp. LM386 Low Power Amplifier:

Screening Audiometer

EE 421L Digital Electronics Laboratory. Laboratory Exercise #9 ADC and DAC

E84 Lab 3: Transistor

EECS 373 Design of Microprocessor-Based Systems

EECS 373 Design of Microprocessor-Based Systems

COSC 3215 Embedded Systems Laboratory

9. Data Acquisition. Chapter 9

Build Your Own Bose WaveRadio Bass Preamp Active Filter Design

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

Experiment 9 AC Circuits

University of California at Berkeley Donald A. Glaser Physics 111A Instrumentation Laboratory

Digital Design Laboratory Lecture 7. A/D and D/A

Advantages of Analog Representation. Varies continuously, like the property being measured. Represents continuous values. See Figure 12.

Digital Sampling. This Lecture. Engr325 Instrumentation. Dr Curtis Nelson. Digital sampling Sample rate. Bit depth. Other terms. Types of conversion.

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

Experiment 8 Frequency Response

Lab 4: Analysis of the Stereo Amplifier

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

DEPARTMENT OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCE MASSACHUSETTS INSTITUTE OF TECHNOLOGY CAMBRIDGE, MASSACHUSETTS 02139

The Oscilloscope. Vision is the art of seeing things invisible. J. Swift ( ) OBJECTIVE To learn to operate a digital oscilloscope.

Analog to Digital Conversion

Chapter 2 Analog-to-Digital Conversion...

VCC. Digital 16 Frequency Divider Digital-to-Analog Converter Butterworth Active Filter Sample-and-Hold Amplifier (part 2) Last Update: 03/19/14

Designing Information Devices and Systems I Spring 2015 Homework 6

LM13700 Dual Operational Transconductance Amplifiers with Linearizing Diodes and Buffers

Lab 6. Binary Counter

UNIVERSITY OF PENNSYLVANIA EE 206

PART. MAX7401CSA 0 C to +70 C 8 SO MAX7405EPA MAX7401ESA MAX7405CSA MAX7405CPA MAX7405ESA V SUPPLY CLOCK

Chapter 2: Digitization of Sound

Project 4 Optical Communications Link

University of Michigan EECS 311: Electronic Circuits Fall 2009 LAB 2 NON IDEAL OPAMPS

In this lab, you ll build and program a meter that measures voltage, current, power, and energy at DC and AC.

LM13600 Dual Operational Transconductance Amplifiers with Linearizing Diodes and Buffers

EK307 Passive Filters and Steady State Frequency Response

HART Modem DS8500. Features

EE251: Tuesday October 10

LM13700 Dual Operational Transconductance Amplifiers with Linearizing Diodes and Buffers

Lab Exercise 6: Digital/Analog conversion

Spectrum analyzer for frequency bands of 8-12, and MHz

RC Filters and Basic Timer Functionality

ECE 271 Microcomputer Architecture and Applications University of Maine

Massachusetts Institute of Technology MIT

STATION NUMBER: LAB SECTION: Filters. LAB 6: Filters ELECTRICAL ENGINEERING 43/100 INTRODUCTION TO MICROELECTRONIC CIRCUITS

Lab 6: Building a Function Generator

Capacitive Touch Sensing Tone Generator. Corey Cleveland and Eric Ponce

MF6 6th Order Switched Capacitor Butterworth Lowpass Filter

Electronic Instrumentation ENGR-4300 Fall Project 4: Optical Communications Link

Laboratory Assignment 1 Sampling Phenomena

Design Implementation Description for the Digital Frequency Oscillator

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

P a g e 1. Introduction

Draw in the space below a possible arrangement for the resistor and capacitor. encapsulated components

In-Class Exercises for Lab 2: Input and Output Impedance

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

Microcontroller: Timers, ADC

DEPARTMENT OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCE MASSACHUSETTS INSTITUTE OF TECHNOLOGY CAMBRIDGE, MASSACHUSETTS 02139

LINEAR IC APPLICATIONS

Lab 7: DELTA AND SIGMA-DELTA A/D CONVERTERS

EECS 216 Winter 2008 Lab 2: FM Detector Part II: In-Lab & Post-Lab Assignment

Lab 5. Binary Counter

8-Bit, high-speed, µp-compatible A/D converter with track/hold function ADC0820

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

Low Cost Screening Audiometer

Analog Integrated Circuit Design Exercise 1

UNIVERSITY OF UTAH ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT ELECTROMYOGRAM (EMG) DETECTOR WITH AUDIOVISUAL OUTPUT

ANALOG TO DIGITAL CONVERTER ANALOG INPUT

Linear Integrated Circuits

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

16.1 ADC ADC ADC10

5 V Integrated High Speed ADC/Quad DAC System AD7339

The University of Texas at Arlington Lecture 10 ADC and DAC

Audio Noise Figure Meter

MF4 4th Order Switched Capacitor Butterworth Lowpass Filter

1 A1 PROs. Ver0.1 Ai9943. Complete 10-bit, 25MHz CCD Signal Processor. Features. General Description. Applications. Functional Block Diagram

Monitoring Temperature using LM35 and Arduino UNO

Analog/Digital Guitar Synthesizer. Erin Browning Matthew Mohn Michael Senejoa

Fundamentals of Data Converters. DAVID KRESS Director of Technical Marketing

Cyber-Physical Systems ADC / DAC

Real Time Embedded Systems. Lecture 1 January 17, 2012

Chapter 7. Introduction. Analog Signal and Discrete Time Series. Sampling, Digital Devices, and Data Acquisition

Lab 2: Discrete BJT Op-Amps (Part I)

MM5452/MM5453 Liquid Crystal Display Drivers

Transcription:

ME 461 Laboratory #3 Analog-to-Digital Conversion Goals: 1. Learn how to configure and use the MSP430 s 10-bit SAR ADC. 2. Measure the output voltage of your home-made DAC and compare it to the expected value. 3. Calibrate and use the MSP430 s internal temperature sensor. 4. Design and implement an RC anti-aliasing filter. 5. Solder a microphone circuit to the breakout board and use it to sample audio signals. Exercise 1: In this exercise you will configure the MSP430 s 10-bit analog-to-digital converter (ADC) to sample the output of the PWM low pass filter you designed in lab 2. This would be a good time to take another good look at, the lecture notes, the MSP 430 User s Guide ADC10 section, and the msp430x22x2.h header file. As you have heard many times already, control register names and predefined constants with (relatively) easy to remember names are declared in the msp430x22x2.h header file. For example with this source code: ADC10CTL0 = SREF_0 ADC10SHT_2 ADC10ON ADC10IE; On line 172 of the msp430x22x2.h header file you will find: #define SREF_0 (0*0x2000u) /* VR = AVCC and VR- = AVSS */ Obviously, zero times anything is zero and we can assign this value of SREF_0 to ADC10CTL, as in ADC10CTL0 = SREF_0; The binary representation of ADC10CTL0 will then be %0000 0000 0000 0000. Note that the three most significant bits are 000 and, referring to the MSP 430 User s Guide, you will see that setting the three most significant bits of ADC10CTL0 to 000 tells the microprocessor to use V CC as the positive voltage reference (V R ) and V SS (Ground) as the negative voltage reference (V R- ). As you know from Lab #2, the full-scale range of your home-made DAC is V SS = 0V to V CC = 3.6V. This means, you can use the example above to help get you started with the configuration of the ADC. Note that because we are using a voltage reference set that is already available on the board (V CC and GND), you do not need to worry about using any of the reference generator features. On line 167 of the msp430x22x2.h header file you will find: #define ADC10SHT_3 (3*0x800u) /* 64 x ADC10CLKs */ ME 461 1 Lab #3

Thus, the binary representation of ADC10SHT_3 = %0001 1000 0000 0000. We could now add SREF_0 and ADC10SHT_3 together, as in ADC10CTL0 = SREF_0 ADC10SHT_3; Now the binary representation of ADC10CTL0 = %0001 1000 0000 0000. Note that three most significant bits remain 000 but the fourth and fifth most significant bits are now 11. Again referring to the MSP 430 User s Guide you will see that setting the three most significant bits of ADC10CTL0 to 000 tells the microprocessor to use V CC as the positive voltage reference (V R ) and V SS (Ground) as the negative voltage reference (V R- ). Setting the fourth and fifth most significant bits (bits 12 and 11 of a 16 bit value) of ADC10CTL0 to 11 tells the microprocessor to set the sample and hold time to be equal to 64 cycles of the ADC10 clock source. The appropriate sample and hold time to use depends upon both the internal input resistance of the microprocessor and the external source resistance associated with any circuitry attached to the ADC input pin. Now refer to section 22.2.5 of the MSP430 user s guide to determine an appropriate minimum sample and hold time for your situation. The external (source) resistance R S is the value of R in your RC low pass filter. In calculating the sample-and-hold time, assume your DAC output is roughly constant relative to the ADC sample rate so that you may neglect the settling time of the external RC lowpass filter. Record the minimum sample and hold time below. T S,min = seconds Check the sample-and-hold time with your TA. It is recommended that you use the dedicated ADC oscillator, ADC10OSC, for the ADC10 conversion clock source (assume its speed is exactly 5MHz). Your minimum sample-and-hold time will dictate whether you need to divide the ADC10CLK source with the ADC10DIVx bits. Record the ADC clock rate after any ADC10DIVx divisions below and the resulting number of ADC10 clock pulses (an integer) that correspond to the minimum sample time you recorded above. ADC10CLK rate after divide: MHz T S,min = ADC10 CLKS Check these with your TA. Continue to determine the remaining configuration parameters according to the following guidelines. Note that you are strongly encouraged to start making regular use of the predefined constants found in the msp430x22x2.h header file and to become comfortable combining them as shown in the examples above (and in the code examples provided in the lecture notes). Doing so will greatly simplify the effort required to properly configure control registers and improve the readability of and portability of your code. You should connect the PWM DAC output to one of the analog inputs on the port 2 pins. To set that pin to analog input mode, you need to set the corresponding bit in the ADC10AEx register. Also, you must tell the ADC which input channel to convert. You may use any of the conversion triggers (referred to in the user s guide as the sample-and-hold source) you like. The ADC10SC bit is a software trigger that ME 461 2 Lab #3

is easy to use and thus recommended at this point, but the other (timer-based) triggers are better suited to fast sample rates (>10kHz) and may be necessary in future lab exercises. Whatever trigger source you use, you should trigger conversions every millisecond. Use the knowledge (and code) you gained from the first half of Lab 2 to generate a 1ms timing interval. For now, use the straight-binary data format. Finally, make sure you enable the ADC10 interrupt and turn the ADC10 on. For general ADC conversion flow, refer to figure 22-5 in the user s guide. Your program should control ENC and ADC10SC in accordance with this diagram. Also, not because you have to but because it is the appropriate place to perform this operation, be sure that you only read the conversion result (ADC10MEM) in the interrupt service routine. In your program, print out the raw conversion results and the corresponding integer millivolts to the serial port. Also, print the expected DAC voltage as you did in Lab 2. In performing the conversion from raw ADC results to millivolts, you may not use floating-point numbers, so keep in mind the caveats of integer math (such as 2/3 = 0). Demonstrate to your TA. Exercise 2: Now, change the analog input channel so that the ADC converts the internal temperature sensor s voltage. You will also have to modify the ADC clock input divider and sample-hold time to achieve the large minimum sample period listed in the user s guide section 22.2.8. Print the voltage in millivolts to the terminal window. Demonstrate to your TA. You will now calibrate the temperature sensor using the thermometer found in lab. Refer to section 22.2.8 of the user s guide. As you can see from Figure 22-13, the sensor voltage is a linear function of temperature. You may use the published value of the slope (3.55mV/ o C), but you will have to determine the offset voltage using the ambient temperature in lab and the corresponding sensor voltage. Record the value of the temperature sensor offset voltage below. V TEMP (mv) = 3.55 Temp( o C) mv Once you have found the offset voltage, convert the temperature sensor voltage to degrees Celsius and print the value to the serial port. Demonstrate to your TA. ME 461 3 Lab #3

Exercise 3: In this exercise, you are going to solder a microphone circuit to the breakout board and use it to sample audio signals. The circuit schematic is shown below. V CC Gain Adjust (see Note A) C G 2.2k 0.22µF V CC R G Anti-Aliasing Filter MIC 10k VOL 3 2 6 1 LM386-4 7 8 5 R A C A ADC in Ax 10µF Note A: 1) Leave Pins 1 & 8 open for Gain = 20. 2) Use R G = 1.2k and C G = 10µF for Gain = 50. 3) Use R G = 0 and C G = 10µF for Gain = 200. Note B: Use a 470µF bypass capacitor between V CC and GND when using the microphone and LM386. See LM386 datasheet for more information. Microphone circuit schematic Notice that the schematic includes an RC anti-aliasing filter on the output of the amplifier. This is a necessary component of a sampled-data system whenever the input signal is not band-limited to half the sample rate. Before you begin soldering the components, you are going to design the anti-aliasing filter. Our goal for the microphone circuit is to sample common audio signals. The audio signals you hear from a CD or mp3 player have been sampled at a rate of 44.1 khz. This ensures that every signal you can hear with your ears is accurately represented. In most cases, though, a sample rate this high is more than enough. It turns out that most speech and common sounds are in the low-frequency range. We are going to use a sample rate of 10 khz, which means we can capture audio signals in the 0-5 khz range. However, there will still be some sounds and noise outside this range. The goal of the anti-aliasing filter is to attenuate frequencies above the 5 khz Nyquist frequency. ME 461 4 Lab #3

Your job is to select an RC that satisfies the requirement that at 5 khz the attenuation should be roughly 50%, that is, only half the amplitude of a 5-kHz signal should be passed through. Hint: recall that the transfer function of an RC low pass filter is G(jω) = 1/(1RCjω). Record the cutoff frequency and the RC that achieves this below. Feel free to use MATLAB (with the tf and bode functions) to check your results. f C : Hz RC: Check these numbers with your TA. Now, from the list of components written on the whiteboard, choose a resistor and a capacitor that gives an RC close to what you calculated. Record the values of these components below. Check with your TA. R A : C A : Now, use the schematic above and the demo board in lab to guide you as you solder the components to your board. For now, leave pins 1 and 8 on the LM386 open for a gain setting of 20. You may need to increase the gain later. When you are done soldering the components to the board, scope the output of the amplifier as you make some noise into the microphone. You should see the typical audio signal waveform biased around ½ V CC. If the output of the amplifier uses only a small portion of the voltage range (0V-V CC ) for reasonably audible noises, increase the gain according to the note in the schematic. Show the audio signal to your TA. Also, scope the output of the anti-aliasing filter and see if you notice any differences. Now, sample the microphone circuit s output at a rate of 10 khz. You may use the software trigger bit (AD10SC) as long as you don t run into lags created by calling an ISR too often. You will have to perform another minimum sample-hold time calculation using the R A you found above. Change the data format to 2 s complement. This will cause the ADC to read 0 when there is no input to the microphone, since it is biased at ½ V CC. Write code to light an LED when the magnitude (absolute value) of the ADC reading is greater than something like half of the maximum. You do not need to convert the ADC reading to a voltage. Hint: in 2 s complement format, the (linear) mapping from voltage to digital reading for our reference set is 0V -512, V CC /2 0, and V CC 511. Demonstrate to your TA. ME 461 5 Lab #3