RC Filters and Basic Timer Functionality

Similar documents
Introduction to basic laboratory instruments

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

Lab 13 AC Circuit Measurements

332:223 Principles of Electrical Engineering I Laboratory Experiment #2 Title: Function Generators and Oscilloscopes Suggested Equipment:

University of Jordan School of Engineering Electrical Engineering Department. EE 204 Electrical Engineering Lab

Physics 310 Lab 2 Circuit Transients and Oscilloscopes

Laboratory 4: Amplification, Impedance, and Frequency Response

Physics 120 Lab 1 (2018) - Instruments and DC Circuits

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

Lab 3: AC Low pass filters (version 1.3)

EE2210 Laboratory Project 1 Fall 2013 Function Generator and Oscilloscope

Time-Varying Signals

Lab 3: RC Circuits. Construct circuit 2 in EveryCircuit. Set values for the capacitor and resistor to match those in figure 2 and set the frequency to

1. Hand Calculations (in a manner suitable for submission) For the circuit in Fig. 1 with f = 7.2 khz and a source vin () t 1.

Experiment 8: An AC Circuit

Pre-Lab. Introduction

ECE 2274 Lab 1 (Intro)

LAB 1: Familiarity with Laboratory Equipment (_/10)

DC and AC Circuits. Objective. Theory. 1. Direct Current (DC) R-C Circuit

Sonoma State University Department of Engineering Science Spring 2017

EE 210 Lab Exercise #3 Introduction to PSPICE

EE 462G Laboratory #1 Measuring Capacitance

Lab 2: Linear and Nonlinear Circuit Elements and Networks

Lab #1 Lab Introduction

RC and RL Circuits. Figure 1: Capacitor charging circuit.

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

BME 3512 Bioelectronics Laboratory Two - Passive Filters

ECE 53A: Fundamentals of Electrical Engineering I

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

Lab 4: Analysis of the Stereo Amplifier

1.5k. (a) Resistive Circuit (b) Capacitive Circuit

LAB I. INTRODUCTION TO LAB EQUIPMENT

Lab Equipment EECS 311 Fall 2009

Name EET 1131 Lab #2 Oscilloscope and Multisim

Laboratory 2 (drawn from lab text by Alciatore)

EXPERIMENT NUMBER 10 TRANSIENT ANALYSIS USING PSPICE

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

ENGR 1110: Introduction to Engineering Lab 7 Pulse Width Modulation (PWM)

Filters And Waveform Shaping

EE 201 Function / Arbitrary Waveform Generator and Oscilloscope Tutorial

Lab Reference Manual. ECEN 326 Electronic Circuits. Texas A&M University Department of Electrical and Computer Engineering

The oscilloscope and RC filters

MAE106 Laboratory Exercises Lab # 1 - Laboratory tools

EXPERIMENT 4: RC, RL and RD CIRCUITs

Integrators, differentiators, and simple filters

Laboratory 3 (drawn from lab text by Alciatore)

Experiment 9 AC Circuits

ME 365 EXPERIMENT 1 FAMILIARIZATION WITH COMMONLY USED INSTRUMENTATION

Equipment and materials to be checked out from stockroom: ECE 2210 kit, optional, if available. Analog BK precision multimeter or similar.

EXPERIMENT NUMBER 2 BASIC OSCILLOSCOPE OPERATIONS

BME/ISE 3511 Laboratory One - Laboratory Equipment for Measurement. Introduction to biomedical electronic laboratory instrumentation and measurements.

EK307 Passive Filters and Steady State Frequency Response

EENG-201 Experiment # 4: Function Generator, Oscilloscope

Combinational logic: Breadboard adders

ECE 201 LAB 8 TRANSFORMERS & SINUSOIDAL STEADY STATE ANALYSIS

ET1210: Module 5 Inductance and Resonance

UNIVERSITY OF CALIFORNIA, DAVIS Department of Electrical and Computer Engineering. EEC 180A DIGITAL SYSTEMS I Winter 2015

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

Lab 11: 555 Timer/Oscillator Circuits

