Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
LabVIEW-Measurements.pdf
Скачиваний:
61
Добавлен:
29.05.2015
Размер:
3.37 Mб
Скачать

Chapter 20 VISA in LabVIEW

Writing a Simple VISA Application

For most simple instrument applications, only two VISA functions are needed: VISA Write and VISA Read.

The example shown in Figure 20-1 is very simple—just one VISA Write call and one VISA Read call. The instrument is specified using the VISA Resource Name Constant. The VISA Write function will check to see if a reference is already established with the specified instrument. If there is not an existing reference, a reference will automatically be opened. Then, the string MEAS:DC? is sent to the instrument. When reading from the instrument, you can simply wire the VISA Resource Name output from the VISA Write function to the VISA Read function to specify the desired instrument. You can then process and display the returned output from the VISA Read function as necessary for your measurement. The VISA Read is followed by the Simple Error Handler VI to process any errors that might have occurred with the VISA functions.

Figure 20-1. VISA Example

Using VISA Properties

VISA resources have a variety of properties (attributes) with values that can be read or set in a program. This section describes how to use VISA properties.

Using the Property Node

Property nodes are used to read or set the values of VISA properties.

The property node is shown in Figure 20-2.

Figure 20-2. Property Node

LabVIEW Measurements Manual

20-2

www.ni.com

Chapter 20 VISA in LabVIEW

Note The property node is a generic node that you also can use to set ActiveX and VI Server properties.

After placing the property node on the block diagram, wire a VISA Session to the reference input terminal of the property node.

The property node contains a single property terminal when it is initially placed on the block diagram. However, it can be resized to contain as many terminals as necessary. The initial terminal on the VISA property node is a read terminal. This means that the value of the property selected in that terminal will be read. This is indicated by the small arrow pointing to the right at the right edge of the terminal. Many terminals can be changed individually from a read terminal to a write terminal by right-clicking the property you wish to change.

Note Some properties are read only or write only. Their values cannot be set.

To select the property in each terminal of the property node, click on the property node terminal. This provides a list of all the possible properties that can be set in the program. The number of different properties shown under the Select Item choice of the VISA Property Node can be limited by changing the VISA Class of the property node.

To change the VISA class, right-click the VISA property node and select VISA Class. Several different classes can be selected under this option besides the default INSTR class which encompasses all possible VISA properties. These classes limit the properties displayed to those related to that selected class instead of all the VISA properties. Once a session is connected to the Session input terminal of the property node, the VISA Class is set to the class associated with that session.

Initially, the VISA properties will be somewhat unfamiliar. Refer to the LabVIEW Help, available by selecting Help»Contents and Index, for more information about the properties. Brief descriptions of individual properties are also available in the simple help window. To get a brief description of a specific property, select the property in one of the terminals of a property node and then open the Context Help window. The Context Help window is shown for the VXI LA property in Figure 20-3.

© National Instruments Corporation

20-3

LabVIEW Measurements Manual

Chapter 20 VISA in LabVIEW

Figure 20-3. VXI Logical Address Property

Note that the help window shows the specific variable type of the property and gives a brief description of what the property does. In cases where it is not clear what variable type to use for reading or writing a property, remember that right-clicking a property node and selecting Create Constant, Create Control, or Create Indicator from the shortcut menu automatically selects the appropriate variable type.

There are two basic types of VISA properties: global properties and local properties. Global properties are specific to a resource while local properties are specific to a session. For example, the VXI LA property is a global property. It applies to all of the sessions that are open to that resource. A local property is a property that can be different for individual sessions to a specific resource. An example of a local property is the timeout value. Some of the common properties for each resource type are shown in the following lists.

Serial

Serial Baud Rate—The baud rate for the serial port.

Serial Data Bits—The number of data bits used for serial transmissions.

Serial Parity—The parity used for serial transmissions.

Serial Stop Bits—The number of stop bits used for serial transmissions.

GPIB

GPIB Readdressing— Specifies if the device should be readdressed before every write operation.

GPIB Unaddressing—Specifies if the device should be unaddressed after read and write operations.

LabVIEW Measurements Manual

20-4

www.ni.com

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]