Laboratory Assignment 1 Sampling Phenomena

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

Lab 12 Laboratory 12 Data Acquisition Required Special Equipment: 12.1 Objectives 12.2 Introduction 12.3 A/D basics

Contents. Introduction 1 1 Suggested Reading 2 2 Equipment and Software Tools 2 3 Experiment 2

Experiment # 4. Frequency Modulation

ESE 150 Lab 04: The Discrete Fourier Transform (DFT)

Discrete-Time Signal Processing (DTSP) v14

ESE 150 Lab 04: The Discrete Fourier Transform (DFT)

Laboratory Experiment #1 Introduction to Spectral Analysis

THE NEXT GENERATION AIRBORNE DATA ACQUISITION SYSTEMS. PART 1 - ANTI-ALIASING FILTERS: CHOICES AND SOME LESSONS LEARNED

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

Experiment # 2. Pulse Code Modulation: Uniform and Non-Uniform

SGN Bachelor s Laboratory Course in Signal Processing Audio frequency band division filter ( ) Name: Student number:

Mechatronics. Analog and Digital Electronics: Studio Exercises 1 & 2

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

Pre-Lab. Introduction

E x p e r i m e n t 2 S i m u l a t i o n a n d R e a l - t i m e I m p l e m e n t a t i o n o f a S w i t c h - m o d e D C C o n v e r t e r

ECEGR Lab #8: Introduction to Simulink

Experiment 02: Amplitude Modulation

Laboratory Assignment 5 Amplitude Modulation

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

MASSACHUSETTS INSTITUTE OF TECHNOLOGY /6.071 Introduction to Electronics, Signals and Measurement Spring 2006

II Year (04 Semester) EE6403 Discrete Time Systems and Signal Processing

DSP Laboratory (EELE 4110) Lab#10 Finite Impulse Response (FIR) Filters

EE 422G - Signals and Systems Laboratory

Lecture Schedule: Week Date Lecture Title

EE 233 Circuit Theory Lab 2: Amplifiers

Data Conversion and Lab Lab 4 Fall Digital to Analog Conversions

Experiment # 2 Pulse Code Modulation: Uniform and Non-Uniform

Laboratory Assignment 2 Signal Sampling, Manipulation, and Playback

Music 270a: Fundamentals of Digital Audio and Discrete-Time Signals

ET 304A Laboratory Tutorial-Circuitmaker For Transient and Frequency Analysis

Using the CODEC ReadMeFirst

Using High Speed Differential Amplifiers to Drive Analog to Digital Converters

ECEN 325 Lab 5: Operational Amplifiers Part III

ENGR 210 Lab 12: Sampling and Aliasing

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

Based with permission on lectures by John Getty Laboratory Electronics II (PHSX262) Spring 2011 Lecture 9 Page 1

EE2210 Laboratory Project 1 Fall 2013 Function Generator and Oscilloscope

Continuous vs. Discrete signals. Sampling. Analog to Digital Conversion. CMPT 368: Lecture 4 Fundamentals of Digital Audio, Discrete-Time Signals

BME/ISE 3512 Bioelectronics. Laboratory Five - Operational Amplifiers

Figure 1: Block diagram of Digital signal processing

ADC and DAC converters. Laboratory Instruction

Sampling and Reconstruction

Pulse Code Modulation

EET 223 RF COMMUNICATIONS LABORATORY EXPERIMENTS

Operational Amplifiers

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

Design IV. E232 Spring 07

ECEN Network Analysis Section 3. Laboratory Manual

EE 330 Laboratory 8 Discrete Semiconductor Amplifiers

Analog-Digital Interface

Build Your Own Bose WaveRadio Bass Preamp Active Filter Design

EE 3305 Lab I Revised July 18, 2003

EE 368 Electronics Lab. Experiment 10 Operational Amplifier Applications (2)

Data acquisition and instrumentation. Data acquisition

Combinational logic: Breadboard adders

Theoretical 1 Bit A/D Converter

Integrators, differentiators, and simple filters

LAB #7: Digital Signal Processing

LABORATORY 4. Palomar College ENGR210 Spring 2017 ASSIGNED: 3/21/17

Lab 4: Analysis of the Stereo Amplifier

FYS3240 PC-based instrumentation and microcontrollers. Signal sampling. Spring 2017 Lecture #5

LABORATORY #3 QUARTZ CRYSTAL OSCILLATOR DESIGN

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

Chapter 2 Signal Conditioning, Propagation, and Conversion

CMPT 318: Lecture 4 Fundamentals of Digital Audio, Discrete-Time Signals

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

Exercise 1: AC Waveform Generator Familiarization

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Electronic Circuits Spring 2007

PC-based controller for Mechatronics System

