Easy Transfer Function Measurements with LabVIEW 6i

advertisement
Easy Transfer Function Measurements with LabVIEW 6i
(Lab Skill Exercise X-1)
To exploit fully the potential for computer-based measurements offered by
LabVIEW 6i, you need to use your computer and its installed DAQ board for three tasks:
1. Supplying the test signals used for input (analog output, abbreviated AO).
2. Acquiring and storing the measured input and output signals from the circuit
(analog input, abbreviated AI), and
3. Computing desired results from the measured data, such as the circuit’s transfer
function, H(w) in this example.
One important additional specification: the computer must perform the AO and AI
simultaneously in order for the measurement to be meaningful.
In the LabVIEW library found at LabVIEW\examples\daq\anlog_io, there is a set of
ready-made VI’s you can use for this purpose. Choose the Simul AI/AO Buffer (xxx)
VI appropriate for your DAQ board and open it. You will see a front panel that looks
like Fig. 1.
Fig. 1. Front panel
1
The following paragraph summarized this VI’s operation. Look for the bold-face
words in this paragraph on the Fig. 1 front panel:
This VI will perform (nearly) simultaneous AO and AI. It calculates sample
values for an output waveform and stores them in an output buffer of assigned size. The
DAQ board outputs the sequence of voltages in the output buffer at the assigned update
rate. At essentially the same time, the DAQ board acquires samples by scanning each of
the assigned input channels at the assigned scan rate. It writes these sample values into
an input buffer of assigned size, and successively plots snapshots of the acquired
waveforms on the acquired data waveform graph. The number of samples used to plot
each of the waveforms is the number of scans to read at a time.
If all you want to do is measure input and output voltages as functions of time,
you can run this VI as is, just setting the scan and update rates appropriately. If your
circuit under test were a series RC circuit with the output taken across the capacitor, your
wiring diagram for the measurement would look like Fig. 2.
Fig. 2. Wiring diagram for input and output measurements using a DAQ board.
The front panel after such a measurement looks like Fig. 3. Note how the capacitor
voltage charges up and down exponentially, as expected for this circuit.
2
Fig. 3. Using the Simul AIAO VI as an oscilloscope to compare input and output
waveforms for a series RC circuit like the one in Fig. 2.
So far, all you can do with this VI is measure input and output signals from a
circuit, Tasks 1 and 2 of the three set forth at the beginning of this document. And you
can only do that for a limited set of input functions, the sine wave, square wave, sawtooth
and triangle waves available at the signal type control on the front panel in Fig. 3. In
order to measure the transfer function of a circuit, the goal of this exercise, you will need
to perform Task 3 also, which will involve calculating the transfer function magnitude
and phase from the measured input and output waveforms.
Circuit theory gives the transfer function in terms of the input and output as
functions of time as follows:
Á{vout (t )} Vout (w )
, where the operation, Á{v(t )} , is the complex one-sided
H (w ) =
=
Á{vin (t )} Vin (w )
Fourier transform of the time signal, v(t). LabVIEW 6i includes a VI called
FrequencyResponseFunction (Mag-Phase).vi that performs this calculation on a
measured pair of waveforms. It will also take an average over many measurements, if
desired. You can find this VI in the Functions Pallette of LabVIEW under Analyze ->
Waveform Measurements.
3
You do not have to modify the the Simul AI/AO Buffer (xxx).vi much in order to
measure transfer functions. First, open its Diagram. It will look like Fig. 4.
Fig. 4. The Simultaneous AOAI VI diagram.
There are two modifications to be made, in the locations shown:
1. Add a transfer function calculation inside the While Loop (gray-outlined
rectangle at right), and
2. Modify the Compute Waveform.vi at the lower left to include a
broadband noise input.
Figure 5, below, shows how to make the first modification.
4
Fig. 5. Modification 1: incorporating the transfer function calculation using the
FrequencyResponseFunction(Mag-Phase).vi. (Orange arrow)
A brief summary of how you build this VI follows:
1. Create two waveform graphs on the front panel: name one Magnitude and
the other Phase.
2. Use two Index Array.vi’s to separate the two acquired signals: the output
(Column 0) and the input (Column 1).
3. Use two BuildWaveform.vi’s to make these columns of data into
waveforms.
4. Drop a FrequencyResponseFunction(Mag-Phase).vi. into the diagram
and wire the two waveforms to its X and Y terminals. You can right-click
on this VI, select Help, and get a short description of how it works.
5. Wire the Magnitude and Phase outputs of the
FrequencyResponseFunction(Mag-Phase).vi to the waveform graphs of
the same names.
6. Right-click on each of the other inputs to the
FrequencyResponseFunction(Mag-Phase).vi and choose Create Control.
This will automatically produce the correct controls on the front panel.
The next step is to modify the ComputeWaveform.vi to include a noise waveform. If
you double-click on the ComputeWaveform.vi where you see it within the diagram for
5
the Simultaneous AOAI VI, you will see the diagram below in Fig.6.
Fig. 6. The ComputeWaveform.vi diagram, showing the case structure to be
modified.
Right-click on the case structure and add a case after case 3 as shown below in Fig. 7.
Fig. 7. New Case 4 containing a UniformWhiteNoise.vi.
Note that you need to re-label the cases so that the new last case has dots after it (4..) and
the old last case has no dots (3). Name your modified VI ComputeWaveform(1).vi, and
replace the old ComputeWaveform.vi with the new one in the diagram of your main VI.
You will also need to delete the signal type control on the front panel of the main VI, and
then go back to the diagram and place the wiring tool on the signal type input of the new
ComputeWaveform(1).vi , then choose Create Control. This will create a new control
on the front panel that has all of the waveform options available.
6
If you’ve done the above steps correctly, you should be ready to measure a transfer
function.
Fig. 7. Front Panel of the Transfer Function measuring VI, showing results for an
RC low-pass filter like the circuit in Fig. 2.
In Fig. 7, the X-scales of the two waveform graphs named magnitude and phase, were
switched to logarithmic mapping. You can make these changes by right-clicking on the
graphs. The view control switches (lower center of the front panel) were set to display
magnitude on a dB scale, and to display the phase in degrees. The averaging parameters
switches control how the averages over multiple measurements are calculated.
Since the network whose transfer function was measured is the one in Fig. 2, we
would expect that a Bode plot of its transfer function magnitude would be flat near zero
dB out to some cutoff frequency, and then roll off at a constant slope (in dB/decade)
above the cutoff frequency. This is exactly what appears in the magnitude graph. We
would also expect the phase shift for this network to be zero at low frequency, and
decrease toward –90o at high frequencies. The measured results agree with this
theoretical expectation up to a few hundred Hz of frequency, and then seem to diverge.
The fundamental cause of this disagreement between theory and experiment in the
phase measurements can be found in the magnitude measurements. Notice that, at the
higher frequencies, the magnitude has dropped by at least 20 dB. This means that the
phase of the (very small) output voltages at these higher frequencies is strongly affected
7
by any noise in the measuring circuitry. You can see this noise better if you run a
measurement with the averaging mode control set to no averaging.
Supplementary Lab Skill Exercise X-1: (Print this part and turn it in)
1. (10%) Put together an RC circuit like the one in Fig. 2 on your proto-board. Wire it to
the AO and AI channels of the DAQ interface as in Fig. 2.
2. (10%) From the values you chose for R and C, calculate the time-constant of your
circuit. Show your calculation and answer here:
3. (20%) Open the Simul AI/AO Buffer (xxx).vi , and use it to measure the time
response of your circuit to a square wave. Print out a front panel showing your results
and attach it here:
8
4. (20%) Modify the ComputeWaveform.vi in the Simul AI/AO Buffer (xxx).vi
diagram so that it lets you supply a noise waveform as described above. Run your VI
with noise selected as the waveform. Your front panel should look like this. Attach a
printout of your front panel over this one.
5. Modify the Simul AI/AO Buffer (xxx).vi to measure transfer functions as described
above. Measure the transfer function of your RC circuit up to at least 5000 Hz. Set the
number of averages al low as you can consistent with accurate results.
9
a) (20%) print out a copy of the diagram of your VI and attach it here.
10
b) (20%) Print out a front panel showing the results of your measurements and attach it
here. If you were unable to make your own transfer function measuring VI to use, you
may use the one provided on the lab computer system, but you will not get the 20% for
part 5a).
11
Download