IVI Instrument Driver
Programming Guide
LabWindows/CVI Edition
Oct 2020 Revision 2.2

Product names and company names that appear in this guide are the trademarks or registeredtrademarks of their respective companies.
© 2020 Kikusui Electronics Corp.

Contents

Contents
Introduction............................................................................................................................. 4
Instrument driver to use with LabWindows/CVI.............................................................. 4
Usable Interfaces........................................................................................................... 4
Programming Using Specific Interfaces.................................................................................. 5
Preparation for programming......................................................................................... 5
Creating a new project........................................................................................... 5
Loading an instrument driver................................................................................. 6
Configuring the program................................................................................................. 7
Setting the Initialize With Options function............................................................. 7
Setting the Close function...................................................................................... 9
Adding other functions......................................................................................... 10
Building projects....................................................................................................11
Executing Programs..................................................................................................... 12
Setting the breakpoints........................................................................................ 12
By executing a program....................................................................................... 12
Values to be stored in variables vi and vs............................................................ 12
Explanation of functions............................................................................................... 13
Starting sessions.................................................................................................. 13
Setting the channel name.................................................................................... 15
Closing sessions.................................................................................................. 15
Handling errors............................................................................................................. 16
Programming using a class interface.................................................................................... 17
Preparation for programming....................................................................................... 17
Creating virtual instruments................................................................................. 17
Creating a new project......................................................................................... 23
Loading an instrument driver............................................................................... 24
Configuring the program............................................................................................... 25
2

KIKUSUI Electronics Corp.

Contents
Setting the Initialize With Options function........................................................... 25
Setting the Close function.................................................................................... 27
Adding other functions......................................................................................... 28
Building projects................................................................................................... 28
Executing Programs..................................................................................................... 29
Setting the breakpoints........................................................................................ 29
By executing a program....................................................................................... 29
Values to be stored in variables vi and vs............................................................ 29
Explanation of functions............................................................................................... 30
Starting sessions.................................................................................................. 30
Setting the channel name.................................................................................... 32
Closing sessions.................................................................................................. 32
Handling errors............................................................................................................. 33
Replacing instrument.................................................................................................... 34

IVI Instrument Driver Programming Guide (LabVIEW Edition)

3

Introduction

Introduction
This guide shows examples of using a KikusuiPwr IVI Instrument Driver (KIKUSUI PWR-01
series DC power supply). IVI instrument driver made by other manufacturers and ones forother models can be used in almost the same way.
This guide explains using the LabWindows/CVI 2019 referring to the case to create a 32-bit(x86) program that runs on Windows 10 (x64) as an example.

Instrument driver to use with LabWindows/CVI
This guide recommends the IVI-C instrument driver and explains referring to the procedureof programming using the IVI-C instrument driver as an example.
Since LabWindows/CVI is a development environment assuming the use of C language, itis easier to use a function-based C DLL than a COM DLL. Since the IVI-C instrument driveris created by extending the architecture for the LabWindows/CVI instrument driver, it iscompatible with LabWindows/CVI.

Usable Interfaces
The IVI instrument driver supports the following two interfaces:• Specific interface
It is the interface specific to instrument drivers. It will enable you to make the most of thefunctions of the instrument to be used.
• Class interface
It is the interface of instrument class defined in the IVI specifications.
Interchangeability is available, but the use of model-specific functions will be limited.
This guide explains how to program using each interface.

Memo• The instrument class to which the instrument driver belongs can be checked from theWindows start menu’s [Kikusui] > [KikusuiPwr IVI Driver 1.0.0 Documentation].
• In the case that the instrument driver does not belong to any instrument class, noapplications can be created that use interchangeability as the class interface is notavailable.

4

KIKUSUI Electronics Corp.

Programming Using Specific Interfaces

Programming Using Specific Interfaces
This section describes the procedures for programming using a specific interface. The specific interface will enable you to make the most of the functions specific to the instrument
driver.

