Signal Generation Using NI-DAQmx

advertisement
Signal Generation Using NI-DAQmx
Wei Lin
Department of Biomedical Engineering
Stony Brook University
Instructor’s Portion
Summary
This experiment requires the student to use NI-DAQmx to generate
analogy voltage signals of sinusoidal, triangle, square wave and user
defined wave. Students should be familiar with the following LabVIEW
programming technique
1.
2.
3.
4.
NI-DAQmx
LabVIEW application for analog signal generation
LabVIEW “Simulate Signal” express VI
LabVIEW “Simulated ECG Signal” Express VI
Uses
This lecture applies to all courses of bioinstrumentation.
Equipment List

Computers

LabVIEW 8.6

NI-ELVIS benchtop workstation

LabVIEW 8.6 Student Edition
References
Student’s Portion
Introduction
The students should learn the basic LabVIEW programming techniques
for the signal generation using NI-DAQmx. They will create one VI for
1
the generation of a continuous function waveform such as a sinusoidal
signal. Students will use VIs developed in the project “Data Acquisition
Using NI-DAQmx” to verify the signals generated.
Objectives



NI-DAQmx
Analog signal generation using NI-DAQmx
LabVIEW graph and chart
Theory
NI-DAQmx is the next generation drivers for the data acquisition hardware
from National Instruments. It is easy to use and has many new features such
as improved ease of use, faster development time, multithreaded
measurements and increased accuracy of measurements. NI-DAQmx can also
be used to generate analog signals if the data acquisition hardware has the
analog output capability. The signal generation application is as
straightforward as the data acquisition application. The following are the steps
for creating such an application.
1. Create a virtual channel and task using the NI-DAQmx Create
Virtual Channel VI. Select Analog output and than voltage.
2. Create the waveform data for the analog signal generation. You
can use signal simulation VI to create the waveform. You must set
the sample rate and number of samples correct to ensure the
waveform generated is one or multiple cycles. (why?)
3. Set the sampling frequency and sampling mode, usually the
continuous samples using NI-DAQmx Timing VI (select “Use
waveform” as timing setting).
4. Write the waveform data to DAQ device using DAQmx write VI
(Analog Waveform, 1Chan NSamp)
5. Start the signal generation process using NI-DAQmx Start VI.
6. Create a while loop and using “DAQmx is done” VI to check the
device status
7. Clear the signal generation task using the NI-DAQmx Clear VI.
All the NI-DAQmx VIs are linked through task in and task out terminal and
the error cluster chain.
Lab Procedure
Experiment 1, Create a LabVIEW signal generation application of
function generator:
1. Launch LabVIEW.
2. Create a blank VI.
3. The front panel should have the following controls
2
a. DAQmx physical channel control
b. Numerical control for amplitude
c. Numerical control for frequency.
4. Drop the “NI-DAQmx Create Virtual Channel VI in
Measurement I/O->NI-DAQmx” to the block diagram and
choose “Analog output-> voltage”. Connect DAQmx physical
channel control to its physical channels terminal.
5. Drop the “Simulate Signal express VI in Express Input” to the
block diagram and
a. Configure the signal type as sine wave.
b. In timing section:
i. Set samples per second as 1000Hz
ii. Number of samples 10000. Please uncheck the
automatic check box
iii. Check the “Integer number of samples” check box.
c. Connect the amplitude control to Amplitude terminal
d. Connect the frequency control to Frequency terminal
e. Drop convert dynamic data type VI (Express->Signal
Manipulation->from DDT) and select conversion type as
single waveform. Connect the sine to its input terminal.
6. Drop the “NI-DAQmx timing VI in Measurement I/O->NIDAQmx” to the block diagram and choose “Use Waveform
(Analog output)” which will determine the sampling frequency
based on the input waveform. Connect waveform from the convert
dynamic data type VI to the waveform terminal. Right click the
“sample mode” terminal and choose create constant. Select
“continuous samples”. This configures the continuous generation
mood.
7. Drop the “NI-DAQmx write VI in Measurement I/O->NIDAQmx” to the block diagram. Select “analog->single channel>multiple samples->waveform (Analog Wfm 1Cha NSamp)” and
connect the waveform data to the terminal “data”.
8. Drop the “NI-DAQmx Start VI in Measurement I/O->NIDAQmx” to the block diagram.
9. Create a while loop and set up shift registers for both task and error
cluster from the NI-DAQmx start VI. Add a wait VI (in Timing)
and connect 200 to its input. Right click the conditional terminal
and create a control named stop. Extract the error status using the
“unbundled cluster by name” function in Cluster and variants.
The output from this function should be OR’ed with the signal
from the stop button inside the loop. This can control the
application to stop if any error occurs during the generation of the
signal.
10. Connect the NI-DAQmx VIs through “task in” and “task out”
terminals and error cluster input and output terminals. At the error
output of “NI-DAQmx Is Task Done” VI extract the error status
3
using the “unbundled cluster by name” function. The output from
this function should be ORed with the signal from the stop button
inside the loop. This can control the application to stop if any error
occurs during the generation of the signal.
11. Drop the “NI-DAQmx Clear VI” to the block diagram outside of
the while loop.
12. Drop a “Simple Error Handler VI in Dialog and user interface” to
the block diagram and connect the error output of the “NI-DAQmx
Clear VI” to it.
13. Keep the ELVIS unit off. Connect the output of function generator
“DAC0” to “ACH0+” using connection wires on the prototype
board.
14. Enter the following values to the controls
a. Frequency: 5Hz (Always choose a value less than 10Hz
because some DAQ card cannot handle frequency higher
than 10Hz)
b. Amplitude: 1V
c. Physical channel: first right click the control and select IO
naming filtering. Select I/O type as output and click OK.
You can now select Dev1/ao0.
15. Launch your data acquisition VI. Run both data acquisition VI and
signal generation VI. You should be able to collect the generated
signal.
16. Run tests using different amplitude (less than 5V) and frequency
(less than 10 Hz)
Experiment 2, Create a LabVIEW signal generation application of
ECG generator:
1. Save a copy of the previous VI and rename it.
2. Delete the “Simulate Signal express VI”.
3. Replace it with “Simulate ECG Signal express VI”. Function
palette->User Libraries->Biomedical Startup Kit->DAQ & SIm>Simulate ECG Signal.
a. You can select heart rate (BPM) and add noise by double
click the express VI
4. Connect output “Data” at the “Simulate ECG Signal express
VI” to the input of “convert dynamic data type VI”
5. Launch your data acquisition VI. Run both data acquisition VI and
signal generation VI. You should be able to collect the generated
ECG signal.
Experiment 3 (Optional), Create a LabVIEW signal generation
application of ECG generator using real ECG data:
1. Save a copy of the previous VI and rename it.
4
2. Delete the “Simulate ECG Signal express VI”.
3. Replace the “Simulate ECG Signal express VI” in the previous
VI to “Read Meas File express VI”. Function palette->Express>Read Meas File
4. Select File Format as Binary (TDMS).
5. Check Action “Ask user to choose file”.
6. Connect output “Signals” at the “Read Meas File express VI” to
the input of “convert dynamic data type VI”
7. Launch your data acquisition VI. Run both data acquisition VI and
signal generation VI. Select the ECG data file as
z:\bme313\105.tdms. You should be able to collect the generated
ECG signal.
Lab Report
1. Project objective.
2. Explain the function of the DAQms VIs used in the signal
generation VI.
3. Compare the signal generation VI with the data acquisition VI and
explain the similarities and difference.
4. What is the difference between the samples per second in step 5
and the sampling frequency in the data acquisition VI?
5. Acquired analog output signals
6. VI with documentation and modified icon.
7. Due on 10/28/2009
Appendix:
5
Front Panel
Block Diagram
6
Download