Experiment I: An Introduction to the Arduino Due + Sampling and Reconstruction

ece 429/529 digital signal processing robin n. strickland ece dept, university of arizona ECE 429/529 RNS

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

Introduction to Lab Instruments

Assignment 8 Analyzing Operational Amplifiers in MATLAB and PSpice

Laboratory 8 Operational Amplifiers and Analog Computers

Chapter 2: Digitization of Sound

A DSP IMPLEMENTED DIGITAL FM MULTIPLEXING SYSTEM

Sept 13 Pre-lab due Sept 12; Lab memo due Sept 19 at the START of lab time, 1:10pm

Analog to Digital Converters

Lab 4 Digital Scope and Spectrum Analyzer

OPERATIONAL AMPLIFIERS LAB

The University of Queensland School of Information Technology and Electrical Engineering. ELEC3004/7312: Signals, Systems and Controls

The Case for Oversampling

EE 210 Lab Exercise #4 D/A & A/D Converters

ANALOG-TO-DIGITAL CONVERTERS

Summary Last Lecture

DIGITAL FILTERING OF MULTIPLE ANALOG CHANNELS

UNIT III Data Acquisition & Microcontroller System. Mr. Manoj Rajale

University of Pennsylvania Department of Electrical and Systems Engineering. ESE 206: Electrical Circuits and Systems II - Lab

FYS3240 PC-based instrumentation and microcontrollers. Signal sampling. Spring 2015 Lecture #5

SU QuarkNet Workshop 2012 Lab Activity 5 ELECTRONICS II: ADCs & DAQ

Cyber-Physical Systems ADC / DAC

EE 233 Circuit Theory Lab 3: First-Order Filters

Laboratory Exercise #1

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

ME 461 Laboratory #3 Analog-to-Digital Conversion

When you have completed this exercise, you will be able to relate the gain and bandwidth of an op amp

Linear Motion Servo Plants: IP01 or IP02. Linear Experiment #0: Integration with WinCon. IP01 and IP02. Student Handout

Transcription:

1 Main Topics Signal Acquisition Audio Processing Aliasing, Anti-Aliasing Filters Laboratory Assignment 1 Sampling Phenomena 2.171 Analysis and Design of Digital Control Systems Digital Filter Design and Implementation 2 Equipment Personal Computer with DS1102 (dspace, Inc.) Controller Card Matlab, Simulink, Real-Time Workshop, Real-Time Interface, and Control Desk Software Digital Storage Oscilloscope Breadboarding System with Analog Electronics Earphones Function Generator Music Source 3 Introduction This set of exercises familiarizes you with the laboratory hardware and shows you how to use the hardware to perform real-world tasks such as acquiring signals and processing them. We also ask you to look at the non-idealities of these operations. You will look at the effects of sampling on signals from the generator and on music. You will also study quantization. Finally, you will implement first-, second-, and higher-order discrete-time filters. These filters will be designed from the viewpoint of approximating continuous-time analog filters and directly as digital filters. 4 Aliasing and Smoothing 4.1 Background and Equipment In this lab, you will use sine waves and music as a source for signal processing. For the music source, you can provide your own, or play music out from the computer at each station. When processing a signal you will want to use nearly the full range of the A/D converters, so as to utilize the maximum number of quantization levels. The signal from the most music sources is at the 100 mv level, which is much lower than the full-scale ±10 V range of the A/D s. Thus you need to use an amplifier to increase this signal to the level of volts. We have designed an appropriate interface circuit for you as shown in Figure 1. 1

C Sig.Gen. Audio Vin 10K 100K - LM741 + 2 3 +15 V 7 4 6 Vad ADC 1-15 V Scope Input Anti-Aliasing Filter C 22K DAC 1 Vda 22K 2 3 +15 V 7 - LM741 + 4 6 Vout 470 Scope Output -15 V Smoothing Filter Figure 1: Anti-aliasing and smoothing filter circuit diagram. We also want to be able to listen to the audio signals. Headphones have been provided at each station for this purpose. Since the DAC cannot supply sufficient current to drive these headphones directly, we have built an interface amplifier which can supply the headphone current. This amplifier is also shown in Figure 1. Both of these circuits have been pre-assembled for you on the electronic protoboard. The lab explores the use of anti-aliasing and smoothing filters. The anti-alias filter attempts to remove high frequencies at the input before they reach the A/D. This is implemented by the input amplifier. The smoothing filter attempts to remove the high-frequencies associated with the staircase output from the D/A. This is implemented in the output amplifier which drives the headphones. The anti-aliasing filter has a transfer function of V ad (s) V in (s) = R f 1 (1) R 1 R f Cs + 1 10 = 10 5 C + 1. (2) This is a first-order filter with a low-frequency gain of -10, and a -3 db frequency set by the capacitor value. The transfer function for the smoothing filter is similar to that of the anti-aliasing filter. It has a low-frequency gain of 1, and the capacitor value sets the cutoff frequency. 4.2 Experimental Procedure a) Use Simulink and rtilib to create a model like that shown in Figure 2. Set the sampling rate by selecting Simulation:Parameters from the simpleio menu bar. Set the options to a fixedtime-step solver with a step size of 0.0001. Close the window, save the file again, and select Tools:RTW Build. This step converts the block diagram into C-code, compiles this code, and downloads the executable to the DSP. At the end of this step, the DS1102 should be reading from the A/D and writing to the D/A at 100 µs intervals. b) We will now examine the effect of aliasing. Aliasing occurs whenever a signal is sampled at a rate less than twice the maximum frequency contained in the signal. Aliasing is easily demonstrated 2

