LabVIEW (Laboratory Virtual Instrument Engineering Workbench) is an
engineering development environment based on graphical programming.
LabVIEW is widely used in writing measurement and automation applications in
many industries. This document describes a step-by-step procedure to use the
TekScope IVI-COM driver to write applications in LabVIEW.
Requirements
The following are required for using TekScope IVI-COM driver in LabVIEW:
TekVISA.
IVI shared components.
TekScope IVI-COM driver.
LabVIEW Version 6i or later.
Enabling the Custom COM Interface Support in LabVIEW 6i
To use custom COM interfaces in LabVIEW 6i, you need to modify an INI-file.
The INI-file, LabVIEW.ini, can be found in the directory where LabVIEW is
installed (by default C:\Program Files\National Instruments\LabVIEW 6\). Close
LabVIEW and open the file in Notepad. Add the following line at the end of the
file:
enableCustomInterface=True
Save and close the file.
Note that you do not have to edit the INI file for LabVIEW version 6.1 or later.
Get Familiar with Automation Palette and Functions
Figure 1 shows LabVIEW's function palette to work with ActiveX. It has four
functions (Automation Open, Automation Close, Automation, Invoke Node,
Property Node) that work with COM properties and methods, and two data
Used to set (writes) or get (reads) ActiveX
object property information.
Used to convert LabVIEW data types to
Variant data.
Used to convert Variant Data to data that can
be displayed or processed in LabVIEW.
Steps to Develop a Sample Virtual Instrument (VI)
Now we will use these LabVIEW functions to develop a sample VI, which will
connect to a Tektronix oscilloscope, acquire the waveform data from Channel 1,
and display it in a graph control. Follow the steps provided below to develop the
VI.
Step 1: Create a new VI
Create a new VI and in the VI function panel window, add a Waveform Graph
control and a String Control, as shown in Figure 2.
This will list all registered ActiveX classes. Select the IVI TekScope (Tektronix)
1.0 Type Library Version 1.0 class here.
The IVI TekScope (Tektronix) 1.0 Type Library Version 1.0 class will be listed
only if you have installed the Tektronix TekScope IVI-COM driver properly.
Step 4: Add an Invoke Node
Add an Invoke Node to the diagram. Wire the refnum out connection point of
Automation Open to the refnum in connection point of Invoke Node. Similarly
wire the error out connection point of Automation Open to the error in
connection point of Invoke Node.
Step 5: Call the driver Initialize function
Right-click on Invoke Node and from the menu select the Methods option and
then select the Initialize method. Once you select the Initialize method, the
Invoke Node will look like this:
Connect the ResourceName to the string control you created in step 1. For the
remaining three (IdQuery, Reset and OptionString) connection points, add
default constants by right clicking on each of them and selecting
Create|Constant.
Step 6: Add a Property Node
Add a Property Node to the diagram. Wire the refnum out connection point of
Invoke Node, as created in step 4, to the refnum in connection point of Property
Node. Similarly wire the error out connection point of Invoke Node, as created in step 4, to the error in connection point of Property Node.
Step 7: Select the WaveformTransfer property
Right-click on Property Node and from the menu select Properties and select
the WaveformTransfer property.
Add an Invoke Node to the diagram. Then wire the refnum out connection point
of the WaveformTransfer property node to the refnum in connection point of this
Invoke Node. Similarly, wire the error out connection point of the
WaveformTransfer property node to the error in connection point of this Invoke
Node.
Right-click on this Invoke Node. From the menu select Methods and select the
FetchWaveform method.
Provide an input Channel to the WaveformSource parameter by right clicking on
the WaveformSource and selecting Create|Constant menu.
Create data type for WaveformArray parameter as follows:
1. Add an Array Constant in the diagram from the Array palette.
2. Right-click on the Array element and numeric constant from Numeric
palette.
3. Right-click on the numeric constant, change the data type to double by
selecting DBL from Representation.
Create data types for InitialX and XIncrement, by right clicking and selecting the
Create|Constant menu.
Right-click on the Waveform Array Parameter of the FetchWaveform Method
and add a Variant to Data Function to the Diagram.
Add another Invoke Node to the Diagram.
Add an Automation Close Function node to the Diagram.