Laboratory 2. Lab 2. Instrument Familiarization and Basic Electrical Relations. Required Components: 2 1k resistors 2 1M resistors 1 2k resistor

Lab E5: Filters and Complex Impedance

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

EE 1210 Op Amps, Gain, and Signal Integrity Laboratory Project 6

Fig. 1. NI Elvis System

Precalculations Individual Portion Introductory Lab: Basic Operation of Common Laboratory Instruments

LAB I. INTRODUCTION TO LAB EQUIPMENT

EK307 Active Filters and Steady State Frequency Response

BIOE 123 Module 3. Electronics 2: Time Varying Circuits. Lecture (30 min) Date. Learning Goals

AME140 Lab #2 INTRODUCTION TO ELECTRONIC TEST EQUIPMENT AND BASIC ELECTRONICS MEASUREMENTS

E84 Lab 3: Transistor

LAB II. INTRODUCTION TO LAB EQUIPMENT

LABORATORY 3: Transient circuits, RC, RL step responses, 2 nd Order Circuits

Experiment #2: Introduction to Lab Equipment: Function Generator, Oscilloscope, and Multisim

Operational Amplifiers 2 Active Filters ReadMeFirst

Lab 10 - INTRODUCTION TO AC FILTERS AND RESONANCE

Waveform Generators and Oscilloscopes. Lab 6

Sirindhorn International Institute of Technology Thammasat University

Name: First-Order Response: RC Networks Objective: To gain experience with first-order response of RC circuits

Laboratory Equipment Instruction Manual 2011

ECE 4670 Spring 2014 Lab 1 Linear System Characteristics

UNIVERSITY OF TECHNOLOGY, JAMAICA School of Engineering -

Lab 5 Timer Module PWM ReadMeFirst

555 Timer/Oscillator Circuits

ECE ECE285. Electric Circuit Analysis I. Spring Nathalia Peixoto. Rev.2.0: Rev Electric Circuits I

EE431 Lab 1 Operational Amplifiers

1.0 Introduction to VirtualBench

Exponential Waveforms

EE283 Electrical Measurement Laboratory Laboratory Exercise #7: Digital Counter

Table of Contents...2. About the Tutorial...6. Audience...6. Prerequisites...6. Copyright & Disclaimer EMI INTRODUCTION Voltmeter...

Tektronix Courseware. Academic Labs. Sample Labs from Popular Electrical and Electronics Engineering Curriculum

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

ENG 100 Lab #2 Passive First-Order Filter Circuits

The University of Jordan Mechatronics Engineering Department Electronics Lab.( ) Experiment 1: Lab Equipment Familiarization

Lab 4 - Operational Amplifiers 1 Gain ReadMeFirst

Notes on Experiment #1

AC CIRCUITS - CAPACITORS AND INDUCTORS

10: AMPLIFIERS. Circuit Connections in the Laboratory. Op-Amp. I. Introduction

University of Jordan School of Engineering Electrical Engineering Department. EE 219 Electrical Circuits Lab

ECE 2274 Lab 2 (Network Theorems)

AC Magnitude and Phase

Transcription:

RC-1 Learning Objectives: RC Filters and Basic Timer Functionality The student who successfully completes this lab will be able to: Build circuits using passive components (resistors and capacitors) from a schematic diagram. Explain the concept of a high or low-pass filter and what its corner frequency is Construct a low-pass or high-pass RC filter with a given corner frequency. Explain terms associated with counter/timers, such as clock, top, bottom, overflow, and clock prescaler. Explain how the hardware timer integrated with an ATmega16 can be used to output a square wave with a given frequency. Components: Qty. Item 1 Atmel ATmega16 microcontroller with STK500 interface boards 1 Programming cable and power supply 1 Solderless breadboard 1 1 kω resistor 1 0.1μF capacitor (may be polarized) 1 10μF capacitor (electrolytic, so it is polarized) 1 Piezo speaker (Murata PKM17EPP-2002-130 (Mouser 81-PKM17EPP-2002)) Introduction RC Filter Theory You will begin this laboratory using the function generator connected to a simple circuit consisting of a resistor and capacitor. Details of the construction are given in the Procedure below. First, consider the circuit shown in Figure 1. The impedance of a capacitor, Z C, is 1/(jωC), a complex quantity, where j is the square root of -1, ω is frequency in rad/sec (2π rad/sec = 1Hz), and C is capacitance in Farads. Equation 1 can be derived from the voltage divider relationship formed by the resistor and capacitor. Equation 2 solves equation 1 for the ratio of to (V O /V i ), which is called the transfer function of the filter. FG 1 k 0.1μF scope RC Low-pass filter Figure 1. RC low-pass filter. The resistor and capacitor function together as a frequency-dependent voltage divider. The function generator will provide a time varying signal whose frequency can be varied, and the oscilloscope will enable you to measure the signal at the output of the circuit. Make sure that you use scope probes with the scope. Ask your lab instructor if you are unsure about which probes are scope probes.