Figure 2: Simulink block diagram simpleio.mdl used to demonstrate aliasing effects. using a sinusoidal signal source and sampling at less than twice its frequency. More complex effects occur when we sample a music signal. Pass a sinusoidal waveform from the signal generator through the anti-aliasing filter, and into A/D Channel 1. Initially run with the capacitors switched out, and thus no filtering. What effects do you observe in the output waveform? Try varying the input frequency and look at the frequency content of the output waveform. You may want to try changing the sample rate and recompiling to examine that effect. You should clearly see aliasing when the input frequency is higher than half the sampling rate. c) Switch in the anti-aliasing and/or smoothing filters. Investigate the effect that these have. We want you to both observe the waveforms on the scope and to listen to the outputs and inputs on the headphones. Try to correlate what you see on the scope with what you hear on the headphones. Notice the beating phenomenon which occurs with the input frequency near half the sampling frequency. d) Sinusoids are a simple waveform. Music is much more complex, but allows us to see/hear many effects simultaneously. Switch the input of your system to the music signal, and repeat the experiments above to understand the effects of sampling on the music signal. The music enters the system through the first BNC connector on your board, and the function generator enters through the second BNC. Move the wire to switch the input between them. Note the serious distortions introduced by aliasing when sampling audio signals at low sample rates. Look at the traces on the oscilloscope and listen to the music on the earphones as you lower the sampling rate; what effects do you see and hear? This gives you an appreciation for the effect of aliasing on real-world signals. What are the effects of the anti-alias and smoothing filters? 5 Quantization 5.1 Background and Equipment Every digital system discretizes an analog signal in both time and amplitude. Only fixed levels (quanta) are permitted in a digital system. The DSP board used in this course has 16-bit A/D s on channels 1 and 2, and 12-bit A/D s on channels 3 and 4. All four of the D/A channels have 12-bit resolution. 3

Figure 3: Simulink block diagram quantize.mdl used to demonstrate aliasing effects. For the 12-bit channels, the operating voltage range of ±10 volts is quantized into 4096 different levels, which corresponds to 4.88 mv per quanta. For the two 16-bit A/D s the signals are quantized into 65536 levels, which corresponds to 0.305 mv per quanta. The software interface to the DSP board also takes the convention that the analog range of ±10 V is mapped to a numerical range of ±1 in the block diagram. Be sure to note this scaling of 10:1! 5.2 Experimental Procedure e) Create a model with quantization as shown in Figure 3. The quantization block is located in the Simulink:Nonlinear library, and using it allows us to effectively increase the quanta size (thus decreasing the resolution). To quantize to 2 N levels, double-click the quantization block and set the level to 1/2 N 1. Note that this value is chosen in light of the internal full range of ±1 corresponding to analog signals of ±10 V. As a starting point, let N = 4. Set the sample time (in Simulation:Parameters) to 0.0001 s with a fixed-time solver. Save the file as quantize.mdl, and download with Tools:RTW Build. f) Choose the quantization bits N at several settings ranging from 2 to 12, recompiling after each change. The resulting distortion due to quantization when using fewer bits can be appreciated by listening to and looking at the quantized and analog signals. Remember that you have to keep the magnitude of the analog signal large enough to be able to see all the levels, but not so large as to be entering saturation. Use the function generator as the source initially and perform the experiment with sinusoidal signals. Observe the effect of increasing and decreasing the amplitude of the sinusoid. You should able to count off 4 levels for a 2 bit quantization level and 16 levels for a 4 bit quantization level on the oscilloscope. Try the same experiment with the music source instead of the waveform generator. Note the deterioration of sound quality as fewer bits are used. 6 Discrete-time filtering 6.1 First-order discrete-time filter Discrete-time filters are described by difference equations in much the same way that continuous-time filters are represented by differential equations. The discrete-time equivalent of a continuous-time filter 4

