Sei sulla pagina 1di 6

M.E.

401 Mechatronics

Laboratory Four
Filtering and Pre-=iltering for Data
Acquisition
Required Materials
Hardware

Software

Lab P.C.

Labview

USB DAQ board (bonus)

Measurement and Automation


eXplorer (bonus)

Component bag: breadboard, 4.7 uF capacitor,


2kOhm resistor, 10 kOhm potentiometer, leads

Study Material
Course Text
LabVIEW Manual

Purpose

The purpose of this lab is to experiment with analog input and output channels in
LabVIEW and begin working with circuits and =ilters.

Introduction

One of the main uses for LabVIEW in industrial or academic settings is for data
acquisition. We will begin to explore this function by setting up two virtual
instruments. One that will produce an analog signal output, and one that will take
that signal as an input. Once these two instruments are functioning together we will
see how the signal is affected by the sampling rate and by =iltering with a basic RC
=ilter. We will use a Fourier Transform in the input VI to see how the component
frequencies of a constructed wave are cutoff by =iltering.

sampling rate and by filtering with a basic RC filter. We will use a Fourier Transform in
the input VI to see how the component frequencies of a constructed wave are cutoff by
filtering.
Concepts and components that need to be reviewed and understood before
Concepts
and tcomponents
that need to be reviewed and understood before beginning the
beginning
he lab:
lab: INPUT
OUTPUT
INPUT
OUTPUT
SAMPLING RATE
SAMPLING RATE
ALIASING
ALIASING
FOURIER TRANSFORM
FOURIER
TRANSFORM
FREQUENCY DDOMAIN
OMAIN
FREQUENCY
CAPACITOR
CAPACITOR
RESISTOR
RESISTOR
RC FILTER
FILTER
RC
LOW
PASS FFILTER
ILTER
LOW PASS
HIGH
PASS
FILTER
HIGH PASS FILTER

Part
1. Output
Part
1: Output
VI VI
1)
AX to toset
p aand
nd ttest
est aan
n aanalog
nalog output
output channel
channel
s you
did
n Lab
1. Use
UseM
MAX
setuup
asayou
did
in ilab
1
2)
Use
LabVIEW
to
create
a
VI
with
an
analog
output
channel.
This
will
your
2. Use LabVIEW to create a VI with an analog output channel. This will
bebe
your
signal
enerator. AAdd
dd a abasic
ignal pprocessing
rocessing
signal ggenerator.
basicfunction
functiongenerator
generator(under
(under ssignal
waveform
m
easurement).
Y
our
c
omplete
c
ircuit
s
hould
l
ook
l
ike
this.
waveform measurement). Your complete circuit should look like this.

Notes: Dont forget the constants for maximum and minimum voltage output. Make
Notes:
Dont forget the constants for maximum and minimum voltage output. Make sure
you selected
the type
correct
type of AO
output
AO Voltage.
Add controls
for type,
Signal
yousure
selected
the correct
of output
Voltage.
Add controls
for Signal
type, frequency,
amplitude,
and info.
sampling
nfo. #s
Make
sure of
#s samples)
(number
f samples)
frequency,
amplitude,
and sampling
Make isure
(number
isoset
to 1 and is
to 1 and
Fs (to
sampling
Fs set
(sampling
rate)
1850. rate) to 1850.
3) Test your output with your LED. With the settings shown you should see the
light changing from dark to light with the set frequency.

What effect do you see in the light when you change the amplitude?
Report 2 other values you tried and describe the results. Note that with
the offset wired to the amplitude control and the limit ranging from 0-5 V,
the maximum amplitude that you can go up to is 2.5 V. Over this value you
Zind an amplitude cutoff which may mislead you to interpret your results
wrongly.
What effect do you see in the light when you change the frequency?
Report 2 other values you tried and describe the results.

Part 2. Input VI
1) Remove the led and wire the output channel to the input channel. (If you are
using port AO0 for output and AI0 for input then wire as follows: 16 (GND)
wired to 3 (AI4), this is the negative side of the circuit; 14 (AO0) wired to 2
(AI0), this is the positive side of the circuit.

2) For this part we will use the DAQ assistant to create our input channel. This is a
quick tool you can use to accomplish much of what you did in part 1, however as
with most software wizards, your options will be limited compared to doing it
yourself from scratch. Create a new VI. The DAQ Assistant is found in several
places, one is under Measurement I/O NI-DAQmx. Once the assistant is
dropped on your block diagram it will bring up an options page to con=igure the
channel. Select Acquire Signals Analog Input Voltage. Select the channel you
are wired to on the DAQ and click Finished. Double check the wiring by selecting
the connection diagram tab near the top of the page. This will show you which
inputs you should be wired to for the channel you selected. You can also click run
to sample the channel and see if you have voltage in, however this check will be
affected by the state in which you left the output channel. Once you are satis=ied
click OK at the bottom and the channel will be created.