RC-2 = 1( jωc) R+ 1( jωc) (1) = 1 1 + jω RC (2) The transfer function is a measure of how much of the input voltage is transferred to the output. What happens to the value of the transfer function as the frequency of the input voltage increases? Does it increase or decrease? For a given sinusoidal input voltage, the magnitude of the output voltage is given by the product of and the magnitude of the transfer function (evaluated at the frequency of ). An important property of filters is the corner frequency, or cut-off frequency. This is the frequency at which the attenuation of the signal through the filter starts to increase sharply. For a passive RC filter, (high or low-pass) the corner frequency is 1/RC radians/sec. By substituting ω=1/rc into equation 2, you can see that the denominator goes to 1+1j, and consequently the magnitude of / becomes 0.707. We will verify equation 2 by the following experiment. Procedure: [Note: the lab stations are set up so that half of the lab team can work on the circuit on the left side of the bench, and the other half of the team can work on programming the microcontroller on the right side with the computer. Be aware that exams will include information on both aspects, so all team members should switch roles and be familiar with what the other team members are doing.] 1. Construct the single-stage RC Low-pass filter circuit shown in Figure 1 above. Pay attention to the connection of the leads of the capacitor. The curved line on schematic shows that the capacitor is polarized (which may or may not be the case depending on the type of capacitor you were given by your lab instructor). Not all capacitors are polarized, but electrolytic ( lytic, for short) capacitors are. Lytics look like little aluminum cans. If you look at the side of the can, you should see a minus sign. The lead closest to the minus sign corresponds to the lead with the curved line on the schematic. It will also be the shorter of the two leads on a polarized capacitor that has not had its leads trimmed. It is extremely important that the lead nearest the minus sign always be kept at a lower potential (toward ground) than the other lead of the capacitor. If you reverse the polarity, the capacitor can explode, so take extra precaution, and double-check how you have wired the capacitors before you apply power to your circuit. There are other capacitors, such as ceramic capacitors, which are not polarized, and the connection to the leads are interchangeable. Discern what kind of capacitor you have, and connect it accordingly! 2. On the function generator, output a sine wave, and set the amplitude of to 5 volts peak-topeak (Vp-p) at 500 Hz (What termination should you set the function generator output to, 50 ohms or High Z?). Measure and record the amplitude of and using the scope. Repeat these measurements with the frequency of set to 1.6 khz and then 10 khz. Compare the ratio of the input voltage and the output voltage (i.e., /) with the magnitude of the transfer function (from equation 2) evaluated at the corresponding frequency. What can you conclude from this comparison about the relationship between the magnitude of the transfer function and the ratio of the input and output voltages? Explain. Why is this circuit called a low-pass filter? The phase lag of a circuit can be thought of as the amount of delay in the signal as it goes through the circuit. Phase lag is measured in degrees as shown in Figure 2. Recall that since the