Memo
In the case of a specific interface, the interchangeability function cannot be used. Whenusing the interchangeability function, be sure to use the class interface. (p.17)

Preparation for programming
Creating a new projectAn example of using the IVI-C driver in a new application is explained below:

1

Start LabWindows/CVI.

2

Click [New] > [Project].

Welcome page is displayed.

If the welcome page is not displayed and the existing projects are imported, click [File]> [New] > [Project (*.prj)].
A new project will be created.

3

Click [File] > [Save Untitled.prj As] to save the project.

4

Click [File] > [New] > [Source (*.c)].

5

Click [File] > [Save Untitled1.c As] to save the source file.

6

Click [File] > [Add Ex01.c to Project].

In this case, save it as “Ex01.prj”.

A source file is created.

In this case, save it as “Ex01.c”.

The source file is added to the project.
This completes the creation of a new project.

IVI Instrument Driver Programming Guide (LabVIEW Edition)5

Programming Using Specific Interfaces

Loading an instrument driver

1

2

Click [Instrument] > [Load].

Load “kipwr.fp” saved in “C:/Program Files (x86)/IVI Foundation/IVI/
Drivers/kipwr” directory.
In the [Instrument] menu, [KikusuiPwr01] will be added.

6

KIKUSUI Electronics Corp.

Programming Using Specific Interfaces

Configuring the program
Setting the Initialize With Options function
Set the Initialize With Options function, declare the variables and insert them into the source
code.
Setting the parameters

123Open the source code of C (Ex01.c) added to the project.
Click [Instrument] > [KikusuiPwr01].
Select Function Panel will be displayed.

Click [Initialize With Options] and click [Select].

The function panel of Initialize With Options will be displayed.

4

Set the values for each parameter.

IVI Instrument Driver Programming Guide (LabVIEW Edition)

7

Programming Using Specific Interfaces
This section explains taking the case in which the instrument is connected by the
LAN interface and the IP address is 192.168.1.5 as an example. As the parametersof ResourceName and OptionString are character strings, enclose them in quotation
marks.
Parameters
ResourceName
IdQuery
Reset
OptionString
Vi
StatusValue“TCPIP::192.168.1.5::INSTR”
On (VI_TRUE in the function call description)
On (VI_TRUE in the function call description)“QueryInstrStatus=1”&vi
vsDeclaring variable
Declare the variable entered in Vi and Status.

1
2
3
4
5
6

Click the Parameter Vi on the function panel.
Click [Code] > [Declare Variable].
Declare Variable dialog box will be displayed.

Check both the Execute declaration in Interactive Window and the Add
declaration to top of target file “Ex01.c”.
Click [OK].
Click the Parameter Status on the function panel.
Operate in the same way as steps 2 to 4.
This completes the declaration.

Inserting the code to recall the Initialize With Options function

1

8

Click [Code] > [Insert Function Call].
The code to recall the kipwr_InitWithOptions function will be inserted to the sourcecode (Ex01.c).

KIKUSUI Electronics Corp.

Programming Using Specific Interfaces

Setting the Close function
Set the Close function in the same way as the Initialize With Options function, and insert
them into the source code.

1

Click [Instrument] > [KikusuiPwr01].

2

Click [Close] and then [Select].

Select Function Panel will be displayed.

The function panel of Close will be displayed.

3Enter vi in the parameter [Vi], and enter vs in [Status].

4

Click [Code] > [Insert Function Call].
The code to recall the kipwr_close function will be inserted to the source code
(Ex01.c).

IVI Instrument Driver Programming Guide (LabVIEW Edition)9

Programming Using Specific Interfaces

