0% found this document useful (0 votes)
43 views

Analog in Put

Uploaded by

hjuiop
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

Analog in Put

Uploaded by

hjuiop
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Lesson 9

Data Acquisition and Waveforms

C. Analog Input
Use analog input to perform analog-to-digital (A/D) conversions. The available analog input measurement types for a task are voltage, temperature, strain, current, resistance, or frequency.

Each measurement type has its own characteristics, such as resistor values for current measurements or strain gauge parameters for strain measurements.

Task Timing
When performing analog input, the task can be timed to Acquire 1 Sample, Acquire n Samples, or Acquire Continuously.

Acquire 1 Sample
Acquiring a single sample is an on-demand operation. In other words, NI-DAQmx acquires one value from an input channel and immediately returns the value. This operation does not require any buffering or hardware timing. For example, if you periodically monitor the fluid level in a tank, you would acquire single data points. You can connect the transducer that produces a voltage representing the fluid level to a single channel on the measurement device and initiate a single-channel, single-point acquisition when you want to know the fluid level.

National Instruments Corporation

9-13

LabVIEW Introduction Course Manual

Lesson 9

Data Acquisition and Waveforms

Acquire n Samples
One way to acquire multiple samples for one or more channels is to acquire single samples in a repetitive manner. However, acquiring a single data sample on one or more channels over and over is inefficient and time consuming. Moreover, you do not have accurate control over the time between each sample or channel. Instead you can use hardware timing, which uses a buffer in computer memory, to acquire data more efficiently. Programmatically, you need to include the timing function and specify the sample rate and the sample mode (finite). As with other functions, you can acquire multiple samples for a single channel or multiple channels. With NI-DAQmx, you also can gather data from multiple channels. For instance, you might want to monitor both the fluid level in the tank and the temperature. In such a case, you need two transducers connected to two channels on the device.

Acquire Continuously
If you want to view, process, or log a subset of the samples as they are acquired, you need to continually acquire samples. For these types of applications, set the sample mode to continuous.

Task Triggering
When a device controlled by NI-DAQmx does something, it performs an action. Two very common actions are producing a sample and starting a waveform acquisition. Every NI-DAQmx action needs a stimulus or cause. When the stimulus occurs, the action is performed. Causes for actions are called triggers. The start trigger starts the acquisition. The reference trigger establishes the reference point in a set of input samples. Data acquired up to the reference point is pretrigger data. Data acquired after the reference point is posttrigger data.

LabVIEW Introduction Course Manual

9-14

ni.com

Lesson 9

Data Acquisition and Waveforms

Exercise 9-2
Objective:

Voltmeter VI
Complete the following steps to build a VI that measures the voltage that the temperature sensor on the DAQ Signal Accessory outputs. The temperature sensor outputs a voltage proportional to the temperature. The sensor is hard-wired to channel 0 of the DAQ device.

To acquire an analog signal using a DAQ device.

Front Panel
1. Open a blank VI and build the following front panel.

a. Place the Meter, located on the ControlsNumeric Indicators palette, on the front panel. Configure the meter scale for 0.0 to 0.4. Use the Labeling tool to double-click 10.0 and type 0.4. You might need to enlarge the meter to display the scale as shown in the example. b. Place a Vertical Toggle Switch, located on the ControlsButtons & Switches palette, on the front panel. Configure the toggle switch to a default value of False and a mechanical action of Latch When Pressed. c. Create two free labels, Off and On, using the Labeling tool.

Block Diagram
2. Build the following block diagram.

National Instruments Corporation

9-15

LabVIEW Introduction Course Manual

Lesson 9

Data Acquisition and Waveforms

a. Place the DAQ Assistant Express VI located on the Functions Input palette, on the block diagram. Configure this VI to read an analog input channel and return the voltage. Select Analog InputVoltage for the measurement to make. Select Dev1ai0 for the physical channel. Click the Finish button. The Analog Input Voltage Task dialog box appears. Configure the Task Timing to Acquire 1 Sample. Click the OK button to close the Analog Input Voltage Task Configuration dialog box. This saves the settings specified for the task in the DAQ Assistant Express VI.

b. Place the Wait Until Next ms Multiple function, located on the FunctionsAll FunctionsTime & Dialog palette, on the block diagram. Right-click the input and select Create Constant from the shortcut menu. Type 100 in the constant to cause the loop to execute every 100 ms. c. Place the Unbundle by Name function, located on the Functions All FunctionsCluster palette, on the block diagram. Use this function to access the status from the error cluster. d. Place the Or function, located on the FunctionsArithmetic & ComparisonExpress Boolean palette, on the block diagram. This function stops the loop if an error occurs or the user clicks the power switch on the front panel. 3. Save the VI as Voltmeter.vi in the C:\Exercises\LabVIEW Basics I directory. You will use this VI later in the course. 4. Display the front panel and run the VI. The meter displays the voltage the temperature sensor outputs. Place your finger on the temperature sensor and notice that the voltage increases. 5. Stop the VI by clicking the power switch.

Scales
The temperature sensor on the DAQ Signal Accessory outputs the voltage in degrees Celsius, scaled by 100. In order to convert the voltage into degrees Celsius, it is necessary to multiply the voltage by 100. You could multiply the output of the DAQ Assistant Express VI by 100, or configure the DAQ Assistant Express VI to automatically scale the voltage. Using the capabilities that exist within the VI reduces block diagram clutter. 6. Double-click the DAQ Assistant to display the Analog Input Voltage Task Configuration dialog box. 7. Select Create New in the Custom Scaling pull-down menu.

LabVIEW Introduction Course Manual

9-16

ni.com

Lesson 9

Data Acquisition and Waveforms

8. Select Linear and name the scale temperature. Click the Finish button. 9. A dialog box appears where you can scale the data by a multiplier and an offset. a. Set the slope to 100 and the Scaled Units to Celsius. b. Click the OK button to close the dialog box. 10. In the Analog Input Voltage Task Configuration dialog box, set the minimum input range to 0, set the maximum input range to 100, and click the OK button to return to the block diagram. 11. Run the VI. The temperature displays in the meter. The temperature values are 100 times greater than the voltage values. Change the meter scale to see the correct values. 12. Stop the VI. Save the VI but do not close it. You will use the VI in Exercise 9-3.

End of Exercise 9-2

National Instruments Corporation

9-17

LabVIEW Introduction Course Manual

You might also like