RC-3 transfer function from equation 2 is a complex quantity, you can think of it as a vector in the complex plane. As you know, vectors have magnitude and direction. The phase lag of the circuit shown in Figure 2 is the angle of the transfer function vector, 1/(1+jωCR), evaluated at the frequency of the signal with respect to the real axis in the complex plane. We will verify this relation by the following experiment: 3. Set the scope to dual-trace mode. Connect two scope probes to the circuit with the same grounding points, but have one measure the output of the function generator and the other measure the voltage across the capacitor. Using the scope, measure the phase lag of this circuit of Figure 2 at =1.6 khz. The following steps may help you make this measurement: 1). Use the position knob on the scope to center each channel around the horizontal (time) axis 2). Change the volts/div adjustment to maximize the size of the signals on the screen 3). Adjust the Horizontal Delay to center a peak (or zero crossing) of the waveform on the vertical axis 4). Using Measure buttons, determine the period of the waveform 5). Use the Cursor button and cursors for t1 and t2 to determine Δt between the peaks (or zero crossings) of and Use Intuilink software or other means to take a picture of the scope trace for the lab report. Does the theoretical value match the observed value? Full period 360 degree ~ 45degree Δt t1 t2 Figure 2. Phase lag of. The output voltage is delayed (shifted later in time). The amount of time shift depends on the value of R and C, and the frequency of the input signal. One period of the waveform represents 360º, so the phase shift is just the percentage of time delay multiplied by 360º. You can use the time cursors on the scope to help in making the phase lag measurement. 4. Construct the single-stage RC high-pass filter circuit shown in Figure 3, and verify (using the voltage division formula) that / for this circuit is as follows: R = R+ 1( jωc) (3) jω RC = (4) 1 + jω RC 5. Repeat steps 2 and 3 for the high-pass filter in Figure 3. Note that is measured across the resistor in this case.

RC-4 FG 0.1μF 1 k scope RC High-pass filter Figure 3. High-pass filter. The resistor and capacitor together function as a frequency-dependent voltage divider. Note that the locations of the resistor and capacitor are interchanged in comparison to the lowpass filter shown in Figure 1. Add a DC offset (any value) to the function generator output. Does this DC offset affect the output () of the high-pass filter? If so, how? Record your measurements for and after you add the DC offset. This is the reason that a capacitor can be thought of as a device that blocks a DC component, but allows the AC component to go through. This is called AC coupling. Using the ATmega16 Timer to Output a Frequency Basic introduction to IC timers/counters One of the most common and useful peripheral devices in a microcontroller is the timer/counter. These peripherals can be used to count pulses of a signal. Timer/counters are extremely useful for keeping time and outputting signals when paired with a clock signal. A clock signal is a very uniform set of pulses generated by a device that occur at a constant frequency, such as that shown in Figure 4 below. Frequently these signals are derived from crystals or RC oscillators tuned to provide a particular output frequency. You have probably heard of the clock speed of a computer or other microprocessor. Microcontrollers, timer/counters, and many digital integrated circuits (ICs) need a clock signal to function. You can think of the clock signal like the heart beat of a sequential logic device. Figure 4. Clock signal input to a counter and the resulting count value as a function of time. Each time the clock signal has a rising edge, the counter's value increases by one.

RC-5 A timer is a specialized counter, which is given a clock signal. The device increments an internal register (think of a register like a variable in a computer program) each time the clock signal changes. The counter increases until it reaches a maximum value known as the TOP value of the counter. The most basic counters are unidirectional, that is they will only count up or down, starting from either the TOP value or the BOTTOM (minimum) value. A unidirectional counter (usually called either an up-counter or a down-counter ) will overflow on the next clock pulse after it has reached its top or bottom value, and it will then reset to the respective opposite value. There are also up-down counters, which will count to the TOP value, and then back down to the BOTTOM value. Because counters exist in the digital world, their counts are represented in binary form, and as a result, people talk about the resolution of a counter in terms of the size of their internal register in number of bits. Figure 5. The three main types of counters and their count values as a function of time. Note that 'up' and 'down' counters will loop around from top to bottom, this is called an overflow. The ATmega16 microcontroller features three built-in timer/counters. These are independent circuit units in the microcontroller, and therefore they can function in a fairly autonomous fashion. Your program code can set up the various attributes of the counter, such its input source (be it the chip s on board clock or an outside clock signal), how it should count, as well as whether it should behave as an up, down, or up-down counter. The ATmega16 features two 8-bit counters and one 16-bit counter, and the resolution of the counter can also be modified by the use of a prescaler. A prescaler allows one to scale down the clock signal by a specified amount. For example, in this lab we will use a pre-scaler of 8. This means that only every 8 th clock pulse will cause the counter to be incremented. Thus, coupled with our 8Mhz clock, this means that the counter will increment at a rate of 1MHz. Consequently, one counter tick is a millionth of second, so 1,000 counter ticks is 0.001 seconds, etc. If we are using a 16-bit counter and the above mentioned clock and prescaler, how much time will it take for the counter to reach it maximum value and then overflow? Now we want to use the ATmega16 microcontroller to output a tone and see the effect of filtering the resulting signal.