Adding other functions
By selecting [Ex01.c] tab, the source code will be displayed. By executing the steps inpages 7 to 9, the source code will be as follows:
static ViStatus vs;static ViSession vi;
vs = kipwr_InitWithOptions (“TCPIP::192.168.1.5::INSTR”, VI_TRUE, VI_
TRUE, “QueryInstrStatus=1”, &vi);
vs = kipwr_close (vi);In order to make this source code an executable program, include the following content:• Specify loading of the included file of the instrument driver.
• Enclose the recall to InitWithOptions and close in the “main” function.
• Between the recalls to InitWithOptions and close, add a recall code for the function setting the voltage and current, and the function controlling the output ON/OFF. Besides themethod of inserting it using the function panel, there is also the method of entering thesource code directly with the editor as shown below.
Shown below is a sample that opens an instrument driver session, sets voltage, current,
and output, and closes immediately.
#include <kipwr.h>static ViStatus vs;static ViSession vi;
void main(){vs = kipwr_InitWithOptions (“TCPIP::192.168.1.5::INSTR”, VI_TRUE, VI_
TRUE, “QueryInstrStatus=1”, &vi);
vs = kipwr_ConfigureVoltageLevel (vi, “”, 20);
vs = kipwr_ConfigureCurrentLimit (vi, “”, KIPWR_VAL_CURRENT_REGULATE,
2.0);
vs = kipwr_ConfigureOutputEnabled (vi, “”, 1);
vs = kipwr_close (vi);}Memo
IVI instrument drivers for DC power supply units are usually structured in consideration of multiple channels. Therefore, many of the device setting functions have theChannelName parameter.

10

KIKUSUI Electronics Corp.

Programming Using Specific Interfaces

Building projects

1

Click [Build] > [Build].
This completes building.

IVI Instrument Driver Programming Guide (LabVIEW Edition)

11

Programming Using Specific Interfaces

Executing Programs
This section introduces the breakpoints that are useful for debugging at the time of program
execution and explains how to run the program and the values stored in variables after
execution.

Setting the breakpoints
It is not clear how to execute the program of the sample on page 10 because it is notinteractive. Inserting a breakpoint in a recall line pauses the program before it is recalled sothat you can check the status of the program in progress.

1
2

Move the cursor to the row where you want to insert the breakpoint.
Click [Run] > [Toggle Breakpoint].
Breakpoints will be set.

By executing a program

1

Click [Run] > [Debug Ex01.exe].

2

Click [Run] > [Continue].

The program will be executed. Pause before calling the row where the breakpoint has
been set.

Program execution will be restarted.

Values to be stored in variables vi and vsIn the case of being able to open a session for an instrument driver, vi will store a session
handle (usually 0x00000001 or more as an IVI handle). The execution result (0x00000000
on success or a negative value on failure) will be stored in vs.

12

KIKUSUI Electronics Corp.

Programming Using Specific Interfaces

Explanation of functions
This section describes the functions comprising the program, including their contents andsetting values.

Memo
The IVI-C instrument driver and VXI Plug&Play instrument driver have the notation <prefix> as a rule for function names. This notation represents the identification name ofeach instrument driver.
For example, the notation “<prefix>_init()” is “kipwr_init()” in the kipwr instrument driver.

Starting sessions
To start a session on a specific interface, use <prefix>_InitWithOptions.
vs = kipwr_InitWithOptions (“TCPIP::192.168.1.5::INSTR”, VI_TRUE, VI_
TRUE, “QueryInstrStatus=1”, &vi);
The parameters that can be set in <prefix>_InitWithOptions are as follows:
Parameters

Type

Description

ResourceName ViRsrc(const char*)

idQuery
Reset
OptionString
Vi

This is a character string of VISA resource names determined by the I/O interface, address, etc. to which the
instrument is connected.

For example, when an instrument with an IP address of
192.168.1.5 is connected to a LAN and controlled by a
VXI-11 interface, it will be “TCPIP::192.168.1.5::INSTR”.
ViBoolean
In the case that VI_TRUE is specified, an ID query suchas “*IDN?” is issued in response to the instrument tomake queries for model information.
ViBoolean
In the case that VI_TRUE is specified, the “*RST” command is issued to reset the settings of the instrument.
ViConstString The settings of the IVI definition can be changed.
(const char*) (p.13)
ViSession*
Receive an instrument session (pointers passed).

