manual, programmer`s, vtex scanner driver

Transcription

manual, programmer`s, vtex scanner driver
VTEXSCANNER
DRIVER
PROGRAMMER’S MANUAL
P/N: 82-0128-000
Released July 22, 2010
VTI Instruments, Corp.
2031 Main Street
Irvine, CA 92614-6509
(949) 955-1894
VTI Instruments Corp.
TABLE OF CONTENTS
INTRODUCTION
TABLE OF CONTENTS ................................................................................................................................................ 2
Certification .......................................................................................................................................................... 4
Warranty ............................................................................................................................................................... 4
Limitation of Warranty ......................................................................................................................................... 4
Restricted Rights Legend ...................................................................................................................................... 4
SUPPORT RESOURCES ............................................................................................................................................... 5
SECTION 1.................................................................................................................................................................... 7
INTRODUCTION ......................................................................................................................................................... 7
Background........................................................................................................................................................... 7
Glossary ................................................................................................................................................................ 7
Basic Concepts ..................................................................................................................................................... 7
Option Strings ....................................................................................................................................................... 8
SECTION 2.................................................................................................................................................................... 9
THE SCANNER MODEL .............................................................................................................................................. 9
Overview .............................................................................................................................................................. 9
Scanner Theory ..................................................................................................................................................... 9
Scanlist Syntax ................................................................................................................................................... 10
The Trigger Model.............................................................................................................................................. 11
SECTION 3.................................................................................................................................................................. 13
PROGRAMMING EXAMPLES..................................................................................................................................... 13
Introduction ........................................................................................................................................................ 13
Basic Programming Examples ............................................................................................................................ 13
Initialization .................................................................................................................................................. 13
Basic Sampling .............................................................................................................................................. 14
Arming the Scanner ....................................................................................................................................... 15
Triggering the Scanner .................................................................................................................................. 16
DMM Configurations .................................................................................................................................... 16
Scanlists......................................................................................................................................................... 16
Advanced Sampling ...................................................................................................................................... 17
Advanced Programming ..................................................................................................................................... 17
Setup Steps .................................................................................................................................................... 17
Discharging a Multiplexer ............................................................................................................................. 18
Output Events ................................................................................................................................................ 18
Scanning Example ......................................................................................................................................... 18
SECTION 4.................................................................................................................................................................. 23
APPLICATION NOTES .............................................................................................................................................. 23
Purpose ............................................................................................................................................................... 23
Product Overview ............................................................................................................................................... 23
EX1200 for Data Acquisition ............................................................................................................................. 23
Recommended Equipment ............................................................................................................................ 24
Making Sure the Required Software is Installed ........................................................................................... 24
Setting the EX1200 as a Scanner ........................................................................................................................ 28
Using the Web Page ...................................................................................................................................... 28
Using IVI-COM (C#) .................................................................................................................................... 29
Using IVI-C ................................................................................................................................................... 30
Setting Up DMM Configurations ....................................................................................................................... 30
Hardware Setup ............................................................................................................................................. 30
Using the Web Page ...................................................................................................................................... 30
Using IVI-COM ............................................................................................................................................ 31
Using IVI-C ................................................................................................................................................... 32
2
VTEXScanner Driver Preface
www.vtiinstruments.com
Setting Up the Scanlist........................................................................................................................................ 32
Using the Web Page ...................................................................................................................................... 33
Using IVI-COM ............................................................................................................................................ 34
Using IVI-C ................................................................................................................................................... 34
Setting up Triggering .......................................................................................................................................... 35
Common Trigger Configurations .................................................................................................................. 35
Using the Web Page ...................................................................................................................................... 35
Using IVI-COM ............................................................................................................................................ 36
Using IVI-C ................................................................................................................................................... 36
Starting the Scan and Retrieving Data ................................................................................................................ 37
Using the Web Page ...................................................................................................................................... 37
Exporting Data to a .CSV File ............................................................................................................................ 38
Using IVI-COM ............................................................................................................................................ 38
Using IVI-C ................................................................................................................................................... 38
APPENDIX A: IVI-COM SOURCE LISTING .............................................................................................................. 40
APPENDIX B: IVI-C SOURCE LISTING ..................................................................................................................... 42
VTEXScanner Driver Preface
3
VTI Instruments Corp.
CERTIFICATION
VTI Instruments, Corp. (VTI) certifies that this product met its published specifications at the time of shipment from
the factory.
WARRANTY
The product referred to herein is warranted against defects in material and workmanship for a period of one year
from the receipt date of the product at customer’s facility. The sole and exclusive remedy for breach of any warranty
concerning these goods shall be repair or replacement of defective parts, or a refund of the purchase price, to be
determined at the option of VTI.
VTI warrants that its software and firmware designated by VTI for use with a product will execute its programming
when properly installed on that product. VTI does not however warrant that the operation of the product, or
software, or firmware will be uninterrupted or error free.
LIMITATION OF WARRANTY
The warranty shall not apply to defects resulting from improper or inadequate maintenance by the buyer, buyersupplied products or interfacing, unauthorized modification or misuse, operation outside the environmental
specifications for the product, or improper site preparation or maintenance.
VTI Instruments, Corp. shall not be liable for injury to property other than the goods themselves. Other than the
limited warranty stated above, VTI Instruments, Corp. makes no other warranties, express or implied, with respect to
the quality of product beyond the description of the goods on the face of the contract. VTI specifically disclaims the
implied warranties of merchantability and fitness for a particular purpose.
RESTRICTED RIGHTS LEGEND
Use, duplication, or disclosure by the Government is subject to restrictions as set forth in subdivision (b)(3)(ii) of the
Rights in Technical Data and Computer Software clause in DFARS 252.227-7013.
VTI Instruments, Corp.
2031 Main Street
Irvine, CA 92614-6509 U.S.A.
4
VTEXScanner Driver Preface
www.vtiinstruments.com
SUPPORT RESOURCES
Support resources for this product are available on the Internet and at VTI Instruments customer
support centers.
VTI Instruments, Corp.
World Headquarters
VTI Instruments, Corp.
2031 Main Street
Irvine, CA 92614-6509
Phone: (949) 955-1894
Fax: (949) 955-3041
VTI Instruments
Cleveland Instrument Division
5425 Warner Road
Suite 13
Valley View, OH 44125
Phone: (216) 447-8950
Fax: (216) 447-8951
VTI Instruments
Lake Stevens Instrument Division
3216 Wetmore Avenue, Suite 1
Everett, WA 98201
Phone: (949) 955-1894
Fax: (949) 955-3041
VTI Instruments, Pvt. Ltd.
Bangalore Instrument Division
642, 80 Feet Road
Koramangala IV Block
Bangalore – 560 034
India
Phone: +91 80 4040 7900
Phone: +91 80 4162 0200
Fax: +91 80 4170 0200
Technical Support
Phone: (949) 955-1894
Fax: (949) 955-3041
E-mail: [email protected]
Visit http://www.vtiinstruments.com for worldwide support sites and service plan information.
VTEXScanner Driver Preface
5
VTI Instruments Corp.
6
VTEXScanner Driver Preface
www.vtiinstruments.com
SECTION 1
INTRODUCTION
BACKGROUND
The intent of the programmer’s manual is to describe the VTEXScanner driver and to introduce its
concepts, structure, and capabilities to software and test application engineers by providing
examples of recommended code usage. The reader is expected to be familiar with instrumentation
drivers, in particular IVI-COM and IVI-C specifications; COM and C programming terminology;
and instrumentation concepts. Understanding the IVI driver specifications will significantly help
the reader follow the VTEXScanner driver’s design and the code examples provided. For more
information regarding the required and optional parts of IVI-compliant switch drivers as well as
IVI driver capabilities and operation, please refer to IVI-4.15: LxiSync Class Specification,
IVI-4.2: IviDmm Class Specification, IVI-4.6: IviSwtch Class Specification and the IVI-3.2,
Inherent Capabilities Specification which are available on the IVI Foundation website.
GLOSSARY
Throughout this document, the following terms will be used:
Controller
EX-based
IVI
Module
Module ID
Repeated capability
SFP
a single-board computer, hosting the CPU, RAM, Flash, real time software (i.e.
firmware) and other devices that enable its operation as an intelligent, LXI
platform.
VTI Instruments’ modular instruments developed for the EX platforms.
Synonymously used with “Next Generation System” and “system”.
acronym for Interchangeable Virtual Instruments; a collection of specifications
that create a common programming model for several classes of instruments.
any instrument installed in an EX system slot.
a string identifying the module; “EX4168”, for example.
An IVI / COM software construct used to describe a group of similar features
supported by an instrument. See IVI-3.1, Driver Architecture specification for a
complete description of repeated capabilities.
acronym for Soft Front Panel; an application running on a host computer (either
a Windows or Linux PC) that provides an graphic user interface (GUI) to
monitor and control the instrument.
BASIC CONCEPTS
1) The VTEXScanner driver is compatible with the IVILxiSync, IVISwtch, and IVIDmm
specifications, though it may not implement all of the interfaces of each. Unimplemented
interfaces will be covered later. On Windows platforms, the driver supports both IVI-COM
and IVI-C interfaces. On Linux platforms, it supports a C++ programmatic interface that is
nearly identical to the COM interface.
2) To facilitate use of the VTEXScanner driver, the APIs that are specific to VTI Instruments’
instruments and switch cards are placed in the same class as the properties or methods which
they supplement in the IVI Standards.
VTEXScanner Driver Introduction
7
VTI Instruments Corp.
OPTION STRINGS
The VTEX drivers provide option strings that can be used when Initializing an instrument. The
option string values exist to change the behavior of the driver. The following options strings are
available on VTI IVI drivers:
•
•
•
•
•
•
8
Cache: Per the IVI specification, this option “specifies whether or not to cache the value of
attributes.” Caching allows IVI drivers to maintain certain instrument settings to avoid
sending redundant commands. The standard allows for certain values to be cached always or
never. In VTI IVI-drivers, all values used are of one of these types. As such, any values
entered have no effect.
QueryInstrumentStatus: Queries the instrument for errors after each call is made. As
implemented in the VTI IVI drivers, instruments status is always queried regardless of the
value of this property.
DriverSetup: Must be last, and contains the following properties:
o Logfile: Allows the user to specify a file to which the driver can log calls and other data.
o Logmode: Specifies the mode in which the log file is opened. The allowed modes are:
• w: truncate s the file to zero length or creates a text file for writing.
• a: opens the file for adding information to the end of the file. The file is created if it
does not exist. The stream is positioned at the end of the file.
o LogLevel: Allows the user to determine the severity of a log message by providing a
level-indicator to the log entry.
o Slots: This is the most commonly used option and it allows for a slot number or a slot
number and a card model to be specified.
"Slots=(2)" - Just slot 2.
"Slots=(2=EX1200_3048)" - slot and card model
"Slots=(2,3)" - Multiple slots
InterchangeCheck: Boolean option that enables/disables IVI Interchangeability checking. As
implemented in the VTI IVI drivers, values entered for this property have no effect.
RangeCheck: Boolean option that enables or disables driver validation of user-submitted
values. As implemented in the VTI IVI drivers, validation of user inputs is always performed
at the firmware level regardless of this property’s value.
RecordCoercions: Boolean option that enables driver recording of coercions. As
implemented in the VTI IVI drivers, coercions are handled in the firmware and cannot be
recorded.
VTEXScanner Driver Introduction
www.vtiinstruments.com
SECTION 2
THE SCANNER MODEL
OVERVIEW
The purpose of the VTEXScanner driver is to make it easy to control a scanning measurement
instrument such as the EX1200 series mainframes and its plug-in modules. While controlling the
instrument in the same way is possible by using separate VTI drivers for each component in the
system, such as the VTEXDmm and VTEXSwitch drivers, this is often cumbersome due to the
need to initialize multiple drivers, arrange scanlists, and configure triggers to coordinate the
components. The VTEXScanner driver abstracts many of these details and allows application
programmers the flexibility to program at a high-level.
The VTEXScanner driver provides three types of interfaces. First, there are the core scan list
interfaces that allow an application to specify a sequence of measurements on channels in the
system and read back measurement data. Second, the VTEXScanner incorporates certain
interfaces to configure individual components in the system. The component interfaces derive
from the main drivers for the components, such as the VTEXSwitch and VTEXDmm drivers, and
are described here if they are changed from the drivers from which they originate. Finally, the
VTEXScanner driver incorporates an IVILxiSync-compatible interface to make programming,
triggering, and arming familiar. This model is interchangeable with IVILxiSync, unless otherwise
noted, but does not present an IVILxiSync Interface in COM.
SCANNER THEORY
In the VTEXScanner driver, a scan list is a sequence of steps where each step is separated into a
Setup and Sweep Phase. Scanlists provide a simple, yet flexible, way to program a scanning
measurement instrument. Scanlists are also the fastest way to perform a large number of
measurements when using the EX1200 series. Figure 2-1 illustrates the scanlist structure.
FIGURE 2-1: SCANLIST SEQUENCING
A single scanlist is specified for the entire system. The scanlist defines a sequence of connections
and measurements on certain channels. The maximum scan-list size is typically greater than
32,000 steps. External triggers can be configured to start the scan or each step of the scan. A
scanlist comprises one or more scan steps. Each scan step has a Setup Phase followed by a Sweep
VTEXScanner Driver Model
9
VTI Instruments Corp.
Phase. The Setup Phase allows the application to configure stimulus for the scan step, such as
closing matrix switch paths and other general purpose switching. The Sweep Phase allows the
application to configure a sequence of DMM measurements, specified as a list of pairs of channel
name and DMM configuration. Before use in a scanlist, the application must first define and save
DMM configurations through the DMM component interfaces in the VTEXScanner driver.
Once a scanlist is specified, the scan can be initiated. The scan then runs and records measurement
data. Measurement data can be read during or after the scan. After the scan is complete, the same
scan can be initiated again or a new scanlist can be specified and initiated.
SCANLIST SYNTAX
An application can use the Add function to build up a scanlist, one scan step at a time, or pass in
the full scanlist to the List property. The List property is a read-write property that contains a
string representation of the entire scanlist. The Add function takes two string parameters, one
which specifies the operations to perform in the Setup Phase and one which specifies the
operations to perform in the Sweep Phase.
NOTE
Spaces in the strings passed to Add and List are ignored.
The strings for the entire scanlist and for the Setup and Sweep Phases have the following
Extended Backus-Naur Form (EBNF) grammar:
scanlist
scan_step
::= scan_step , { "/" , scan_step }
::= [ setup_phase ] , "|" , [ sweep_phase ]
setup_phase
switch_path
slot_id
channel
::=
::=
::=
::=
switch_path , { ( "," | ";" ) , switch_path }
{ "~" } , slot_id , channel , "->" , slot_id , channel
digit , { digit } , "!"
letter , { word_char }
sweep_phase
dmm_measure
dmm_config
word_char
::=
::=
::=
::=
dmm_measure , { ";" , dmm_measure }
slot_id , channel , "=" , dmm_config
word_char , { word_char }
letter | digit | "-" | "_"
Where digit is a decimal numeral (0-9), letter is an alphabetical character (A-Z) in upper or lower
case, the digits in slot_id represent the slot number of a card in the instrument, channel is the name
of a switch card channel, and dmm_config is the name of a previously saved DMM configuration.
Take the following three scanlists for example:
1. "| 2!CH1_1=DC_10V"
2. "1!CH1_C1->1!CH1_R1 | 2!CH1_1=DC_1V; 2!CH1_2=DC_1V"
3. "1!CH1_C1->1!CH1_R1 | 2!CH1_1=DC_1V; 2!CH1_2=DC_1V
/~1!CH1_C1->1!CH1_R1,1!CH1_C1->1!CH1_R2 | 2!CH1_1=DC_10V;
2!CH1_2=DC_10V"
Example 1 is a scanlist with one step, no Setup Phase, and one measurement in the Sweep Phase.
The measurement is taken on channel CH1_1 of the switch card in slot number 2 using the settings
from the DMM configuration saved as DC_10V. Example 2 also has one step, a path connection
between channels CH1_C1 and CH1_R1 in slot 1 in the Setup Phase, and measurements on
CH1_1 and CH1_2 of slot 2 in the Sweep Phase with the DMM configuration DC_1V. Example 3
is a scanlist with two steps. The first scan step is the same as in Example 2. The Setup Phase of the
second scan step disconnects the path from the first step and connects a different path (CH1_C1
and CH1_R2), and the Sweep Phase of the second step is similar to the first step except that it uses
a different DMM configuration (DC_10V).
10
VTEXScanner Driver Model
www.vtiinstruments.com
In general, a scanlist is a sequence of triggers and operations. Triggers occur consecutively, with
each trigger advancing the scan to the next step. The beginning of the scanlist marks the beginning
of the first Scan Step and a forward slash (/) marks the beginning of each subsequent step. Scan
operations can occur consecutively or concurrently. A semicolon (;) or vertical bar (|) separate
scan operations that occur consecutively, as used to separate measurements in the Sweep Phase
and to separate the Setup from the Sweep Phase. A comma (,) separates scan operations that occur
concurrently, as used to separate path connections in the Setup Phase. Connections in the Setup
Phase can also be made consecutively by separating them with a semicolon (;) instead of a comma
(,).
Scanlists can contain any combination of scan steps with any combination of connections in the
Setup Phase and measurements in the Sweep Phase. Each trigger, connection, and measurement in
a scan executes in the order specified in the scanlist. Scanning speed is not significantly affected
by the order of channels or the number of cards in the scan, but scanlists with very low channel
locality, such as changing the slot number for each consecutive measurement, will run less
efficiently, which could introduce additional latency. Typically, DMM re-configuration adds the
most significant latency during scanning. To achieve the best scanning speed, an application
should group measurements with the same DMM configuration to avoid re-configuring the DMM
more often than necessary.
THE TRIGGER MODEL
The EX1200 is a bridge device and, therefore, does not expose a triggerable action. However, for
ease of use, the scanner driver exposes a trigger model which functions like the SCPI 1999 Trigger
Subsystem and works on the device and all installed plug-in cards. The user should be able to
program to this representation except where otherwise noted. This is illustrated in Figure 2-2.
IDLE
LAYER
IDLE
Init
No
Wait for
ARM Event
ARM
LAYER
Yes
ArmCount> 0
or
ARM:Count:Inf?
ARM Event
ARM:COUNT:INF?
No
Decrement
ArmCount
Yes
Yes
Wait for
TRIG Event
TRIG
LAYER
No
Scan List
Complete?
TRIG Event
Increment Scan-Step/
Begin Scanning
Plug-in
Module
Layer
Acquire
Data
Yes
Scan-Step
Complete?
No
Advance through Scan-Step/
Continue Sweeping
FIGURE 2-2: EX1200 SERIES TRIGGER MODEL
VTEXScanner Driver Model
11
VTI Instruments Corp.
The trigger model is sectioned into five layers: IDLE, INIT, ARM, TRIG, and Plug-in Module.
The EX1200 system reset condition places it in the IDLE state. A Scanner Initiate() API call
begins the acquisition sequence by transitioning the instrument into the ARM layer. As this
occurs, the reading buffer memory is cleared.
Upon entering the ARM layer, the ARM Count is reset to its specified value. The instrument
remains in the ARM layer until the specified ARM event occurs. Once that occurs the ARM Count
is decremented, and the instrument transitions into the TRIG layer.
The instrument remains in the TRIG layer until the specified TRIG event occurs. Once that occurs,
the instrument transitions into the Plug-In Module layer.
In the Plug-In Module layer, channels in the scan step are measured once for each occurrence in
the scan step and the data is stored into local memory (FIFO).
If there are more steps in the scanlist, the instrument stays in the TRIG layer until the specified
TRIG event (and subsequent device action) occurs enough times to finish the scanlist. Once the
scanlist is complete, the instrument then evaluates the remaining ARM Count and repeats the
ARM layer action if it is nonzero. However, since each transition into the TRIG layer restarts the
scanlist, each additional ARM layer action results in the full specified number of TRIG Count
actions through the TRIG layer and PLUG-IN MODULE layer.
Once the ARM Count reaches zero, the instrument transitions back into the IDLE layer. If the Arm
Count is the special value indicating “Infinite”, the ARM layer is automatically reentered.
However, unlike with an Initiate() API call, the reading buffer memory is not cleared.
12
VTEXScanner Driver Model
www.vtiinstruments.com
SECTION 3
PROGRAMMING EXAMPLES
INTRODUCTION
The VTEXScanner driver uses IVI-compliant APIs to control its operation. The help file for the
driver, installed with the driver and available on the product’s Distribution CD as a standalone
.chm file, provides all the needed property and method descriptions as well as the enum values. To
supplement the help file and to provide a better understanding of how the APIs work together,
programming examples are provided in this section. All examples provided were written in
IVI-COM. For more information on standard IVI function calls, please refer to the IVI Foundation
website for complete documentation. Additional programming examples are also included with
the driver distribution which can be used and modified if desired.
NOTE
For Linux users, .chm viewer are available. These viewers vary from one distribution to another.
BASIC PROGRAMMING EXAMPLES
Initialization
Before using the VTEXScanner driver, it must be initialized. This creates a network connection
between the instrument and the PC. Once established, commands can be sent using this
connection. When this connection is no longer needed, the “close” command can be issued which
releases this connection. The following example is written in C++.
COM Example Using C++
::CoInitialize(NULL) //Start the COM layer
/* A pointer is instantiated to the driver in a try/catch block so that a proper failure will
occur if the driver is not found in the COM registry */
try
{
IVTEXScannerPtr scanner(_uuidof(“VTEXScanner”));
/* Initialize in a try/catch block so that the test code doesn’t run if initialization fails*/
try
{
/*The driver is given an empty options string. To add driver options, see Option Strings in
Section 1. Note that the Reset bit was also set to get a clean start. */
scanner->Initialize(“TCPIP::10.20.5.160::INSTR”, True, True, “”);
// INESERT TEST CODE
scanner->Close();
}
catch(_com_exception &e)
{
::MessageBox(NULL, e.Description(), e.ErrorMessage(), MB_ICONERROR);
}
}
catch(...)
{
VTEXScanner Driver Programming
13
VTI Instruments Corp.
/*Included to catch generated program errors*/
// INESERT ERROR HANDLING CODE
}
Using C# to program can simplify initialization. Many of the standard C++ constructs behave in
the expected manner, making and working with the COM driver easier. Rather than initializing the
COM layer, simply add the VTI.VTEXScanner.Interop assembly to the resources section of the
Visual Studio project. A browser can be used to assist if Visual Studio is used.
COM Example using C#
{
VTEXScanner scanner = new VTEXScanner();
try
{
scanner.Initialize(“TCPIP::10.20.5.160::INSTR”, True, True, “”);
//INESERT TEST CODE
scanner.Close();
}
catch(COMException e)
{
//put code here to catch any test code errors
}
}
catch(COMException e)
{
//Put code here to catch errors instantiating a Scanner driver
}
Basic Sampling
The VTEXScanner driver’s primary use is to take inputs from the front panel of a multiplexer card
and measure them on a DMM. For this, and all subsequent examples, assume that the system
being used is an EX1266 with an EX1200-3048 installed in slot 3.
In this example, the device will be configured using the fewest number of operations possible.
Some default settings will be utilized in this example which will be explained later in this section.
Initialization has been omitted in this code example as well. Note that, in the initialization
examples, a comment is inserted that states “INESERT TEST CODE”. The following code
would be inserted where this comment is made. The remaining programming examples are all
written in C++. C# examples are included in the driver distribution.
/* The next two lines configure the DMM so that it is in the correct mode to measure the switch
card’s inputs */
scanner->Dmm->Function = VTEXScannerFunctionDCVolts;
//More DMM configuration could go here
scanner->Dmm->Configuration->Save(“DCV”);
/* Next, a scanlist is created defining the channels that the DMM will read. Here, a voltage
measurements will be taken on channel CH1_1 on the EX1200-3048 in slot 3. “3!” indicates
that the card is in slot 3 of the EX1266 and “DCV” refers to the saved DMM configuration
above. */
scanner->Add(“”, “3!CH1_1=DCV”);
/* The Initiate call takes no arguments and tells the device to start its trigger model. This is
acceptable, as the default Arm and Trigger sources are “Immediate” which means the device
will sample as soon as it is ready. Arm and Trigger are covered in depth later in this
section. */
//Trigger/arm sources could be set up here
scanner->Initiate();
14
VTEXScanner Driver Programming
www.vtiinstruments.com
/* Once sampling begins, the device must wait for the scanlist complete. The timeout defined here
is in milliseconds, so the device is given 2 seconds to complete scanning. Since the call
will return immediately upon the completion of the scanlist, large timeouts can be defined
without slowing the system. */
scanner->WaitForScanComplete(2000);
/*Next, the data will be read. To do this, three SAFEARRAY pointers are created and then the Read
call allocates and fill in the arrays. Once reading is completed, the SAFEARRAYs must be
destroy, but this is beyond the scope of the example. For more information on working with
SAFEARRAY types, visit the Microsoft website. */
SAFEARRAY* Data = NULL;
SAFEARRAY* ts_sec = NULL; //Timestamps, seconds component
SAFEARRAY* ts_nsec = NULL; //Timestamps, nanoseconds or fractional seconds component
scanner->Read(1000, 1, &data, &ts_sec, &ts_nsec);
Arming the Scanner
The scanner is intended to be a stimulus-measure instrument: once it receives a stimulus, then it
begins a measurement. The stimulus might consist of a trigger bus line pulse, a DIO signal going
high, or an internal IEEE 1588 alarm reaching the defined time. In the following two examples,
the arm and trigger sources are changed from their default settings.
The Arm layer of the device controls the start of each scanlist iteration (see Figure 2-2). One Arm
command must be received each time the scanlist is run. The Arm Count property controls how
many times the scanlist will run.
/*Turn off the Immediate source (default setting). */
scanner->System->Arm->Sources->DisableAll();
//Enable the LXI3 arm source. By doing so, a rising edge on LXI3 will be required to operate.
scanner->System->Arm->Sources->Item[“LXI3”]->Enabled = VARIANT_TRUE;
/* The Item[] syntax used to select a particular source is specified in the IVI LxiSync
specification. The use of VARIANT_TRUE and VARIANT_FALSE is a Microsoft COM standard. More
on this concept can be found in the Microsoft COM documentation. */
//To run the scanlist multiple times, the Arm Count is changed.
scanner->System->Arm->ArmCount = 5; //Run the scanlist 5 times
/*To wait for both LXI3 or DIO2, it is necessary to first enable DIO2 as well as LXI3 */
scanner->System->Arm->Sources->Item[“DIO2”]->Enabled = VARIANT_TRUE;
/*In its current state, there are two Arm signals waiting for a rising edge from a hardware line
that are logical-ANDed together. If left in this state, the scanner would only Arm when
LXI3 and DIO2 both went high simultaneously. This is corrected by changing the OrEnable bit
so that either rising edge will trigger the scanner.*/
scanner->System->Arm->Sources>OrEnabled = VARIANT_TRUE;
/* The Arm layer also supports Alarms, based on IEEE 1588, and allow a device to be armed based
on a time in the future. This allows two devices on separate networks with no commonality
aside from their IEEE 1588 time to be triggered (fairly) simultaneously. */
scanner->System->Arm->Alarms->Item[“ALARM0”]->Configure(VARIANT_TRUE, 1234567890.0, 0.01234567,
0, 0);
/* This Alarm configuration enables Alarm 0, sets it to arm at IEEE 1588 time
1234567890.01234567, and to fire exactly once (“0” is a special case for both Period and
Repeat Count). Note that Alarms are Sources, despite having their own
area, and, therefore, are affected by OrEnabled. There is no Alarm dedicated DisableAll function.
*/
VTEXScanner Driver Programming
15
VTI Instruments Corp.
Triggering the Scanner
The trigger layer of the device controls the start time of each scan step within a scanlist, essentially
controlling each Add function call (see Figure 2-2). While the Arm layer allows for OR’ing and
AND’ing together multiple sources, the Trigger layer is limited to a single source, defined by the
TriggerSource property. This property can still be set to many of the same sources available in the
Arm layer. The Trigger→Sources and Trigger→Alarms areas still exist, but are used for
configuration only, not enabling.
/*Set the TriggerSource to a hardware trigger, such as LAN3. */
scanner->System->Trigger->TriggerSource = “LAN3”;
/*Set the TriggerSource to Alarm0. Note that the Trigger->Alarms section’s Configure function
does not have a Boolean for Enabled, but that Alarm0 must still be enabled with the Enabled
property. If we do not enable the alarm, it will not fire when the defined time is reached.
In Arm, the Enabled property both turns the alarm on and sets it as an Arm source.*/
scanner->System->Trigger->Alarms->Item[“ALARM0”]->Configure(1234567890.0, 0.01234567, 0, 0);
scanner->System->Trigger->Alarms->Item[“ALARM0”]->Enabled = VARIANT_TRUE;
scanner->System->Trigger->TriggerSource = “ALARM0”;
DMM Configurations
To read data from the DMM present in some EX1200 series mainframes, a DMM configuration
must be stored. In a previous example, the DMM Configuration only involved setting the DMM
function to DCVolts. Configuring the DMM is expanded in the following example.
/* “Fast” DMM Configuration. This allow for the shortest time between readings, but sacrifices
some accuracy. */
scanner->Dmm->Configuration->DeleteAll(); //Clear all configs from permanent storage
scanner->Dmm->Function = VTEXScannerFunctionDCVolts;
scanner->Dmm->Range = 10.0; //10 Volt Range. AutoRange is slower, so the range is specified
scanner->Dmm->Resolution = 10000; //This selects the fewest digits of accuracy
scanner->Dmm->Trigger->MultiPoint->SampleDelay = 0;
scanner->Dmm->Trigger->Delay = 0; //A delays of 0 mean faster sampling
scanner->Dmm->Advanced->AutoZero = VTEXScannerAutoZeroOff; //AutoZero is slow as well
scanner->Dmm->Configuration->Save(“Fast”); //Any name could be provided for this configuration.
/* “Slow” DMM Configuration. This allows for highly accurate measurements, but may significantly
increase the time required for the scanlist to run. */
scanner->Dmm->Function = VTEXScannerFunctionDCVolts;
scanner->Dmm->Range = VTEXScannerDmmRangeAutoRangeOn; /* It is only necessary to use AutoRange if
if the range of the signal being measured is unknown. If the range is known, select the
minimum range that accomidates the signal. */
scanner->Dmm->Resolution = 1.0e-9; //This selects the most digits of accuracy
scanner->Dmm->Advanced->AutoZero = VTEXScannerAutoZeroOn;
scanner->Dmm->Configuration->Save(“Slow”);
/*Many more DMM Configurations are possible depending on the measurement requirements.*/
Scanlists
A scanlist can be set in one of two ways: 1) by directly setting the entire list at once using the List
property or 2) by building a scanlist by calling Add with each step to be included. Scanlist steps
can be of any length and scanlists can consist of any number of steps. Scanlist steps are divided
into two events: the “setup” event and the “sweep” event. In the examples below, the Sweep event
is defined, leaving the Setup event to be described later in this section.
/*Create a list that scans 3 channels. The semicolon character (;) is used as a separator for
actions that should occur sequentially*/
scanner->Clear();
scanner->Add(“”, “3!CH1_1=DCV; 3!CH1_2=DCV; 3!CH1_3=DCV”); /* The empty quotes are the Setup
portion */
16
VTEXScanner Driver Programming
www.vtiinstruments.com
/* The scanlist above scans all three channels as fast as possible with no external input. To
wait for a trigger between each event, they must be written in separate scanlist steps */
scanner->Clear();
scanner->Add(“”, “3!CH1_1=DCV”);
scanner->Add(“”, “3!CH1_2=DCV”);
scanner->Add(“”, “3!CH1_3=DCV”);
/* To set the first scanlist in a single function call without using Clear and Add, set the List
property directly. Note that the bar character (|) is used to separate the Setup and Sweep
portions of the scanlist step and that there is no setup step. */
scanner->List = “|3!CH1_1=DCV; 3!CH1_2=DCV; 3!CH1_3=DCV”;
/*To do the same for the second scanlist example, the forward-slash character (/) is used to
separate scanlist steps from each other. Note that an empty Setup step can be placed after
a new scanlist step.*/
scanner->List = “|3!CH1_1=DCV/|3!CH1_2=DCV/|3!CH1_3=DCV”;
Advanced Sampling
In the Basic Sampling example, many details were left to default settings.. Now that other topics
have been discussed and examples examined, a more complicated sampling example can be
provided.
/*First, set up a DMM configuration */
scanner->Dmm->Configuration->DeleteAll();
scanner->Dmm->Function = VTEXScannerFunctionDCVolts;
scanner->Dmm->Range = 10.0;
scanner->Dmm->Resolution = 10000; //
scanner->Dmm->Trigger->MultiPoint->SampleDelay = 0;
scanner->Dmm->Trigger->Delay = 0;
scanner->Dmm->Advanced->AutoZero = VTEXScannerAutoZeroOff;
scanner->Dmm->Configuration->Save(“Fast”);
/* Set up a Scanlist */
scanner->List = “|3!CH1_1=Fast/|3!CH1_2=Fast”;
/*Set up Trigger and Arm. Here, the scanlist will be run twice, will wait for LXI1 to trigger,
and LXI2 to Arm. Set in this manner, the following incoming events must occur sequentially:
LXI2, LXI1, LXI1, LXI2, LXI1, LXI1. */
scanner->System->Arm->ArmCount = 2;
scanner->System->Arm->Sources->DisableAll();
scanner->System->Arm->Sources->Item[“LXI2”]->Enabled = VARIANT_TRUE;
scanner->System->Trigger->TriggerSource = “LXI1”;
scanner->Initiate();
/* Since it cannot be determined when the hardware lines will toggle, it is important to set
WaitForScanComplete for a reasonable time. In this example, 10 seconds is used. */
scanner->WaitForScanComplete(10000);
SAFEARRAY* Data;
SAFEARRAY* ts_sec;
SAFEARRAY* ts_nsec;
/* Read has an ‘instant’ timeout here (0 ms) because the scan should be done by this point. An
error should occur instantly if all 4 samples are not ready. */
scanner->Read(0, 4, &Data, &ts_sec, &ts_nsec);
ADVANCED PROGRAMMING
Setup Steps
Again, in the Scanlists programming example, setup steps were ignored and left blank. Although
this is a valid configuration, using setup step allows the user to prepare the switch card for
measurements, such as closing relays to create the desired path. It is important to note that setup
steps are cleared at the end of the scanlist step and are not available for subsequent scanlist steps.
VTEXScanner Driver Programming
17
VTI Instruments Corp.
/* CH1_1 on will be configured on an EX1200-3048. CH1_1 is connected to CH2_1, which then
multiplexes out to CH2_2, CH2_3, and CH2_4. To measure CH1_1, the multiplexed connections
which are required must be defined. */
scanner->Clear();
scanner->Add(“3!CH2_1->3!CH2_2”, “3!CH1_1=DCV”);
scanner->Add(“~3!CH2_1->3!CH2_2;3!CH2_1->3!CH2_3”, “3!CH1_1=DCV”);
scanner->Add(“~3!CH2_1->3!CH2_3;3!CH2_1->3!CH2_4”, “3!CH1_1=DCV”);
/* Other multiplexer cards can be involved as well. Here, an EX1200-5002 in slot 5 is configured
to connect CH1_1 to CH1_2. */
scanner->Clear();
scanner->Add(“5!CH1_1->5!CH1_2”, “3!CH1_1=DCV”);
Discharging a Multiplexer
Under some circumstances, such as switching from a high voltage measurement to a low voltage
measurement, it is necessary to discharge any accumulated charge in a circuit so that an accurate
reading can be made. The following example shows how this can be done.
/* Assume that a 300 V signal being fed into CH1_1 and that a 0.0001 V signal being fed into
CH1_2. Prior to switching from CH1_1 to CH1_2, it is good practice to discharge the
backplane lines before performing the second measurement. */
scanner->Clear();
scanner->Add(“”, “3!CH1_1=DCV”);
scanner->Add(“3!BPL_HI->3!BPL_LO;~3!BPL_HI->3!BPL_LO”, “3!CH1_2=DCV”);
/*To be certain that the path that connects BPL_HI to BPL_LO goes through CH1_COM, the following
can be done.*/
scanner->Clear();
scanner->Add(“”, “3!CH1_1=DCV”);
scanner->Add(“3!BPL_HI->3!CH1_COMH->3!CH1_COML->3!BPL_LO”, “3!CH1_2=DCV”);
Output Events
If a test setup contains more than an EX1200 series mainframe, it may be necessary for the other
instruments to be notified when the EX1200 series mainframe completes a scanlist or a scan step.
This communication is provided using output events.
/* First, a rising edge is sent on DIO3 when the scanlist is complete. */
scanner->System->Events->Item[“DIO3”]->Source = “ScanListComplete”
/* Next, a LAN event is added every time a scan step completes */
scanner->System->Events->Item[“LAN2”]->Source = “ScanStepComplete”
/* This process can also be used to route signals from one output to another which have no affect
on the scanlist */
scanner->System->Events->Item[“LXI1”]->Source = “DIO5”;
Scanning Example
This example uses the EX1200-4128 to demonstrate how to use the scanning feature. This
example measures the first three channels of EX1200-4128 ten times each and displays the results.
//
/*
This is the main project file for Visual C++ application project
Requirements
1. A EX1200 mainframe with DMM
2. A Matrix card EX1200-4128.
Setup.
1. IP address of the EX1200 mainframe is 10.30.1.11 in this example. The IP address must be
changed in the program if the EX1200 mainframe has a different address.
18
VTEXScanner Driver Programming
www.vtiinstruments.com
2. Matrix card is in the slot No:1. This can be confirmed in SFP. If not, change the 1! in
the scanner->Add to the appropriate slot number
3. This example uses IVI scanner drivers, which can be downloaded from
http://www.vtiinstruments.com/Downloads.aspx
Description:
This example demonstrates how use the scanning feature with an EX1200-4128 matrix card.
This example measures the first three channels of EX1200-4128 ten times and displays the
results.
Working steps:
1. First, the DMM is configured for measuring DC voltage and the configuration is saved
before taking any measurements. See the EX1200 Series User’s Manual for more information.
2. The Scanlist is configured for measuring the first three channels.
3. Scanlist is set to repeat for 10 times(using "System->Arm->ArmCount" setting)
4. When scanning is initiated, the first channel in its scanlist connect and then take a
measurement. This step is repeated for all the three channels. This entire process is then
repeated ten times, resulting in a total of thirty measurement results.
5. During the scanning process, measured values are read from the FIFO and displayed until
the scanning completes for all the channels(using IsScanning).
*/
#include "stdafx.h"
#using <mscorlib.dll>
#import "IviDriverTypelib.dll" no_namespace
#import "VTEXScanner.dll" no_namespace
#include <comutil.h>
#include <iostream>
#include <conio.h>
using namespace std;
int _tmain()
{
::CoInitialize(NULL); //Start the COM layer
/*Instantiate a pointer to the driver in a try/catch block so that the instrument fails
gracefully if the driver is not found in the COM registry.*/
try
{
IVTEXScannerPtr scanner(__uuidof(VTEXScanner));
/*Perform an Initialization using a try/catch block so that our test code doesn't run if
the instrument fails to initialize.*/
try
{
/* Here, reset (the third argument) is true to provide a clean start, and the
options string (the fourth argument) is empty. See Option Strings in Section 1 for
more information on option strings.*/
scanner->Initialize("TCPIP::10.30.1.11::INSTR",true, true, "");
/*set up a DMM for DC voltage measurement*/
scanner->Dmm->Configuration->DeleteAll(); //Delete all the saved configurations of
the DMM.
scanner->Dmm->FunctionOption = VTEXScannerDmmFunctionOptionDCExtProbeOn; //10M
mode
scanner->Dmm->Function = VTEXScannerDmmFunctionDCVolts;
scanner->Dmm->Range = 100.0;
scanner->Dmm->Resolution = 0.001; //5.5 Digits accuracy. Choose 0.0001 for 6.5
digits accuracy
scanner->Dmm->Trigger->MultiPoint->SampleDelay = 0;
scanner->Dmm->Advanced->AutoZero = VTEXScannerDmmAutoZeroOff;
scanner->Dmm->Configuration->Save("DCV");
//Set up a Scanlist with the MUX
scanner->Clear();
scanner->Add("", "1!CH1_2W=DCV; 1!CH2_2W=DCV; 1!CH3_2W=DCV");// Measuring first
three channels.
/*The EX1200-4128 has two-wire channels (CH1_2W through CH64_2W) and four-wire
channels (CH1_4W through CH32_4W) for the rows.
VTEXScanner Driver Programming
19
VTI Instruments Corp.
CH1_2W comprises (CH_R1, CH_R2), CH2_2W is (CH_R3, CH_R4), and so on. CH1_4W
comprises (CH_R1,CH_R2,CH_R3,CH_R4),
CH2_4W is (CH_R5, CH_R6, CH_R7, CH_R8), and so on.
The 4128 has two wire channels CH1_2WCOM and CH2_2WCOM and for wire channel CH_C
for the columns.*/
scanner->System->Arm->ArmCount = 10;
scanner->Initiate();// Start the measurement since no trigger has been configured.
double *dReadBuf;
double *ts_secs, *ts_fsecs; // Seconds and Fraction of seconds.
long fifo = scanner->FIFOCount;
SAFEARRAY
*psaData = NULL;
SAFEARRAY
*psaTimeSeconds = NULL;
SAFEARRAY
*psaTimeFractions = NULL;
long total_count = 0;
while(scanner->IsScanning || fifo>0)
{
if(fifo>0)
{
psaData = NULL;
psaTimeSeconds = NULL;
psaTimeFractions = NULL;
dReadBuf = NULL;
ts_secs = NULL;
ts_fsecs = NULL;
/* Read has an timeout here because the scan should be done by the
time we get to this point. We should error after 1 second if all
the samples are not yet ready. */
scanner->Read(1000, fifo, &psaData, &psaTimeSeconds,
&psaTimeFractions);
//dReadBuf = (void *)calloc(fifo , sizeof(double));
SafeArrayAccessData(psaData, (void **)&dReadBuf);
SafeArrayAccessData(psaTimeSeconds, (void **)&ts_secs);
SafeArrayAccessData(psaTimeFractions, (void **)&ts_fsecs);
for (int i = 0; i < fifo; i++)
{
cout<<"Data:"<<dReadBuf[i]<<" Second:"<<ts_secs[i]<<"
Nanosecond:"<<ts_fsecs[i]<<endl;
}
total_count = total_count+ fifo;
}
Sleep(100);
fifo = scanner->FIFOCount;
}
cout<<endl<<"Total count:"<<total_count;
SafeArrayUnaccessData(psaData);
SafeArrayUnaccessData(psaTimeSeconds);
SafeArrayUnaccessData(psaTimeFractions);
//Remember to clear safearray to avoid memory leaks.
::SafeArrayDestroy(psaData);
::SafeArrayDestroy(psaTimeSeconds);
::SafeArrayDestroy(psaTimeFractions);
scanner->Close();
getche();
}
catch(_com_error &e)
{
::MessageBox(NULL, e.Description(), e.ErrorMessage(), MB_ICONERROR);
}
}
catch(...)
{
/*This will catch any error the program generated.*/
//Handle the errors
}
}
20
VTEXScanner Driver Programming
www.vtiinstruments.com
VTEXScanner Driver Programming
21
VTI Instruments Corp.
22
VTEXScanner Driver Programming
www.vtiinstruments.com
SECTION 4
APPLICATION NOTES
PURPOSE
This application note is designed to familiarize customers with the scanning capabilities of the
EX1200 family and also to provide a step-by-step procedure that can be followed to successfully
set the instrument up as a scanning DMM. The procedure is intended to be used with a functional
EX1200 mainframe, with internal DMM and switch modules and will highlight features/benefits
that illustrate the versatility of the EX1200 series and its ability to satisfy many different
application needs.
PRODUCT OVERVIEW
The EX1200 product family is a modular, scalable series of mainframes and plug-in cards,
certified to LXI Class A specifications, that can be configured to address a variety of applications
in the data acquisition and electronic test environments. The series includes the following core
components, and the list continues to grow as more products are released:
•
•
•
•
•
•
•
•
•
•
•
•
•
•
2-slot mainframe with optional DMM in ½ rack 1U footprint
6-slot mainframe with optional DMM in full rack 1U footprint
16-slot mainframe with optional DMM in full rack 3U footprint
General purpose and multiplexing switching modules (300 V and 2 A)
Solid-state multiplexers scanning at 1000 channels/second
Matrix modules providing 128 two-wire cross-points or 512 cross-point 1-wire
Power modules switching (16 A)
RF trees switching DC-3 GHz, including 500 V/250 MHz
Microwave switching to (26.5 GHz)
Isolated analog outputs with ranges from 1 V to 20 V and 500 kSa/s AWG capability
Digital I/O with 2 MHz pattern generator and relay drive to 300 mA
Comparator/Threshold detector with constant monitor of signals to 100 V
5 W Programmable Load
Multifunction digital/analog counter/timer
EX1200 FOR DATA ACQUISITION
When installed with the optional 6.5 digit DMM, the EX1200 family can be configured as a costeffective, high-density, scanning measurement and control instrument capable of acquiring data
from thermocouples, RTDs, thermistors, and voltage/current sensors at rates up to 1000 channels
per second 1. Plug-in switch/multiplexer and digital input modules are used to expand the number
of channels that can be scanned in a single system. Additional plug-in modules expand the
capabilities of this instrument for data acquisition by adding analog and digital outputs for
controlling external devices. A powerful onboard graphic interface provides quick and easy setup
for test sequences and storing data to disk.
1
Scanning speeds are dependent on switch types used and accuracy requirements
VTEXScanner Driver Programming
23
VTI Instruments Corp.
This guide creates a scanning DMM that measures the onboard thermistor of the EX1200-104TB,
a Type K thermocouple connected to channel 2 of the terminal block and a resistor connected to
channel 3 of the terminal block. This example can easily be extended to any desired configuration.
Recommended Equipment
•
•
•
•
•
•
•
•
•
•
•
•
•
EX1266, reconfigurable switch/measure instrument
EX1200 AC line cord
EX1200-3048, 48-channel multiplexer
EX1200-104TB, screw terminal block with auto CJC
Type K thermocouple connected to channel 2 of terminal block
≈2 kΩ resistor connected to channel 3 of terminal block
Computer with Ethernet interface and Windows XP or Vista
Internet Explorer 7.0 or above. Any web browser can be used to communicate with the
EX1266, but Bonjour requires Internet Explorer 7.0 or above.
Bonjour discovery utility
Java plug-in (on VTI Distribution CD)
CAT-5e Ethernet cable
Standard Ethernet switch (optional)
Program Development environment (optional, such as LabView, Visual Studio,
LabWindows/CVI)
Making Sure the Required Software is Installed
These steps are intended to give an overview of setting the instrument up and some of the features
of the instrument and LXI. If the device is already setup, feel free to skip to the next section.
1) Ensure that the required software is installed on the PC, including Internet Explorer, Bonjour,
Java, and, if desired, the development environment of choice.
2) Connect the PC to the EX1266 LAN connector on the back of the mainframe using a CAT-5e
cable. It can be connected directly through the PC’s NIC or indirectly by connecting it to an
Ethernet switch.
3) Connect the EX1200-3048 switch card (104-pin D-sub) to the EX1200-TB104. Ensure that
there is a thermocouple connected to channel 2 and a resistor to channel 3. The terminal block
has an onboard thermistor that is used as cold-junction compensation. It is required only when
the application requires accurate temperature measurements (< 0.4 °C) and an external CJC is
not being used. If temperature measurements are not being made, users can directly connect to
the EX1200-3048 connector.
4) Make sure the jumpers on the EX1200-TB104 are connected so that the thermistor is
connected to channel 1.
FIGURE 4-1: TERMINAL BLOCK JUMPERS
5) Power on the EX1266. It will take about one minute for the mainframe to boot up, be
‘discovered’ by the PC, and then have an IP address assigned. When the LAN LEDs
illuminate green, the device is booted up and has acquired an IP address.
24
VTEXScanner Driver Programming
www.vtiinstruments.com
6) From the PC, open Internet Explorer. If Bonjour 2 is installed, the EX1266 will be discovered
automatically and will appear in the Bonjour toolbar as shown in Figure 4-2.
If the PC is not connected to the Internet, the browser will display a generic error window.
This is to be expected. The EX1266 should be listed as an Ethernet device on the left hand
side. If this is not the case, please contact a VTI Sales Manager or applications engineer to
ensure that the system is setup properly.
This is to be expected if the EX1200 mainframe is
connected directly to a laptop/PC.
The EX1266 will be displayed here. Click on the link to
open up the EX1266 soft front panel.
FIGURE 4-2: USING BONJOUR DISCOVERY TOOL
7) Click on the EX1266 line item in the toolbar to open the soft front panel.
8) After clicking on the EX1266 link, there will be a momentarily delay, then the index page
should be displayed as shown in Figure 4-3. The Index page acts as a “Main Menu” for all
LXI-related graphic user interfaces (GUIs), including the soft front panel, and also displays
the information mandated by the LXI specification 3.
2
Bonjour is not required to communicate to LXI devices, however, because LXI is inherently Ethernet at its core, Bonjour will discover and
display LXI devices just as it would any other LAN appliance (such as Ethernet printers). This is a very convenient, free utility and the LXI
specification requires that all devices be discoverable through Bonjour.
3
A major benefit of LXI over generic LAN instruments is that LXI defines what information must be displayed and that it is displayed in a
consistent manner. The IP address, serial number, and IEEE 1588 time (for class A or B devices only) are displayed among other things.
VTEXScanner Driver Programming
25
VTI Instruments Corp.
Contact the factory directly with questions, or easily
download manuals and software updates with web-aware
instruments.
This is where the LXI Class level of the EX1266 can be
sent. It conforms to Class A which is a superset of all LXI
classes and provides the most (advanced) capabilities.
FIGURE 4-3: EMBEDDED WEB PAGE INDEX
9) Click on the Network Configuration link. The web page in Figure 4-4 should be displayed.
Configure how the system will assign an IP address with a
click of the mouse. DHCP is dynamic addressing.
Use static IP addressing when it is desirable to fix an
address in the system.
Every Ethernet device has a unique MAC address. This is
used to set an IP address when AutoIP is enabled and there
is no DHCP server.
FIGURE 4-4: NETWORK CONFIGURATION PAGE
IP addresses are the Ethernet-equivalent of GPIB logical addresses used by instrumentation
platforms. Where GPIB only supports 31 logical addresses on a node, there is virtually no
limit to the number of LXI devices that can be supported on a single system.
26
VTEXScanner Driver Programming
www.vtiinstruments.com
LXI devices default to DHCP/AutoIP to assign logical addresses. Unless there is a DHCP
server present, such as those found in a router or a corporate intranet, the LXI device will get
its address via AutoIP. This is an address that is derived from the unique MAC address that is
assigned to an Ethernet device.
Often, when there is a dedicated test network, end users will desire a hard coded, static IP
address which is similar to setting dip switches on a VXI or GPIB device to assign a logical
address.
10) Click on the Time Configuration link. The web page in Figure 4-5 should be displayed.
The EX1266 does not have an
onboard battery that continues to
keep time when the system is
powered down. In order for the
system to display the current wallclock time, it must be set here.
Setting it for the grandmaster will
sync up any slave as well.
IEEE 1588 enabled systems will
have one master and multiple
slaves.
VTI’s software implementation of
IEEE 1588 allows for very good
time synchronization to be achieved
which is required by the DAQ
switching I/O markets.
FIGURE 4-5: TIME CONFIGURATION PAGE
The Time Configuration page provides access and visibility to the EX1266’s time
synchronization features. The EX1266 is Class A compliant, and, as such, it supports
Precision Time Protocol (PTP or, more commonly, IEEE 1588) as well as the standard, less
precise, Network Time Protocol. IEEE 1588 is a standard that was developed to allow
distributed devices to precisely agree on wall clock time with some implementations
delivering accuracies into the 10’s of nanoseconds range.
VTEXScanner Driver Programming
27
VTI Instruments Corp.
11) Click on the LXI Synchronization link. The web page in Figure 4-6 should be displayed.
What does this number mean? It is the IEEE 1588 time,
which is expressed in seconds that have elapsed since
‘epoch time’ or t0 for coordinated universal time (UTC).
t0 = January 1, 1970.
FIGURE 4-6: THE LXI SYNCHRONIZATION PAGE
The LXI Configuration page provides more detail into the capabilities of the EX1266 as it
relates to synchronization and triggering. Note that the Wired-OR Bus (the Class A hardware
trigger bus, or WTB) information is displayed here.
SETTING THE EX1200 AS A SCANNER
The following steps show how to configure the EX1200-3048 and DMM in a scanning DMM
configuration. Examples are shown using the instrument web page, IVI-C, and IVI-COM (in C#).
To begin the process, the scanner must first be initialized.
Using the Web Page
Click on the Soft Front Panel link, the web page in Figure 4-7 should appear:
FIGURE 4-7: EX1200 SOFT FRONT PANEL INDEX
The EX1200 series is modular and the number of plug-ins that can be supported by any one
mainframe is dependent on the model number. The EX1266 can support up to six plug-ins and has
the optional onboard, 6.5 digit DMM installed. Each plug-in module has soft front panel (SFP)
accessible through the embedded webpage. The SFP allows end users to monitor and/or control
system components. In addition, there is a ‘scanner’ SFP which is a utility that quickly allows a
user to configure a data acquisition process and begin acquiring data. This demonstration utilizes
one switch card and the DMM.
28
VTEXScanner Driver Programming
www.vtiinstruments.com
Click on the All Slots: Scanner link in the Soft Front Panels table to initialize the scanner.
The SFPs are written in Java, so it is essential that the Java utility is installed on PC/laptop and
Internet Explorer must be configured to allow Java applets to run. After clicking on the link, the
Java applet will begin installing and, when it completes, a GUI like the one shown in Figure 4-8
will appear.
FIGURE 4-8: EX1200 SCANNER SFP
The EX1200 scanner SFP allows users to:
1) Setup multiple DMM configurations that can be used to take different measurements (e.g.
resistance, temperature, voltage) during scanning.
2) Select the channels where measurements will occur as part of a test sequence.
3) Program the setup states of general purpose relays and analog/digital outputs that get
configured at the beginning of each scan step.
4) Setup trigger conditions that initiate and advance scan sequences.
5) View the returned data in the LED display, or in tabular form.
6) Export acquired data to a .csv compatible file.
Note that the scanner SFP also provides access to the individual module SFPs.
Using IVI-COM (C#)
1) To use the driver, a reference to it must first be included. Click Project → Add Reference
and then click the Browse tab. Browse to C:\Program Files\IVI Foundation\IVI\bin and select
VTEXScanner.dll.
2) In the header of the .cs file, enter the following:
using VTI.VTEXScanner.Interop;
3) The following code will initialize the driver session:
VTEXScanner scanner = new VTEXScanner();
scanner.Initialize("TCPIP::10.20.11.145::INSTR", true, true, "");
VTEXScanner Driver Programming
29
VTI Instruments Corp.
Using IVI-C
1)
2)
3)
4)
Add C:\Program Files\IVI Foundation\IVI\Include to the include directories of the project
Add C:\Program Files\IVI Foundation\IVI\lib\msc to the library files of the project
Add VTEXScanner.lib to the Dependancies of the project
Include the Scanner header file in the source code:
#include "VTEXScanner.h"
5) Use the following code to initialize the instrument:
ViSession scanner = VI_NULL;
ViStatus stat = VI_SUCCESS;
stat = VTEXScanner_init(RESOURCE_STRING, VI_TRUE, VI_TRUE, &scanner);
SETTING UP DMM CONFIGURATIONS
A DMM configuration stores the state of the DMM, including function, range, resolution, and
many other settings. These configurations are used by the scanner as directions for making a
specific type of measurement for a particular channel.
DMM configurations are stored in non-volatile memory on the EX1266. This means that any
configurations that have been created previously persist through power cycles. Therefore, the
panel in Figure 4-9 may already have DMM configuration entries when the DMM Configs button
is clicked.
For this example, a scan list will be set up that reads data from two input channels: one that is
connected to a thermocouple for a temperature measurement and one that is connected to a
resistor. Because temperature measurement are being made, the CJC must be read at the beginning
of each scan to compensate for the temperature gradient at the junction of the thermocouple and
the terminal block.
Hardware Setup
This example uses the onboard thermistor of the EX1200-TB104 as a CJC reference for more
accurate thermocouple readings. To do this, the jumpers on the EX1200-TB104 must be set
properly (see Figure 4-1).
Using the Web Page
Click on the DMM Configs button. The panel in Figure 4-9 should appear.
FIGURE 4-9: DMM CONFIGURATION MANAGER
1) The DMM will be measuring a CJC channel, as well as temperature and resistance, so DMM
configurations must be defined that allow this to be accomplished.
Click the New button. This will add a DMM configuration entry shown in Figure 4-10.
30
VTEXScanner Driver Programming
www.vtiinstruments.com
FIGURE 4-10: ADDING A DMM CONFIGURATION
From this panel, it is very easy to create a DMM configuration that can be called as part of a
scan sequence. Cells are either modified as text edits or via drop menus. Channel 1 is the CJC
channel. The first configuration is defined for this type of measurement. Once configured,
click on the New button. The second configuration is for a thermocouple measurement and
the last configuration is for a resistance measurement. When finished, the DMM configuration
manager should resemble the Figure 4-11.
FIGURE 4-11: THREE DMM CONFIGURATIONS
NOTES
The thermistor onboard the TB104 is a 10 kΩ thermistor. Simply select 10K from the drop menu
to use this thermistor.
When configuring the option for the CJC thermistor, be sure that the Is Reference Junction box is
checked. This ensures that the CJC measurement is used for more accurate temperature
measurements. Also, when configuring the thermocouple channel, ensure that the reference
junction is set to External.
Click the Done button once all configurations are entered into the system.
Using IVI-COM
The following code sets up the three required configurations for this example. Using “CH1_CJC”,
“CH2_TEMP” and “CH2_RES” as the configuration names:
//Setup The CJC Configuration
scanner.Dmm.Configure(VTEXScannerDmmFunctionEnum.VTEXScannerDmmFunctionTemperature,
100, 0.1);
scanner.Dmm.Temperature.TransducerType =
VTEXScannerDmmTransducerTypeEnum.VTEXScannerDmmTransducerTypeThermistor;
scanner.Dmm.Temperature.Thermistor.Resistance = 10000;
scanner.Dmm.Temperature.IsReferenceJunction = true;
scanner.Dmm.Configuration.Save("CH1_CJC");
// Setup The Thermocoupel Configuration
scanner.Dmm.Configure(VTEXScannerDmmFunctionEnum.VTEXScannerDmmFunctionTemperature,
1200, 0.1);
VTEXScanner Driver Programming
31
VTI Instruments Corp.
scanner.Dmm.Temperature.Thermocouple.Type =
VTEXScannerDmmThermocoupleTypeEnum.VTEXScannerDmmThermocoupleTypeK;
scanner.Dmm.Temperature.IsReferenceJunction = false;
scanner.Dmm.Temperature.Thermocouple.Type =
VTEXScannerDmmThermocoupleTypeEnum.VTEXScannerDmmThermocoupleTypeK;
scanner.Dmm.Temperature.Thermocouple.RefJunctionType =
VTEXScannerDmmRefJunctionTypeEnum.VTEXScannerDmmRefJunctionTypeExternal;
scanner.Dmm.Configuration.Save("CH2_TEMP");
// Setup the Resistance Configuration
scanner.Dmm.Configure(VTEXScannerDmmFunctionEnum.VTEXScannerDmmFunction2WireRes,
10000, 10);
scanner.Dmm.Configuration.Save("CH3_RES");
Using IVI-C
// Set the CJC Configuration
stat = VTEXScanner_Configure(vi,
VTEXSCANNER_VAL_FUNCTION_TEMPERATURE,
100,
0.1);
stat = VTEXScanner_SetAttributeViReal64(vi,
VI_NULL,
VTEXSCANNER_ATTR_DMM_TEMPERATURE_THERMISTOR_RESISTANCE,
10000);
stat = VTEXScanner_SetAttributeViBoolean(vi,
VI_NULL,
VTEXSCANNER_ATTR_DMM_TEMPERATURE_IS_REFERENCE_JUCTION,
VI_TRUE);
stat = VTEXScanner_DmmConfigurationSave(vi, "CH1_CHJ");
// Set the TC Config
stat = VTEXScanner_Configure(vi,
VTEXSCANNER_VAL_FUNCTION_TEMPERATURE,
100,
1.0);
stat = VTEXScanner_DmmTemperatureThermocoupleConfigure(vi,
VTEXSCANNER_VAL_THERMOCOUPLE_TYPE_J,
VTEXSCANNER_VAL_REF_JUNCTION_EXTERNAL);
stat = VTEXScanner_SetAttributeViBoolean(vi,
VI_NULL,
VTEXSCANNER_ATTR_DMM_TEMPERATURE_IS_REFERENCE_JUCTION,
VI_FALSE);
stat = VTEXScanner_DmmConfigurationSave(vi, "CH2_TEMP");
// Set the Resistance Config
stat = VTEXScanner_Configure(vi,
VTEXSCANNER_VAL_FUNCTION2_WIRE_RES,
10000,
10);
stat = VTEXScanner_DmmConfigurationSave(vi, "CH3_RES");
SETTING UP THE SCANLIST
The scanlist defines a list of channels and the measurements that will be made on each. The entire
scanlist is scanned when the device is triggered. The user does not need to take individual
measurements. The VTEXScanner help file defines the scanlist in BNF notation under
VTEXScanner IVI-C Driver→Attributes By Name→VTEXSCANNER_ATTR_LIST for a
32
VTEXScanner Driver Programming
www.vtiinstruments.com
complete description of the structure of the scanlist. I am putting the pertinent excerpt here for
easier understanding:
scanlist
scan_step
setup_phase
dmm_measure
::=
::=
::=
::=
scan_step , { "/"
[ setup_phase ] ,
switch_path , { (
slot_id , channel
, scan_step }
"|" , [ sweep_phase ]
"," | ";" ) , switch_path }
, "=" , dmm_config
In plain English, the first line defines the scanlist as a sequence of scan_steps separated by the “/”
character. However, in the actual application, multiple scan steps should not be needed.
The second line defines the scan_step as a setup_phase and a sweep_phase separated by the “|”
character. The setup_phase can set up outputs before reading the inputs. For example, prior to
scanning voltage channels, a user can close relays to power up an external device or use the
EX1200-3608 to apply a stimulus voltage in the setup_phase. This is a powerful tool that
provides a means to create simple test sequences that can run without the need for host
intervention which greatly reduces test execution time. Setup phases are executed prior to the start
of the sweep_phase (scan process). The example does not require a setup phase, but the “|” is still
needed.
The third line defines the sweep_phase as a series of sweep operations separated by the ‘;’
character. This is the focus of the example. A channel list of sweep operations will be created.
Each DMM measure operation is defined as a channel and a DMM Config (previously
configured) with an “=” character between them.
In this example, where the first three channels are being measured, the scanlist would be:
“|1!CH1_1=CH1_CJC;1!CH1_2=CH2_TEMP;1!CH1_3=CH3_RES”
Using the Web Page
NOTE
The web page provides a Scanlist Setup Wizard. The scanlist that this Wizard creates can be
used in IVI-C and IVI-COM programs.
Now that the DMM configurations are defined, they can be include in a scanlist. For this
example, ten samples will be taken per channel. To configure a scanlist, click the Add Step
button. Two white cells will appear under Setup and Sweep as shown in Figure 4-12.
Setup output channels and general
purpose relays here.
Define the channels that are to be
measured here.
FIGURE 4-12: CREATING A SCAN LIST
VTEXScanner Driver Programming
33
VTI Instruments Corp.
1) Click on the cell below the Sweep header. A black button appears as shown in Figure 4-13.
Clicking on the button opens the Sweep Wizard shown in Figure 4-14.
FIGURE 4-13: OPENING THE SWEEP WIZARD
2) The Sweep Wizard is an intuitive interface that allows a user to quickly set up scan lists based
on the DMM configurations created in the Setting Up DMM Configurations discussion.
FIGURE 4-14: THE SWEEP WIZARD
Enable the check boxes as shown in Figure 4-14 and choose the appropriate DMM Config from
the drop menu. Click the OK button once setup is complete. The scanlist window now includes
the channel list to be scanned as shown in Figure 4-15.
FIGURE 4-15: A SCANLIST ENTRY
NOTE
For end users who interested in developing their own application code, the soft front panel can still
be very useful in reducing development time. The string that is shown in the Sweep cell is
syntactically correct and can be pasted directly into the EX1200 scanner driver.
Using IVI-COM
scanner.Add("",
"2!CH1_1=CH1_CJC;2!CH1_2=CH2_TEMP;2!CH1_3=CH3_RES");
Using IVI-C
stat = VTEXScanner_Add(scanner, "",
"2!CH1_1=CH1_CJC;2!CH1_2=CH2_TEMP;2!CH1_3=CH3_RES");
34
VTEXScanner Driver Programming
www.vtiinstruments.com
SETTING UP TRIGGERING
As an LXI Class A device, the EX1266 supports all available trigger sources as defined in the LXI
specification. The EX1266 supports peer-peer communication over CAT-5e and LAN messages
generated by other Class A and/or B devices can be used to initiate a scanlist. Similarly, hardware
triggers on the WTB are generated by Class A devices can be used to coordinate scanlist
execution. By leveraging inter-module communication, system developers can remove the
responsibility of pacing a test from the host PC, eliminating the effects of latency and greatly
reducing test execution times.
The scanner has four triggers: two in and two out. They are as follows:
•
•
•
•
Scan Trigger In (Arm In in the driver): After the device is initiated, this trigger starts the
scanlist. When the device is initiated, nothing occurs until Scan Trigger In is received.
Step Trigger In (Trigger In the driver): After the Scan Trigger In has been received, this
trigger advances the scanlist to the next scan step. If there are multiple Scan Steps, each step
waits until this trigger is received. For each Scan Trigger received, there will be n Step
Triggers, where n is the number of scan steps.
Step Complete Out: This trigger is output each time a scan step is completed.
Scan Complete Out: This trigger is output once the scanlist is completed.
In this example, the scanlist is immediately initiated and scanlist execution is paced to take ten
measurements from each channel. Since no other devices are connected to the EX1266, there is no
need to output any scan list progress triggers.
Common Trigger Configurations
•
•
•
All Inputs as Immediate, All Outputs as NONE. Every time the instrument is initiated, it
runs the entire scan list, Scan Count times, without waiting for a trigger and without creating
output triggers.
Scan Trigger In as Immediate, Step Trigger In set to a Trigger Source. This makes the
device ready to execute the first scan step once initiated. Each individual scan step is paced by
the trigger source.
Scan Trigger In is set to a Trigger Source and Step Trigger In is set to Immediate. This
causes the instrument to wait until it receives the Scan Trigger before running the scanlist.
When this trigger is received, it runs the entire scanlist without stopping and wait for the Scan
Trigger signal again. This will repeat for “Scan Count” times.
Using the Web Page
Once the scanlist is configured, the trigger properties should be defined that will govern the
execution of the scanlist as shown in Figure 4-16. The trigger properties should be set as shown in
the above figure below.
FIGURE 4-16: TRIGGER PROPERTIES
VTEXScanner Driver Programming
35
VTI Instruments Corp.
Using IVI-COM
// Setup the Triggers
// This setup is the default state, but shows how to set a trigger.
// Simply change the "Immediate" to the desired ARM source. It is
// possible to enable multiple sources for each event and to set the //
for both arm and trigger
same source
// Set the Arm Source.
// This corresponds to the web page Scan Trigger In
// Disable all sources so the default Immediate does not override other
// sources
scanner.System.Arm.Sources.DisableAll();
// Enable the Immediate Source
scanner.System.Arm.Sources.get_Item("Immediate").Enabled = true;
// Note if there are multiple sources enabled the following command
// will OR the sources together meaning if any source is asserted the //
trigger. The default is the sources being ANDed
// together meaning all sources must be asserted at the same time for //
to trigger.
//scanner.System.Arm.Sources.OrEnabled = true;
device will
the device
// Setup the trigger source.
// This corresponds to the Front Panel Step Trigger In
scanner.System.Trigger.TriggerSource = "Immediate";
// Set the scanlist to run 10 times
scanner.System.Arm.ArmCount = 10;
Using IVI-C
// Setup the Arm Source
// This corresponds to the SFP Scan Trigger In
VTEXScanner_SystemArmSourceConfigure(vi,
"Immediate",
VI_TRUE,
0);
// Set the Trigger Source
// This corresponds to the SFP Step Trigger In
VTEXScanner_SetAttributeViString(vi,
VI_NULL,
VTEXSCANNER_ATTR_SYSTEM_TRIGGER_TRIGGER_SOURCE,
"Immediate");
// Set the Trigger Count.
// This is how many times the scanlist will run.
// This corresponds to Scan Count on the SFP
VTEXScanner_GetAttributeViInt32(vi,
VI_NULL,
VTEXSCANNER_ATTR_SYSTEM_TRIGGER_TRIGGER_COUNT,
10);
36
VTEXScanner Driver Programming
www.vtiinstruments.com
STARTING THE SCAN AND RETRIEVING DATA
Using the Web Page
Prior to initiating a scan list, it is important to determine how the data will be viewed. Depending
on how fast the scan list executes (which is highly dependent on the DMM configuration), it may
be difficult to view all of the data in the LED display. Data can be viewed in tabular form by
checking on the Get Continuous box shown in Figure 4-17.
FIGURE 4-17: RETRIEVE DATA PROPERTIES
NOTE
If the data does not need to be viewed live and will either be saved to disk or viewed after
acquisition is complete, deselect this button. Data can be retrieved post-acquisition by clicking the
Get button.
Click the Initiate button in the Trigger Properties window. The scan list will start to execute and
the sound of relays clicking should be heard as the scan list advances, as well as viewing retrieved
data in the tabular window (assuming Get Continuous is selected, as shown in Figure 4-18).
System Status: Idle means
the scanning process is
complete
LED Display shows the last
measurement made, and function
The data is returned with
IEEE 1588 timestamps. This
is optional in the API.
Measured data in tabular form returned with
engineering units.
FIGURE 4-18: COMPLETING A MEASUREMENT SEQUENCE
VTEXScanner Driver Programming
37
VTI Instruments Corp.
EXPORTING DATA TO A .CSV FILE
It is very easy to export the acquired data to a .csv file that can be used in any application (e.g.
Excel) for archiving or for analysis. To export acquired data, click on the Save Data button. A
prompt will appear, as shown in Figure 4-19, providing an option to save the file a local hard
drive.
FIGURE 4-19: SAVING DATA TO DISK
Using IVI-COM
// Initiate the Scan
scanner.Initiate();
// Wait until scanning is finished
while (scanner.IsScanning)
{
System.Threading.Thread.Sleep(100);
}
// Determine how much data is in the FIFO
int count = scanner.FIFOCount;
// Declare Memory to copy the data to.
double [] data = new double[count];
double [] seconds = new double[count];
double [] fraction = new double[count];
// Read the data
scanner.Read(10000, // How much time to wait to read the data
count, // How many samples to read
ref data, ref seconds, ref fraction); // Where to store the data
Using IVI-C
// Start the scan
stat = VTEXScanner_Initiate(vi);
if(stat) throw stat;
do
{
// Wait for scanning to finish
stat = VTEXScanner_GetAttributeViBoolean(vi,
VI_NULL,
VTEXSCANNER_ATTR_IS_SCANNING,
&isScanning);
if(stat) throw stat;
38
VTEXScanner Driver Programming
www.vtiinstruments.com
}while(isScanning == VI_TRUE);
stat = VTEXScanner_GetAttributeViInt32(vi,
VI_NULL,
VTEXSCANNER_ATTR_FIFO_COUNT,
&fifoCount);
data = (ViReal64 *)malloc(sizeof(ViReal64) * fifoCount);
seconds = (ViReal64 *)malloc(sizeof(ViReal64) * fifoCount);
fraction = (ViReal64 *)malloc(sizeof(ViReal64) * fifoCount);
stat = VTEXScanner_Read(vi,
10000,
// Timeout
fifoCount,
// Number of scans to read
fifoCount,
// Size of the data buffer
data,
// Data buffer
&dataActual,
// Actual Number read
fifoCount,
// Size of the seconds buffer
seconds,
// Seconds Buffer
&secondsActual,
// Actual Seconds Read
fifoCount,
// Size of the fraction buffer
fraction,
// Fraction Buffer
&fractionActual);
// Actual Fraction read
VTEXScanner Driver Programming
39
VTI Instruments Corp.
APPENDIX A: IVI-COM SOURCE LISTING
using
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Text;
VTI.VTEXScanner.Interop;
namespace ScannerExample
{
class Program
{
static void Main(string[] args)
{
try
{
VTEXScanner scanner = new VTEXScanner();
scanner.Initialize("TCPIP::10.20.11.145::INSTR", true, true, "");
// Use this so there are no repeated configurations
scanner.Dmm.Configuration.DeleteAll();
//Setup The CJC Configuration
scanner.Dmm.Configure(VTEXScannerDmmFunctionEnum.VTEXScannerDmmFunctionTemperature,
100, 0.1);
scanner.Dmm.Temperature.TransducerType =
VTEXScannerDmmTransducerTypeEnum.VTEXScannerDmmTransducerTypeThermistor;
scanner.Dmm.Temperature.Thermistor.Resistance = 10000;
scanner.Dmm.Temperature.IsReferenceJunction = true;
scanner.Dmm.Configuration.Save("CH1_CJC");
// Setup The Thermocoupel Configuration
scanner.Dmm.Configure(VTEXScannerDmmFunctionEnum.VTEXScannerDmmFunctionTemperature,
1200, 0.1);
scanner.Dmm.Temperature.IsReferenceJunction = false;
scanner.Dmm.Temperature.TransducerType =
VTEXScannerDmmTransducerTypeEnum.VTEXScannerDmmTransducerTypeThermocouple;
scanner.Dmm.Temperature.Thermocouple.Type =
VTEXScannerDmmThermocoupleTypeEnum.VTEXScannerDmmThermocoupleTypeK;
scanner.Dmm.Temperature.Thermocouple.RefJunctionType =
VTEXScannerDmmRefJunctionTypeEnum.VTEXScannerDmmRefJunctionTypeExternal;
scanner.Dmm.Configuration.Save("CH2_TEMP");
// Setup the Resistance Configuration
scanner.Dmm.Configure(VTEXScannerDmmFunctionEnum.VTEXScannerDmmFunction2WireRes,
10000, 10);
scanner.Dmm.Configuration.Save("CH3_RES");
// Setup the Scanlist
scanner.Add("", "2!CH1_1=CH1_CJC;2!CH1_2=CH2_TEMP;2!CH1_3=CH3_RES");
// Setup the Triggers
// This setup is the default state, but shows how to set a trigger.
Simply
//
Change the "Immediate" to the desired ARM source. It is possilbe
//
multiple sources for each event and to set the same source for
//
trigger
to enable
both arm and
40
VTEXScanner Driver Programming
www.vtiinstruments.com
/*
// Set the Arm. This corresponds to the web page Scan Trigger In
scanner.System.Arm.Sources.DisableAll();
scanner.System.Arm.Sources.get_Item("Immediate").Enabled = true;
Enable the Immediate Source
//
// Note if there are multiple sources enabled the following command
will OR the sources
// together meaning if any source is asserted the device will
trigger. The default is
// the sources being ANDed together meaning all sources must be
asserted at the same
// time for the device to trigger.
// scanner.System.Arm.Sources.OrEnabled = true;
// Setup the trigger source. This corresponds to the Front Panel Step
Trigger In
scanner.System.Trigger.TriggerSource = "Immediate";
* */
scanner.System.Arm.ArmCount = 10;
// Initiate the Scan
scanner.Initiate();
// Wait until scanning is finished
while (scanner.IsScanning)
{
System.Threading.Thread.Sleep(100);
}
// Determine how much data is in the FIFO
int count = scanner.FIFOCount;
// Declare Memory to copy the data to.
double [] data = new double[count];
double [] seconds = new double[count];
double [] fraction = new double[count];
// Read the data
scanner.Read(10000, // How much time to wait to read the data
count, // How many samples to read
ref data, ref seconds, ref fraction); // Where to store the data
scanner.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}
VTEXScanner Driver Programming
41
VTI Instruments Corp.
APPENDIX B: IVI-C SOURCE LISTING
#include "VTEXScanner.h"
#include <stdlib.h>
#include <stdio.h>
ViStatus SetupCJC(ViSession vi);
ViStatus SetupTemp(ViSession vi);
ViStatus SetupRes(ViSession vi);
int main()
{
ViSession vi = VI_NULL;
ViStatus stat = VI_SUCCESS;
ViBoolean isScanning = VI_TRUE;
ViInt32 fifoCount = 0;
ViReal64 *data = VI_NULL;
ViReal64 *seconds = VI_NULL;
ViReal64 *fraction = VI_NULL;
ViInt32 dataActual, secondsActual, fractionActual;
try
{
// Initialize the instrument
stat = VTEXScanner_init("TCPIP::10.20.11.145::INSTR", VI_TRUE, VI_TRUE,
&vi);
if(stat != VI_SUCCESS) throw stat;
stat = VTEXScanner_DmmConfigurationDeleteAll(vi);
if(stat) throw stat;
// Setup the DMM Configurations
stat = SetupCJC(vi);
if(stat) throw stat;
stat = SetupTemp(vi);
if(stat) throw stat;
stat = SetupRes(vi);
if(stat) throw stat;
// Setup the Scanlist
stat = VTEXScanner_Add(vi, "",
"2!CH1_1=CH1_CJC;2!CH1_2=CH2_TEMP;2!CH1_3=CH3_RES");
// Setup the Arm Source
// This corresponds to the SFP Scan Trigger In
VTEXScanner_SystemArmSourceConfigure(vi,
"Immediate",
VI_TRUE,
0);
if(stat) throw stat;
// Set the Trigger Source
// This corresponds to the SFP Step Trigger In
VTEXScanner_SetAttributeViString(vi,
VI_NULL,
VTEXSCANNER_ATTR_SYSTEM_TRIGGER_TRIGGER_SOURCE,
"Immediate");
if(stat) throw stat;
// Set the Trigger Count.
// This is how many times the scanlist will run.
42
VTEXScanner Driver Programming
www.vtiinstruments.com
// This corresponds to Scan Count on the SFP
VTEXScanner_SetAttributeViInt32(vi,
VI_NULL,
VTEXSCANNER_ATTR_SYSTEM_ARM_ARM_COUNT,
10);
if(stat) throw stat;
// Start the scan
stat = VTEXScanner_Initiate(vi);
if(stat) throw stat;
do
{
// Wait for scanning to finish
stat = VTEXScanner_GetAttributeViBoolean(vi,
VI_NULL,
VTEXSCANNER_ATTR_IS_SCANNING,
&isScanning);
if(stat) throw stat;
}while(isScanning == VI_TRUE);
stat = VTEXScanner_GetAttributeViInt32(vi,
VI_NULL,
VTEXSCANNER_ATTR_FIFO_COUNT,
&fifoCount);
data = (ViReal64 *)malloc(sizeof(ViReal64) * fifoCount);
seconds = (ViReal64 *)malloc(sizeof(ViReal64) * fifoCount);
fraction = (ViReal64 *)malloc(sizeof(ViReal64) * fifoCount);
stat = VTEXScanner_Read(vi,
10000,
// Timeout
fifoCount,
// Number of scans to read
fifoCount,
// Size of the data buffer
data,
// Data buffer
&dataActual,
// Actual Number read
fifoCount,
// Size of the seconds buffer
seconds,
// Seconds Buffer
&secondsActual,
// Actual Seconds Read
fifoCount,
// Size of the fraction buffer
fraction,
// Fraction Buffer
&fractionActual);
// Actual Fraction read
}
catch(ViStatus error)
{
// Handle Errors here
char msg[256];
ViStatus code = VI_SUCCESS;
do
{
VTEXScanner_GetError(VI_NULL, &code, 256, msg);
printf("Error 0x%08X:%s\n", code, msg);
}while(code != VI_SUCCESS);
}
if(vi != VI_NULL)
VTEXScanner_close(vi);
}
ViStatus SetupCJC(ViSession vi)
{
ViStatus stat;
stat = VTEXScanner_Configure(vi,
VTEXScanner Driver Programming
43
VTI Instruments Corp.
VTEXSCANNER_VAL_FUNCTION_TEMPERATURE,
100,
0.1);
if(stat) return stat;
stat = VTEXScanner_SetAttributeViInt32(vi,
VI_NULL,
VTEXSCANNER_ATTR_DMM_TEMPERATURE_TRANSDUCER_TYPE,
VTEXSCANNER_VAL_TRANSDUCER_TYPE_THERMISTOR);
if(stat) return stat;
stat = VTEXScanner_SetAttributeViReal64(vi,
VI_NULL,
VTEXSCANNER_ATTR_DMM_TEMPERATURE_THERMISTOR_RESISTANCE,
10000);
if(stat) return stat;
stat = VTEXScanner_SetAttributeViBoolean(vi,
VI_NULL,
VTEXSCANNER_ATTR_DMM_TEMPERATURE_IS_REFERENCE_JUNCTION,
VI_TRUE);
if(stat) return stat;
stat = VTEXScanner_DmmConfigurationSave(vi, "CH1_CJC");
return stat;
}
ViStatus SetupTemp(ViSession vi)
{
ViStatus stat;
// Set the TC Config
stat = VTEXScanner_Configure(vi,
VTEXSCANNER_VAL_FUNCTION_TEMPERATURE,
100,
1.0);
if(stat) return stat;
stat = VTEXScanner_SetAttributeViInt32(vi,
VI_NULL,
VTEXSCANNER_ATTR_DMM_TEMPERATURE_TRANSDUCER_TYPE,
VTEXSCANNER_VAL_TRANSDUCER_TYPE_THERMOCOUPLE);
if(stat) return stat;
stat = VTEXScanner_DmmTemperatureThermocoupleConfigure(vi,
VTEXSCANNER_VAL_THERMOCOUPLE_TYPE_K,
VTEXSCANNER_VAL_REF_JUNCTION_EXTERNAL);
if(stat) return stat;
stat = VTEXScanner_SetAttributeViBoolean(vi,
VI_NULL,
VTEXSCANNER_ATTR_DMM_TEMPERATURE_IS_REFERENCE_JUNCTION,
VI_FALSE);
if(stat) return stat;
stat = VTEXScanner_DmmConfigurationSave(vi, "CH2_TEMP");
return stat;
}
ViStatus SetupRes(ViSession vi)
{
ViStatus stat;
// Set the Resistance Config
stat = VTEXScanner_Configure(vi,
VTEXSCANNER_VAL_FUNCTION2_WIRE_RES,
10000,
10);
if(stat) return stat;
stat = VTEXScanner_DmmConfigurationSave(vi, "CH3_RES");
return stat;
}
44
VTEXScanner Driver Programming