RC-6 1. Build the circuit shown below in Figure 6 on the solderless breadboard. Use a jumper wire (female socket on one end, stripped wire at the other end or kluge an equivalent using a 2-wire female jumper and a short length of hookup wire stripped at both ends) to connect the ATmega16 pin PD4 to the solderless breadboard. Note that the 10 μf capacitor is POLARIZED. Remember to look for the minus sign on the side, and connect the corresponding lead appropriately in the circuit. PD4 To scope channel 1 1k To scope channel 2 STK500 GND from Port D header 10 μf - Common ground scope ground clip Figure 6. ATmega16 circuit with RC Filter. The scope is used to display the output from the ATmega16 before and after the filter. Note that the ground shown is the common ground of the power supply. One (not both, they are internally wired together) of the ground clips from the scope probes must be connected to the power supply common ground. 2. Using AVR Studio create a new project with descriptive name (ex. RCfilterLab ) Select AVR GCC and type a descriptive name into the Project name field. You will be using existing sources so uncheck the Create initial file box. Check the Create folder box. Browse to ensure the Location (where your project will be saved) is your USB drive. Files left on lab computers can be erased at any time!!! Select AVR Simulator in the Debug platform field. Select ATmega16 in the Device field. (scroll down, it is there) 3. Configure your project settings using the Project -> Configuration Options drop down menu Change the Frequency box to 8000000. (8 million without the commas) Change the Optimization box to O2. Click on the Include Directories button found in the left side panel. Click on the New Folder icon (upper right corner) and use the browse ellipse to add your project folder you created in Step #2 (appears as.\ ), then click, OK 4. Use a web browser to navigate to the course website and download the supplied C file, main_rc.c, into the project folder you created in step 2. 5. Switch to AVR Studio to add the main_rc.c file to your project. Find the Project File Manager Window (look for AVR GCC and a file tree in the upper left hand corner). Right click on Source files Add Existing Source File(s) and locate the main_rc.c file that you just copied to your project folder. 6. Now, please take a moment to read through the code, especially the comments. The code has been designed to give you insight into what each line is doing. If you understand the code, you will be able to implement your own timer and counter in other projects. Pay special attention to

RC-7 any references the comments make to the datasheet for the microcontroller. Timers will come up throughout the semester. 7. Program the microcontroller (using Build Build, or F7) with this new code (use the AVR icon on the toolbar). Be sure to verify that you re using the hex file associated with this project while you re on the Program Tab. AVR Studio does NOT update this automatically when you open a new project. If someone else has used the AVR Studio recently, it may still be pointing to their hex file. Double-check that the fuses and the Oscillator and ISP speeds are set as instructed in the Introduction to the ATmega16 lab. 8. Connect a 10-pin jumper between port C and the Switches header (check the alignment of the red stripe etc ). Also connect the PORTA headers pins to the LED headers pins, and then power up the board, and press the reset button. 9. Connect the leads of the piezo speaker to PD4 and common ground. You should hear an audible tone when you hold down one of the switches on the STK500, and a different tone for each of the switches. The tone should stop when no button is pressed or if more than one button is pressed. 10. Look at the signal on channels 1 and 2 using the oscilloscope, and measure their voltages and frequencies. Acquire the scope display for your lab report using IntuiLink software (or other means). Comment on the behavior of the system.