IVI Instrument Driver Programming Guide (LabVIEW Edition)13

Programming Using Specific Interfaces
Setting OptionString
In OptionString, the following IVI definitions can be set up:
IVI definition

Default value

RangeCheck
Cache
Simulate
QueryInstrStatus
RecordCoercions
Interchange Check

VI_TRUE
VI_TRUE
VI_FALSE
VI_FALSE
VI_FALSE
VI_FALSE

OptionString is a parameter of the character string. The following is a sample:
QueryInstrStatus = VI_TRUE, Cache = VI_TRUE, DriverSetup=12345
Regarding the formatting, note the following:• If the set value is not specified, the default value will be applied.
• The set value is of the ViBoolean type. Either of “VI_TRUE”, “VI_FALSE”, “1” or “0” can beset.
• Function names and values are case-insensitive. Uppercase and lowercase letters are notdistinguished.
• When setting multiple items, they should be separated by commas.
• Depending on the instrument driver, the “DriverSetup” parameters are supported.
The “DriverSetup” is a parameter that specifies items not defined in the IVI specifications when recalling InitWithOptions. Usage and formatting are dependent on the driver.
Therefore, in the case of setting the “DriverSetup”, it should be specified as the last item inthe “Option String”. For the details of what is specified in “DriverSetup”, see the Readmeof the driver or the online help.

14

KIKUSUI Electronics Corp.

Programming Using Specific Interfaces

Setting the channel nameIn the case of power supplies and oscilloscopes, the IVI instrument drivers are designedwith the assumption that they are equipped with multiple channels. Therefore, many of thedriver functions that work on the instrument panel settings need to specify a channel for thesecond parameter, as shown below:
vs = kipwr_ConfigureVoltageLevel( vi, “”, 20.0);
In this example, a blank (“”) is specified as the channel name. If the number of channels isone, a blank is fine, but if there are multiple channels, it needs to be specified explicitly.
The names of the channels that can be used depend on the instrument driver. For details,
see the help for each driver.

Closing sessions
To close the instrument driver sessions, use <prefix>_close.
vs = kipwr_close (vi);

IVI Instrument Driver Programming Guide (LabVIEW Edition)

15

Programming Using Specific Interfaces

Handling errors
If a value out of range is passed to a parameter or an unsupported function is recalled, anerror can occur in the instrument driver. In the IVI-C instrument driver, all errors that haveoccurred in the instrument driver are conveyed to the client program as a return value of
ViStatus-type, as shown below.
Range of values
vs = 0vs > 0vs < 0Description
Success
Warning
Error

Although no error correction has been done in the previous examples, the error_message
function can be used to convert a ViStatus-type return value into readable messages. The
error_message exceptionally accepts VI_NULL as ViSession. The receiving buffer size
should be 256 bytes or more.
char buf[256];...
kipwr_error_message (VI_NULL, vs, buf);

16

KIKUSUI Electronics Corp.

Programming using a class interface

Programming using a class interface
This section describes the procedures for programming using a class interface. In the classinterface, you can achieve interchangeability with an instrument class interface by programming using the instrument class interface defined in the IVI specifications. Using interchangeability, the instruments can be replaced without recompiling and linking the application once again.

Memo• To utilize interchangeability, an IVI-C instrument driver of the same class of instrument must be provided in response to both models before and after replacement.
Interchangeability between different classes of instrument is not available.
• In programming using the class interface, the machine-specific functions that are available are limited. To maximize the use of model-specific functions, program using thespecific interface (p.5).

Preparation for programming
Creating virtual instruments
To create an application that uses the interchangeability functions, it is necessary to createa virtual instrument in advance.

Memo
To avoid loss of interchangeability function, do not include descriptions dependent on
specific IVI-C instrument drivers (e.g. direct calls to kipwr_init function) or specific VISA
addresses (resource names) (e.g. “TCPIP::192.168.1.5:: INSTR”) in the applicationcode.

