Summary: In this exercise, the objective is to build a VI that uses the DevSim instrument driver VIs to acquire and plot voltages. Complete the following steps to build a VI that acquires a DC voltage measurement from the NI Instrument Simulator once every second and plots it in a waveform chart until you click a button. As each value is acquired, the VI compares it with the previous minimum and maximum values. The VI calculates and displays the minimum and maximum values continuously on the front panel.
Front Panel
- Select
File>>New
, then selectTemplate>>Frameworks>>Single Loop Application
to open theSingle Loop Application template
VI. - Build the front panel shown in Figure 1.Use the following guidelines to help you construct the front panel.
Figure 1 - Place a VISA resource name control, located on the
Controls>>All Controls>>I/O
palette, on the front panel. - Set the x-axis scale of the waveform chart to show incremental values.
- Place a VISA resource name control, located on the
Block Diagram
- Build the block diagram shown in Figure 2.
Figure 2 - Create two shift registers by right-clicking the right or left border of the loop and selecting
Add Shift Register
from the shortcut menu. - Place the
NI DEVSIM Initialize
VI, located on theFunctions>>Input>>Instrument Drivers>>NI Device Simulator
palette, on the block diagram. This VI opens communication between LabVIEW and the NI Instrument Simulator.- Right-click the
ID Query
input and selectCreate>>Constant
from the shortcut menu. Use theOperating
tool to change the constant to aFalse
value. - Wire the Boolean constant to the
Reset
input.
- Right-click the
- Place the
NI DEVSIM Multimeter Configuration
VI, located on theFunctions>>Input>>Instrument Drivers>>NI Device Simulator>>Configuration
palette, on the block diagram. This VI configures the range of voltage measurements that the NI Instrument Simulator generates. The default is 0.0 to 10.0 V DC. - Place the
NI DEVSIM Measure DC Voltage
VI, located on theFunctions>>Input>>Instrument Drivers>>NI Device Simulator>>Data
palette, on the block diagram. This VI returns a simulated voltage measurement from the NI Instrument Simulator. - Place the
NI DEVSIM Close
VI, located on theFunctions>>Input>>Instrument Drivers>>NI Device Simulator
palette, on the block diagram. This VI ends communication between LabVIEW and the NI Instrument Simulator. - Place the
Max & Min
function, located on theFunctions>>All Functions>>Comparison
palette, on the block diagram. Use two of these functions to check the current voltage against the minimum and maximum values stored in the shift registers. - Place the
Simple Error Handler
VI, located on theFunctions>>All Functions>>Time & Dialog
palette, on the block diagram. This VI displays a dialog box if an error occurs and displays the error information. - Place the
Unbundle by Name
function, located on theFunctions>>All Functions>>Cluster
palette, on the block diagram. This function accepts status from the error cluster. - Place the
Or
function, located on theFunctions>>Arithmetic & Comparison>>Express Boolean
palette, on the block diagram. This function controls when theWhile Loop
ends. If there is an error or you click theStop
button, theWhile Loop
stops. - Set the wait for the
Time Delay
Express VI to 1 second. - Wire the block diagram as shown in Figure 2.
NOTE:
You do not need to wire every terminal for each node. Wire only the necessary inputs for each node, such as instrument descriptor, VISA session, and error I/O.
- Create two shift registers by right-clicking the right or left border of the loop and selecting
- Save the VI as
Voltage Monitor.vi
in theC:\Exercises\LabVIEW Basics I
directory. - Make sure the NI Instrument Simulator is powered on.
- Display the front panel and run the VI. The LEDs alternate between Listen and Talk as LabVIEW communicates with the GPIB instrument once a second to get a simulated voltage reading. This voltage displays on the chart, and the minimum and maximum values update accordingly.
- Stop and close the VI.
No comments:
Post a Comment