can be obtained by various approximations to the derivatives. A common approximation is by the forward Euler rule. Let x a (t) be an analog signal and its value at the k th sampling interval be given by x(k) = x a (kt ) where T is the sampling period. The Euler rule then approximates the derivative as x a (kt ) x a((k + 1)T ) x a (kt ) T x(k + 1) x(k) ẋ(k) = T x a (t) at t = kt. Let us now apply the above rule to a first-order unity-gain continuous-time filter given by the transfer function Y (s) U(s) = b s + b The corresponding differential equation is then given by sy (s) + by (s) = bu(s) ẏ a (t) + by a (t) = bu a (t) (5) As before, define y(k) = y a (kt ) and u(k) = u a (kt ). Then the difference equation which approximates this via the forward difference is given by y(k + 1) y(k) + by(k) = bu(k) T y(k + 1) y(k) = bt u(k) bt y(k) y(k + 1) = bt u(k) + (1 bt )y(k) (6) Equation 6 gives the difference equation in a form suitable for implementation in a computer program. That is, we can calculate the present value of y with knowledge of its previous value and of the previous value of the input u. We can also specify this discrete-time filter via its transfer function. Introducing the z-transform variable z to represent a unit forward shift in discrete time, we can rewrite the difference equation above in transfer function form as bt H (z) = (7) z (1 bt ) where Y (z) = H (z) U (z). The above system can be implemented in Simulink by using a discrete-time transfer function block with num = [0 bt ] and den = [1 (1 bt )]. In discrete system representation, it is good practice to enter the numerator and denominator polynomials as equal length vectors, padded with zeros as needed. This avoids confusions which can occur due to the use of z or z 1 in transfer function polynomials. For instance, in the signal processing literature, it is common to use H(z 1 ), whereas in the controls area it is more standard to use H(z). We recommend H(z), but with the zero padding mentioned above, both forms are equivalent. h) Build and run a filter which implements this discrete-time transfer function. i) Examine the effect of the digital filter on sinusoidal input signals from the function generator. Initially, switch out the analog filter capacitors so that we do not have any anti-aliasing or smoothing effects. Initially, set T = 0.0001 and b = 1000, and thus the resulting first-order digital filter should approximate a continuous-time filter with a time contant of 1 ms. Using the scope, look at a sinusoidal waveform before and after the digital filter. Does it have the response you expect? Look at the response for inputs at frequencies higher than the Nyquist (i.e. above 5000 Hz). You should see the amplitude of the output grow again. Can you use aliasing to explain this effect? 5 (3) (4)

j) Change the output of the function generator to a square wave, and adjust the scope to display the step response of the digital filter. While keeping the sampling rate fixed, change the value of b and examine the step response of the digital filter. At low values of b, the response should approximate a continuous system. Examine the shape of the response as you raise b. At what value of b does the response depart significantly from the continuous-time response? At what value of b does the response become unstable? Note the z-plane pole location for each value of b so that you can develop an intuition for the z-plane. Be sure you understand the response characteristics in light of the z-plane pole location. 6.2 Second-order discrete-time filter We will now create a discrete-time approximation to a second-order continuous-time system. A unitygain second-order continuous-time filter can be described by the transfer function Y (s) U(s) = ω 2 n s 2 + 2ζω n s + ωn 2. (8) We will next apply the forward Euler rule to derive a corresponding transfer function, H (z) = ω 2 nt 2 z 2 + (2ζω n T 2) z + (T 2 ω 2 n 2ζω n T + 1) (9) Please check this derivation to be sure that you understand it before proceeding further. The experimental procedure for this section of the lab is described as follows. k) Create a model which implements this filter with a 10 khz sampling rate. l) Look at the filter output when using the function generator for a sinusoidal input. Does the frequency response match your expectations? At frequencies past the Nyquist, can you see the increasing amplitude (as in the first-order system)? Change the function generator to produce a square wave output, and look at the step response on the scope. How well does the response correspond to the modeled continuous-time system? Look at different values of ζ and ω n. How does the response correspond with the location of the discrete-time poles? Determine a relationship between ζ, ω n, and T for stability. Compare this with the mapping viewpoint of the approximate filter design. How does the approximation of the second order filter hold up for large ω n or small values of ζ? 6.3 Other discrete-time filters Experiment with additional discrete-time transfer functions in order to understand the effect of pole and zero locations in the z-plane. m) Take a look at the effect of pole and zero locations in the transfer function H (z) = b 0z 2 + b 1 z + b 2 a 0 z 2 + a 1 z + a 2. (10) n) Design some interesting finite impulse response (FIR) filters, and implement these on the real-time system. Compare the step and frequency responses with that predicted in Matlab, and explain these responses in terms of the pole and zero locations. A separate handout on FIR filters will be available shortly. 6