In the IVI specifications, the interchangeability function is achieved by placing the IVI configuration store outside the instrument drivers and applications. The application is not controlled by using model-specific instrument drivers directly, but through a special instrument
driver, called the instrument class interface.

IVI Instrument Driver Programming Guide (LabVIEW Edition)17

Programming using a class interface
At the time of control, select the instrument driver DLLs according to the contents of the IVI
configuration store and access the instrument driver loaded indirectly through a model-independent class interface function.
An XML file (C:/ProgramData/IVI Foundation/IVI/IviConfigurationStore.xml) will be used forthe IVI configuration store. Mainly IVI instrument drivers and some VISA/IVI configuration
tools access through the IVI Configuration Server DLL. Applications do not usually use it.
When using LabWindows/CVI, use the NI-MAX (NI Measurement and Automation Explorer)software manufactured by National Instruments to configure the IVI driver.
This section describes the procedure of creating a virtual instrument using NI-MAX.
Creating Driver Sessions1
2
3

Launch NI-MAX and check the hierarchy under the [IVI Drivers] in the tree
display on the left of the screen.
Right-click [Driver Sessions] and select [Create New (case-sensitive)].
Set a name for Driver Sessions.
Here, set it as [mySupply].

Driver Sessions have now been created.

18

KIKUSUI Electronics Corp.

Programming using a class interface
Creating Hardware Asset
In Hardware Asset, specify with what path the instruments to be used will be connected.

1
2
3
4

Select the [Hardware] tab.

Click [Add] to create a new [Hardware Asset].
Set a name for Hardware Asset.
Here, set it as [mySupply].

At [Resource Descriptor], specify the VISA address to which the instrument is connected.
In this example, [TCPIP::192.168.1.5::inst0::INSTR] is specified.

Hardware Asset has now been created.

IVI Instrument Driver Programming Guide (LabVIEW Edition)

19

Programming using a class interface
Setting Software Module
In the Software Module, the instrument driver module (DLL module) is set.

1
2

Select the [Software] tab.

From the [Software Module] list, select the instrument driver module to beused.
In this example, [kipwr] is selected.

Software Module has now been set.

20

KIKUSUI Electronics Corp.

Programming using a class interface
Creating Virtual NameWith Virtual Name, a virtualized name is created for the channel name of the instrument
driver. This is because different instrument drivers have different valid channel names in thecase of instrument drivers requiring channel specification.

1

Select the [Virtual Names] tab.

2

Click [Add] to add a virtual name and enter [Track_A] in [Virtual Name].

3

On the [Physical Name] list, the channel on which the instrument operates will be
displayed.

In the [Physical Name] column, select a channel name displayed on thelist or enter a valid channel name.
In this example, select or enter [OutputChannel1].

Memo
In some cases, not all channel names may be displayed, depending on the driver's
mounting conditions or the configuration of the multi-channel power supply unit. For
details on the names of the available channels for the driver, see the Readme document for each driver or the online help.

Virtual Name has now been created.

IVI Instrument Driver Programming Guide (LabVIEW Edition)

21

Programming using a class interface
Setting Logical Name
A Logical Name refers to the name of a virtual instrument that is configured in NI-MAX.

1
2
3
4
5

Check the hierarchy under [IVI Drivers] in the tree display on the left sideof the screen.
Right-click [Logical Name] and select [Create New (case-sensitive)].
Set a name for Logical Name.
Here, set it as [mySupply].

In [Driver Session], select [mySupply].
Click [Save IVI Configuration] on the toolbar and save the settings.

Logical Name has now been set.
This completes the creation of the virtual instrument.

22

KIKUSUI Electronics Corp.

Programming using a class interface

Creating a new projectAn example of using the IVI-C driver in a new application is explained below:

1

Start LabWindows/CVI.

2

Click [New] > [Project].

Welcome page is displayed.

If the welcome page is not displayed and the existing projects are imported, click [File]> [New] > [Project (*.prj)].
A new project will be created.

3

Click [File] > [Save Untitled.prj As] to save the project.

4