3) Add FFT Spectrum (Mag Phase) to analyze the component frequencies of your
wave. This is under Signal Processing Waveform Measurement. On the front
panel add a Waveform Chart and a Waveform Graph, these can be found under
Graph Indicators. Add controls for Rate and Number of Samples to your input
channel and make sure your connections are made. The =inal circuit should look
something like this.

4) The output VI (The VI you created previously is our output VI) will run continuously
on its own as long as the while loop condition is satisfied (Run the output VI). For the
new VI (input VI) click Run Continuously, this is next to run. If you have
everything hooked up and running you should see something on your chart and
graph. You will probably have to adjust the scaling on the waveforms to get a better
image of what is coming in. Run the input channel (new VI) for a moment and then
stop it. The waveforms will remain. Uncheck Autoscale X so that you can fix the
scale at something appropriate for the frequencies you are using. For frequencies of
10 or lower try clicking on the end time on the x-axis of the waveform chart and
changing the time to 1 second after the initial time. This shows a one second period
on the chart so you should see five full waves for a 5 Hz input. The graph should
show the component frequencies of the wave. For a sine wave you should see a
single defined peak at the input frequency. For square, or other wave types, you
should see the largest peak at the primary frequency followed by a series of
diminishing harmonics.
Print a screen shot of your input waveforms and report 2 frequencies you tried
outputting and what frequencies you are reading.
5) Now we will change the sampling rate on the input. We have two controls on the
input, sampling rate and the number of samples. Play around with the number of
samples. Try making it half as large as the rate, now double. In general for our
purposes it is best to keep it less than half of the rate so the waveforms will update at
least twice per second. More samples will give a better representation of the sampled
wave, but slow the time to refresh. The sampling rate determines the frequency of the
wave we can read. You must sample at least twice as fast as the wave you are reading
to get good data. Increase the output wave to 100 Hz. The default setting for the

sampling rate is 1000 (this is the sampling rate for the input circuit, make sure the
output circuit is still set to 1850), this would allow an accurate frequency
measurement to 500 Hz.
With a 100 Hz Sine wave output and input sampling rate of 1000 what
frequency are you reading on the input? Change the sampling rate to 500, 300,
and 200. Also note that you need to reduce the number of samples. Keep the
ratio of sampling rate to no. of samples to 1. Describe the effects for each setting.
Drop the sampling rate to 50 and report results. Describe the phenomena you
are seeing.

Part3. Filters
1) Set input sampling back to 1000, and output to 5 Hz square wave. Set the scale
on your graph so you can see the primary wave and the harmonics.
2) Using the electronic parts given add a low pass RC =ilter between the output and
input using the 2k resistor (red black red gold: color bands) and the
4.70uF capacitor. Following is a basic circuit diagram for a low pass RC =ilter.
Make sure you get the capacitor polarity correct (shorter negative and longer
positive). Note: This diagram shows the input and output from the perspective
of the =ilter. What the =ilter sees as output your input VI will see as input, and
what the output VI sees as output, the =ilter sees as input. Remember what
perspective you are using when thinking of input versus output. Part 2.1 showed
how to wire the output channel directly to the input channel. Now you will insert
the =ilter between the input and output (ex. Wires 14 and 16 are output from the
PCs perspective, but are input, or VIN, from the =ilters point of view).

Calculate the cutoff frequency with the 2k resistor. How did the waveforms
change in time and frequency domains?
3) Replace the =ixed resistor with the variable potentiometer.
Calculate the cutoff frequency with 10k potentiometer at full resistance
and lowest resistance (1 ).

Now set your primary wave to 2Hz. How does the waveform look now at

full, somewhere in the middle, and minimum resistance?


Now set your primary wave to 10 Hz. How does the waveform look now at
full, somewhere in the middle, and minimum resistance? How would you
compare this behavior to the case where your wave was at 2 Hz?
Plot front panel and block diagram for both parts.

BONUS (2 points): Create a band pass Zilter and show its pass/no-pass
characteristics by using the analog output to generate various frequencies and
measuring the response (essentially the same thing you did in the last
homework for the notch Zilter, but with real hardware and using LabView).

Potrebbero piacerti anche