Time Varying Signals
Time Varying Signals
Objective
In this experiment well introduce the tools used to generate and measure signals that vary with time. Youll use a function generator and oscilloscope, view the output of an AC voltage divider circuit, and simulate the circuit in PSpice. Then well use Matlab to write a program that generates the signals weve looked at, plus a couple more. The idea is to learn the basic concepts of what function generators and oscilloscopes do and how they work. Youll also learn how to handle AC analysis in PSpice and Matlab.
Concepts
Until now, weve looked at signals that did not vary with time. In this lab, well analyze signals that vary periodically with time. The most common periodic electrical signal is the sinusoid. We use a cosine reference for sinusoidal signals, so voltages can be expressed in the form: Sinusoid = A + Bcos(t + ) (1)
A represents the DC offset, B represents the peak signal amplitude, is the radian frequency (recall that is equal to 2f, where f is the frequency), and is the phase shift. Phase shift is the horizontal difference between two signals, for instance, the phase difference between a sine and cosine is /2, or 90. The amplitude of a sinusoid can be represented as a peak value (p or pk), a peak-to-peak value (pkpk), or and average root-mean-square (rms) value. In this lab, Vp will be peak voltage, and Vpp will be peak-to-peak.
Figure 1: Sinusoidal function with no DC offset Figure 2: Sinusoidal function with a DC offset Figure 1 shows a sinusoidal signal. 1A shows the peak amplitude, 1B shows the peak-to-peak amplitude, and 1C shows the period. Figure 2 shows the same sinusoid, but where the signal of Figure 1 has a 0 V DC offset, the signal in Figure 2 has a non-zero DC offset.
Figure 3 shows the Wavetek function generator front panel. Like all the measurement equipment we use, all function generators have a basic features that allow you to select the type of function, amplitude, frequency, DC offset, and modulation. The Wavetek has the capacity to perform tasks such as logarithmic and linear sweeps and AM modulation, but what were primarily concerned with for this lab is generating basic sinusoid, square, and triangle waves. What follows is a basic description of the Wavetek Model 25 functions well be using today. The FUNCTION selection allows you to select between sinusoid, square, and triangle wave output. The FREQUENCY RANGE selection allows you to select the maximum frequency range of your desired signal. So if you wanted a 1 kHz signal, it would be best to select the 5 kHz frequency range. Then FREQUENCY youd use the frequency knob to set the frequency. The ATTENUATOR allows you to select your amplitude and DC offset range. The largest range occurs when both attenuators are off. The second largest is when only the -20 dB attenuator is on. The third largest is when the -40 dB attenuator is on, and the smallest range is when both attenuators are on. The DC OFFSET and AMPLITUDE knobs adjust, well, the DC offset and the amplitude. To adjust the DC offset, you push the OFFSET button (A), then use the DC OFFSET knob to change the value. Likewise, to change the amplitude, you push the PK-PK/RMS button (B) and use the AMPLITUDE knob to set the amplitude.
is shown in Figure 4. The initial display is shown in Figure 5. The buttons on the bottom of Figure 5 are called softkeys. What follows is an introduction to the controls shown in Figure 4.
Run Control menu Run/Stop and Single enable the oscilloscope to acquire data. A trigger event is what tells the scope to begin acquiring data. The oscilloscope needs to keep collecting data, since it analyzes signals that change with time. When Run/Stop is green the instrument is continuously acquiring data with the scope displaying multiple acquisitions of the same signal. When Run/Stop is red the oscilloscope has stopped acquiring data, and only information from the last trigger is available for display and measurement. Running in Single will cause the scope wait for the trigger event defined by the user and sweep one time. Trigger menu A trigger event is an electrical event that tells the oscilloscope when to begin acquiring data. For instance, you can set a trigger level to a certain voltage. Once the voltage reaches the trigger level, the oscilloscope begins sampling the data. The Trigger Mode dictates how the instrument determines when a trigger event has occurred. The user determines the nature of the trigger event through the use of the soft keys and other front panel inputs. For example, in Figure 4, the Edge selection is lit up. Selecting the Edge trigger brings up a menu from which you can choose with the softkeys. This menu allows the user to determine whether a rising edge or falling edge will trigger the display and the source of the trigger input (analog channel 1 or 2, the digital inputs D0 D15, or some external source) Pressing the Mode/Coupling button enables several softkeys under the display to allow the user to determine the trigger and coupling mode for the trigger. The Mode soft key offers three options: Auto Level, Auto and Normal. The voltage level of the trigger is set using the Level knob on the main panel. In general, the trigger control determines when the display will begin. This set of controls allows the user to select the source of the trigger, the mode and what kind of electrical event will cause the display to begin.
Normal mode displays a waveform only when the trigger conditions are met. The display will NOT update until trigger conditions are met. This makes it useful for signals that only occur once or very few times, like transients, which well learn about in a subsequent lab. Auto mode also displays the input waveform when it detects a valid trigger event. However, unlike Normal mode, once the acquisition memory is full it will generate a trigger and update the display as if a trigger occurred. Note: For both Normal and Auto the instrument will fill the pre-trigger buffer memory before the instrument will even begin looking for a trigger event, which can cause some trigger events to be overlooked. Auto-level only works when Edge is selected on the front panel. The input data flows into the pretrigger buffer and the instrument examines the data for a valid trigger. It will allow the data to overflow the buffer while it waits for a trigger. First it tries a Normal trigger, then it adjusts the level to 10 percent of full scale and 50 percent of full scale. If it still doesnt detect a valid trigger it will trigger anyway and update the display. Other Trigger Types are selected from the front panel inputs. Pulse width, pattern, duration, sequence, and others are available. See the Users Guide, which is linked from the EE2303 website, for more information. Because the Agilent 54621D is a digitizing oscilloscope, the input signals are digitized and then stored in acquisition memory. This memory is partitioned in pre-trigger, trigger and post-trigger areas. The Mode selected by the user determines how this data is displayed. Coupling Modes DC coupling allows both DC and AC signals into the trigger path. AC coupling puts a filter into the trigger path that rejects frequencies below 3.5 Hz. It blocks the DC component (like an offset voltage from the function generator) from the trigger path. If you want to be able to measure the DC offset, dont use this setting. LF Reject puts a filter in the trigger path that rejects frequencies below 50 kHZ. Use this coupling if you want to measure signals that have a strong low frequency noise component. Horizontal The knob labeled A in Figure 4 adjusts the horizontal scale. The horizontal axis is time, and the knob increases and decreases the time per horizontal square on the display. To zoom out and display more periods, you increase the time base. To zoom in and view fewer periods, you decrease the time base. The time per horizontal square can be viewed in the place on the screen shown in Figure 6 under A. Figure 4 B shifts the signal horizontally.
Analog The Volts/div knob shown in Figure 4 C and D adjusts the volts per division for channels 1 and 2, respectively. Just as the Horizontal control adjusts the horizontal scale, the Volts/div knob adjusts the vertical scale. The current setting can be viewed in the upper left corner of the display, shown just below B in Figure 6. In Figure 6, the display is set for 1 volt per division, meaning that each vertical square represents 1 volt of signal output. If you start at the upper most peak, and count down to the bottom most peak you should count four whole squares and two partials. That represents about 4.5 V peak-to-peak (4.5 Vpp). Figure 4 E and F shift the signal up or down for each channel.
reading manuals), and the articles on the Agilent website. Use your own words and cite your sources. 10 points) 3. The Agilent 54621 D is a deep-memory digital oscilloscope. Type a paragraph describing what deep memory is and why its useful, given what you now know about digital oscilloscope data acquisition. Again, use your own words and cite your sources.
9. Use the horizontal X cursors to measure the period in the same manner. The X gives the time. 10. Using the Quickprint function, save the plot (with the cursors in place) to a disk. You can then open it in Paint. Print out a copy to hand in. 11. Set the function generator to output a 5 MHz, 18 Vpp sinusoid with a 6 V DC offset. There will be a flattening of the signal. Include an explanation of why this occurs on the data sheet. The online function generator manual will help the cause. 12. Lastly, well look at the rise time of a square wave. Adjust the function generator to output a 1 Vp 1 MHz square wave. If we zoom in on the horizontal scale (using the Horizontal control) closely enough, we see that the square wave actually takes a measurable amount of time to go from low to high. Rise time is often defined as the time it takes to go from 5% of the maximum signal to 95%, but for this case, were going to measure simply from minimum to maximum. Then if you want to measure from 5% to 95%, you can do it! But for now, use the cursors to measure the time the signal takes to go from full minimum to full maximum. Print out a copy of the plot with the cursors in place.
(2)
So heres what were going to do: 1. Before building the circuit, measure the resistances of each resistor and make note of their actual values (for your reference). 2. Build the circuit shown in Figure 7 on your breadboard. The voltage source will be your function generator, set at a 1000 Hz, 3 V peak, 0 V DC offset sinusoid.
3. Use the oscilloscope to view the voltage across R1 on channel 1 and the input voltage on channel 2. Set the horizontal scale to show two periods. Then save the plot to disk and print it out on your computer. 4. You may not have seen any difference between the signal on channel one and the signal on channel two for the last section. If not, examine the placement of the reference (black) lead for both the scope and the function generator. Electrically, these two leads are at the same potential because of internal connection inside the generator and scope. How does this affect your ability to take the measurement in item #3.
5. Use the oscilloscope to view the voltage across R2 on channel 1 and the input voltage on channel 2. Set the horizontal scale to show two periods. Again, save the plot to disk and print it out on your computer. 6. Answer Question 3 on the data sheet, describing your results and expectations.
2. Set up the circuit simulation profile. The Simulation Settings window is shown in Figure 9. The analysis type this time is Time Domain (Transient). Given the frequency of the input, enter a run time that will show two periods of the signal. Later, you can vary the sampling step size and see how it affects the output. When youre finished, click OK.
3. Run the simulation. After you run, the output plot window will come up (Figure 10) and show you graphs of nothing! It doesnt even work! Actually you have to add the output plots you want to look at. 4. Click Trace, then Add Trace. The window in Figure 10 will come up. In the Trace Expression, select or type: V1(V1), V2(R2), V1(V1)-V2(R2) . This can all be done on the same line. It will select three different voltages to plot.
10
5. On the data sheet, write down the circuit element to which each voltage corresponds. In other words, which is the source voltage, which is the voltage across R1, and which is the voltage across R2? 6. The final output plot is shown in Figure 11. Print out a copy of your plot to hand in.
11
The input to the program should be values for frequency, amplitude, DC offset, number of periods to display and square wave duty cycle. The output of the program should vary depending on these input parameters. For an example of the input and output to the program, well refer to Figures X X: The input to the program was: Frequency = 1000 Hz; Amplitude = 2 V (pk); Number of periods to display = 4; DC offset = 2.5 V; Duty Cycle for the non-50% square wave = 33%; The output was: Figure X: 4 periods of a sinusoid with f = 1000 Hz, A = 2 V pk, and a DC offset of 2.5 V; Figure X: 4 periods of a 50% duty cycle square wave with f = 1000 Hz, A = 2 V pk, and a DC offset of 2.5 V; Figure X: 4 periods of a 33% duty cycle square wave with f = 1000 Hz, A = 2 V pk, and a DC offset of 2.5 V; Figure X: 4 periods of a sawtooth wave with f = 1000 Hz, A = 2 V pk, and a DC offset of 2.5 V; Figure X: 4 periods of a triangle wave with f = 1000 Hz, A = 2 V pk, and a DC offset of 2.5 V;
12
On page X is a skeleton file with pseudocode for one way to do this program. Once you get the sinusoid, the code for each other function is the same except for the type of function. To generate the different types of functions, look up the help files on the square, tripuls, and sawtooth commands (no prizes for guessing what they do). Other helpful commands are plot, figure, title, xlabel, and ylabel. You can choose to follow the format of the skeleton, or devise your own program structure to perform the tasks. When you finish, turn in your data sheets, plots from Parts 1-3, and Matlab code .
Bye.
13
%%% skeleton file for generating functions in Matlab clear; %%% clear all variables
%%% input to program f = %%% frequency a = %%% amplitude per = %%% input number of periods dc = %%% dc offset duty = %%% duty cycle for square wave %%% calculate the period %%% create the index vector against which to plot the data - the %%% array should go from 0 to the total time it takes to complete %%% the inputted (is that a word) number of periods %%% sinusoid function %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % use a for loop to generate cosine values for each item in your sample array, using the form A + B * cosine wave to generate the cosine, use cos(wt), where t will be an element of your index array
%an alternate method is to vectorize the function by using the same index vecto you created above again as the input to your function % plot the cosine wave vs. the sampling array % add a title % add x and y axis labels %%% square wave - 50% duty cycle %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % use a for loop to generate values for each item in your sample % array, using the form A + B * square wave % plot the wave as before %%% square wave - variable duty cycle %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % use a for loop to generate values for each item in your sample % array, using the form A + B * 33% square wave % plot the wave %%% sawtooth wave %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % use a for loop to generate values for each item in your sample % array, using A + B * sawtooth wave % plot the wave %%% triangle wave %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % use a for loop to generate cosine values for each item in your sample % array, using A + B * triangle wave
14
% plot it %%% hope you understood that, cos its all you get!!!
15
1A 1B 1C 2A 2B 2C
2. Include your paragraph on data acquisition. 3. Include your paragraph on deep memory.
16
17