Click [File] > [New] > [Source (*.c)].

5

Click [File] > [Save Untitled1.c As] to save the source file.

6

Click [File] > [Add Ex02.c to Project].

In this case, save it as “Ex02.prj”.

A source file is created.

In this case, save it as “Ex02.c”.

The source file is added to the project.
This completes the creation of a new project.

IVI Instrument Driver Programming Guide (LabVIEW Edition)

23

Programming using a class interface

Loading an instrument driver

1

2

Click [Instrument] > [Load].

Load the “IviDCPwr.fp” saved in “C:/Program Files (x86)/IVI Foundation/
IVI/Drivers/IviDCPwr” directory.
In the [Instrument] menu, [IviDCPwr Class Driver] will be added.

24

KIKUSUI Electronics Corp.

Programming using a class interface

Configuring the program
Set the Initialize With Options function, declare the variables and insert them into the source
code.

Setting the Initialize With Options function
Setting the parameters

123Open the source code of C (Ex02.c) added to the project.
Click [Instrument] > [IviDCPwr Class Driver].
Select Function Panel will be displayed.

Click [Initialize With Options] and click [Select].

The function panel of Initialize With Options will be displayed.

4

Set the values for each parameter.

IVI Instrument Driver Programming Guide (LabVIEW Edition)25

Programming using a class interface
As the parameters of Logical Name and OptionString are character strings, enclose
them in quotation marks.
Parameters
Logical Name
ID QueryReset Device
Option String
Instrument Handle
StatusValue“mySupply”
Yes (VI_TRUE in the function call description)
Yes (VI_TRUE in the function call description)
Leave as default.
&vi
vsDeclaring variable
Declare the variables entered in [Instrument Handle] and [Status].

1
2
3
4
5
6

Click the parameter Instrument Handle in the function panel.
Click [Code] > [Declare Variable].
Declare Variable dialog box will be displayed.

Check both the Execute declaration in Interactive Window and the Add
declaration to top of target file “Ex02.c”.
Click [OK].
Click the Parameter Status on the function panel.
Operate in the same way as steps 2 to 4.
This completes the declaration.

Inserting the code to recall the Initialize With Options function

1

26

Click [Code] > [Insert Function Call].
The code to recall the IviDCPwr_InitWithOptions function will be inserted to the sourcecode (Ex02.c).

KIKUSUI Electronics Corp.

Programming using a class interface

Setting the Close function
Set the Close function in the same way as the Initialize With Options function, and insert
them into the source code.

1

Click [Instrument] > [IviDCPwr Class Driver].

2

Click [Close] and then [Select].

Select Function Panel will be displayed.

The function panel of Close will be displayed.

3Enter vi in the parameter [Instrument Handle], and enter vs in [Status].

4

Click [Code] > [Insert Function Call].
The code to recall the IviDCPwr_close function will be inserted to the source code
(Ex02.c).

IVI Instrument Driver Programming Guide (LabVIEW Edition)27

Programming using a class interface

Adding other functions
By selecting [Ex02.c] tab, the source code will be displayed. By executing the steps inpages 25 to 27, the source code will be as follows:
static ViStatus vs;static ViSession vi;
vs = IviDCPwr_InitWithOptions (“mySupply”, VI_TRUE, VI_TRUE,“Simulate=0,RangeCheck=1,QueryInstrStatus=0,Cache=1”, &vi);
vs = IviDCPwr_close (vi);In order to make this source code an executable program, include the following content:• Specify loading of the included file of the instrument driver.
• Set the initial values of the variables vi and vs at 0.
• Enclose the recall to InitWithOptions and close in the “main” function.
• Between the recalls to InitWithOptions and close, add a recall code for the function setting the voltage and current, and the function controlling the output ON/OFF. Besides themethod of inserting it using the function panel, there is also the method of entering thesource code directly with the editor as shown below.
Shown below is a sample that opens an instrument driver session, sets voltage, current,
and output, and closes immediately.
#include <IviDCPwr.h>static ViSession vi = 0;
static ViStatus vs = 0;
void main(){vs = IviDCPwr_InitWithOptions (“mySupply”, VI_TRUE, VI_TRUE,“Simulate=0,RangeCheck=1,QueryInstrStatus=0,Cache=1”, &vi);
vs = IviDCPwr_ConfigureVoltageLevel (vi, “Track_A”, 20);
vs = IviDCPwr_ConfigureCurrentLimit (vi, “Track_A”, IVIDCPWR_VAL_CURRENT_REGULATE, 2.0);
vs = IviDCPwr_ConfigureOutputEnabled (vi, “Track_A”, 1);
vs = IviDCPwr_close (vi);}

