LABVIEW HANDOUT 4 CHAPTER 4: DATA ACQUISITION

Transcription

LABVIEW HANDOUT 4CHAPTER 4: DATA ACQUISITION USING DAQ ASSISTANTIn this exercise, you will be introduced to the data acquisition capabilities of LabVIEW. Usinghardware connected to the PC and the Measurement & Automation Explorer (MAX) within theLabVIEW programming environment, you will be able to acquire voltage data from an externalsource. The DAQ Assistant function will be shown to be an efficient way of quickly acquiringdata, although it is fairly limited in its capabilities. The importance of sampling frequency andthe aliasing effect will be demonstrated. Control of external devices will be shown by use ofanalog output terminals on the data acquisition board. The following concepts will explained:Dynamic Data, Error Outputs as Diagnostic Tools, the Use of Previously Saved VI’s andControls in new VI’s.

Open a Blank VI. Open the Measurement & Automation Explorer:Tools Measurement & Automation ExplorerIn the Configuration box, double-click on Devices and Interfaces tab. Double-click on NIDAQmx Devices. Click on NI PCI-6221: “Dev1”. Then click on Self-Test. If the device passesthe self-test, click OK.Attach wires to the AI0 (Analog Input Channel Zero) and AI8 connectors on the SCC-68 board.Attach the red wire from the Output Main Connector on the function generator to AI0 and theblack wire to AI8. Set the range to 10 Hz and the Function to a Sine Wave. Turn the Frequencyknob counterclockwise as far as it will go. Turn on the function generator. Press the Test Panelsbutton. Select Analog Input Dev1/ai0 and press Start to see the acquired sine wave.

Press Stop to turn off the data acquisition. Switch to the block diagram. Place a DAQ AssistantIcon on the Block Diagram:Functions Express Input DAQ Assistant

When the DAQ Assistant is placed on the Block Diagram, a dialog window called Create NewExpress Task will appear. Click the following:Acquire Signals Analog Input Voltage

On the next screen, left-click on ai0 Finish:

Analog Input Channel 0 is now programmed to receive external voltage signals. On the DAQAssistant screen:Configuration Acquisition Mode 1 Sample (On Demand)Select Display Type Chart, then click the Run button to see the sine wave.

Press Stop and then OK to exit out of the DAQ Assistant screen. Expand the DAQ Assistanticon by pulling the bottom edge downward.Wire indicators to the data output and the error output as shown below by:

Right-Click Create IndicatorThe thick blue wire indicates that dynamic data comes from the DAQ Assistant. The dynamicdata type has the actual data, a time/date stamp, and also the name of the data stream. Notice theRed Coercion Dot appears on the input of the data indicator. This can be eliminated by insertinga conversion icon:Functions Express Signal Manipulation Convert From Dynamic DataWhen the Convert From Dynamic Data icon is placed on the Block Diagram, a windowappears that allows the user to determine what type of conversion takes place. Select SingleScalar/Floating Point Numbers/Double Precision.

Surround the icons on the Block Diagram with a While Loop and place a Wait (ms) on theBlock Diagram as shown below. Run the VI to verify that the sine wave is output to the FrontPanel. Save this VI as DC Voltmeter (Express).Save a copy of this VI to Digital Oscilloscope (Express). Delete the Convert From DynamicData icon and the Numeric Indicator on the data output. Place a Waveform Graph on theFront Panel and wire it to the data output of the DAQ Assistant. Notice that the Waveform

Graph automatically turns blue, indicating that it will graph the dynamic data from the DAQAssistant. Delete the Timing icon and its Numeric Constant.Double-Click on the DAQ Assistant and change the setting to:Configuration Acquisition Mode N Samples OK

Place the Digitizing Parameters Control onto the Front Panel as follows:Controls Select a Control Browse Digitizing Parameters.ctl

Place an Unbundle By Name icon onto the Block Diagram:Functions Programming Cluster, Class, & Variant Unbundle By Name

When the Unbundle By Name icon is wired to the Digitizing Parameters Control, it willautomatically show one of the controls, as shown below:Expand the Unbundle By Name icon by pulling down the bottom edge:Change the terminal ordering by right-clicking on the top terminal and choosing:Right-Click Select Input/Output Number of SamplesWire the Stop button as shown below. Change the frequency of the sine wave signal comingfrom the frequency generator to around 100 Hz, and run the VI with the following DigitizingParameters Control settings:

Notice that the signal travels across the screen. To eliminate this, double-click on the DAQAssistant. In the dialog window:Triggering Trigger Type Digital Edge

Choose the Trigger Source as PFI0 (Programmable Function Interface Zero) and press OK.Place another set of breadboard wires onto connector 11 and connector 12 on the SCC-68 DAQBoard. Obtain another black double-wire set for the function generator and connect it to theOutput Sync connector. Connect the red wire from the Output Sync connector on thefunction generator to connector 11 and the black wire to connector 12. Run the VI. Now thetrace is locked to the left-hand top of the sine wave. Vary the function generator frequency untilexactly three cycles appear on the Waveform Graph and note the frequency. Change thefunction generator frequency to the 1K range. Increase the frequency and note the frequencyeach time the graph shows exactly three cycles on the Waveform Graph. How do these valuescompare to those predicted by the Aliasing Condition?Open a new VI and create the following Block Diagram. This VI will output a voltage from theSCC-68.When the DAQ Assistant icon is placed on the Block Diagram, the Create New Express Taskwindow appears. Input the following:Generate Signals Analog Output Voltage ao0 FinishMake the following selections in the DAQ Assistant dialog window:

Run the VI. Use a voltmeter to measure the output from connectors 22 and 54 on the SCC-68.The value should correspond to the voltage requested by the VI. Save this VI as DC VoltageSource (Express). Modify the VI so that it will stop when an error occurs as shown below.Verify that the VI operates correctly by inputting a desired value of voltage outside of the rangegiven in the DAQ Assistant dialog window.

Open a new VI. Save it as Waveform Generator (Express). Place the previously constructedWaveform Simulator VI onto the Block Diagram:

Place the previously constructed controls Digitizing Parameters and Waveform Parametersonto the Block Diagram by hovering the cursor over one of the inputs of the WaveformSimulator VI and:Right-Click Create ControlWhen placing the DAQ Assistant, select the following on the pop-up window:Generate Signals Analog Output Voltage ao0 Finish

Run the VI with the following parameters. The sine wave is now being output to Analog OutputChannel ao0.

LABVIEW HANDOUT 4 CHAPTER 4: DATA ACQUISITION USING DAQ ASSISTANT In this exercise, you will be introduced to the data acquisition capabilities of LabVIEW. Using hardware connected to the PC and the Measurement & Automation Explorer (MAX) within the LabVIEW programming environment, you will