Building projects

1
28

Click [Build] > [Build].
This completes building.

KIKUSUI Electronics Corp.

Programming using a class interface

Executing Programs
This section introduces the breakpoints that are useful for debugging at the time of program
execution and explains how to run the program and the values stored in variables after
execution.

Setting the breakpoints
It is not clear how to execute the program of the sample on page 28 because it is notinteractive. Inserting a breakpoint in a recall line pauses the program before it is recalled sothat you can check the status of the program in progress.

1
2

Move the cursor to the row where you want to insert the breakpoint.
Click [Run] > [Toggle Breakpoint].
Breakpoints will be set.

By executing a program

3

Click [Run] > [Debug Ex02.exe].

4

Click [Run] > [Continue].

The program runs and pauses before calling the row where the breakpoint has beenset.

Program execution will be restarted.

Values to be stored in variables vi and vsIn the case of being able to open a session for an instrument driver, vi will store a session
handle (usually 0x00000001 or more as an IVI handle). The execution result (0x00000000
on success or a negative value on failure) will be stored in vs.

IVI Instrument Driver Programming Guide (LabVIEW Edition)29

Programming using a class interface

Explanation of functions
Functions that comprise the program are described with a case in which the IviDCPwr classdriver is used as an example. The prefix “IviDCPwr” attached to the VI (function) is uniqueto the IviDCPwr class driver.

Starting sessions
To start a session of the class interface, use the IviDCPwr_InitWithOptions.
vs = IviDCPwr_InitWithOptions (“mySupply”, VI_TRUE, VI_TRUE,“Simulate=0,RangeCheck=1,QueryInstrStatus=1,Cache=1”, &vi);
The parameters that can be set with IviDCPwr_InitWithOptions are as follows:
Parameters

Description

Logical Name

Specify the logical name of the virtual instrument created with NI-MAX.
The class driver locates the appropriate instrument driver DLL (Software
Module) or VISA address (Hardware Asset) from the logical name andrecalls kipwr_InitWithOption indirectly at the end. The class driver cannot provide a VISA address directly to the IviDCPwr_InitWithOptions
function.
In the case that VI_TRUE is specified, an ID query such as “*IDN?”
is issued in response to the instrument to make queries for model
information.
In the case that VI_TRUE is specified, the “*RST” command is issued toreset the settings of the instrument.
The settings of the IVI definition can be changed. (p.13)
Receive an instrument session (pointers passed).

ID QueryReset Device
Option String
Vi

30

KIKUSUI Electronics Corp.

Programming using a class interface
Setting OptionString
In OptionString, the following IVI definitions can be set up:• RangeCheck• Cache• Simulate• QueryInstrStatus• RecordCoercions• Interchange Check
OptionString is a parameter of the character string. The following is a sample:
QueryInstrStatus = VI_TRUE, Cache = VI_TRUE, DriverSetup=12345
Regarding the formatting, note the following:• If the set value is not specified, the default value will be applied. The default value is thevalue specified on the [Driver Session] > [General] page of the IVI configuration.
• The set value is of the ViBoolean type. Either of “VI_TRUE”, “VI_FALSE”, “1” or “0” can beset.
• Function names and values are case-insensitive. Uppercase and lowercase letters are notdistinguished.
• When setting multiple items, they should be separated by commas.
• Depending on the instrument driver, the “DriverSetup” parameters are supported.
The “DriverSetup” is a parameter that specifies items not defined in the IVI specifications when recalling InitWithOptions. Usage and formatting are dependent on the driver.
Therefore, in the case of setting the “DriverSetup”, it should be specified as the last item inthe “Option String”. For the details of what is specified in “DriverSetup”, see the Readmeof the driver or the online help.

IVI Instrument Driver Programming Guide (LabVIEW Edition)

31

Programming using a class interface

Setting the channel nameIn the case of power supplies and oscilloscopes, the IVI instrument drivers are designedwith the assumption that they are equipped with multiple channels. Therefore, many of thedriver functions that work on the instrument panel settings need to specify a channel for thesecond parameter, as shown below:
vs = IviDCPwr_ConfigureVoltageLevel( vi, “Track_A”, 20.0);
In this example, “Track_A” is specified as the channel name. Track_A is the virtual namethat was set in IVI Configuration (p.17). By specifying a virtual name, programming canbe done independently of the instrument driver of a particular model.
In the IVI configuration, the virtual name “Track_A” has been configured so that it can beconverted to the channel name that can be used only by a specific instrument driver (in thiscase, the kipwr driver) called “OutputChannel1”. Therefore, if the instrument is replaced, its
operation can be continued by simply changing the IVI configuration settings without having
to rewrite the program (p.34).
Instruments can be controlled by directly specifying channel names that are dependent on
the instrument driver, but interchangeability will be lost. For example, since the valid channel name for the AgN57xx instrument driver is “Output1”, if the channel name is specified as“OutputChannel1”, the program must be rewritten in order to replace the instrument with the
AgN57xx.

Memo• Do not manually edit the XML file (IviConfigurationStore.xml) in which the IVI configuration information is saved.
• The IVI configuration will be shared by all 32-bit/64-bit measurement applications andall logged-on users in the same PC.

Closing sessions
To close the instrument driver session, use IviDCPwr_close.
vs = IviDCPwr_close (vi);32

KIKUSUI Electronics Corp.

Programming using a class interface

Handling errors
If a value out of range is passed to a parameter or an unsupported function is recalled, anerror can occur in the instrument driver. In the IVI-C instrument driver, all errors that haveoccurred in the instrument driver are conveyed to the client program as a return value of
ViStatus-type, as shown below.
Range of values
vs = 0vs > 0vs < 0Description
Success
Warning
Error

IVI Instrument Driver Programming Guide (LabVIEW Edition)

33

Programming using a class interface

Replacing instrument
When replacing the instrument, the operation can be continued by simply changing the
Driver Session of the virtual instrument (IVI configuration). There is no need to change theapplication itself.
There are three Driver Session settings to be changed.
Item

Settings[Hardware] tab > [Hardware Assets] >[Resource Descriptor]

VISA address to which the instrument isconnected[Software] tab > [Software Module]

Instrument drivers to be used

[Virtual Names] tab > [Physical Names]

The physical name to which the virtualchannel name is mapped

If properly configured for the replaced instrument, the application can be operated without
having to recompile and link it again.
In the examples in this guide, if the instrument is replaced from a Kikusui PWR-01 series
DC power supply (instrument hosted by the kipwr instrument driver) to an Agilent N5700
series DC power supply (instrument hosted by the AgN57xx driver), the [mySupply] settings
should be changed as follows:
Item

Description of change[Hardware] tab > [Hardware Assets] >[Resource Descriptor]

VISA address to which the Kikusui
PWR-01 series DC power supply isconnected=> VISA address to which Agilent N5700
series DC power supply is connected[Software] tab > [Software Module]“kipwr” => “AgN57xx”[Virtual Names] tab > [Physical Names]“OutputChannel1” => “Output1”

Memo
The interchangeability function using IVI class drivers does not guarantee the operation
before and after replacement of the instrument. Be sure to fully verify that the replaced
system is functioning properly before operating it.

34

KIKUSUI Electronics Corp.