Iox Corp.

LabTab2

Documentation

 

SHORT TABLE OF CONTENTS

SHORT TABLE OF CONTENTS      *

TABLE OF CONTENTS     *

COPYRIGHT WARNING   *

DOCUMENT OVERVIEW *

INSTALLATION MANUAL - LICENCES     *

USER'S MANUAL - LABTAB         *

PROGRAMMER'S MANUAL - IOX               *

ADVANCED TOPICS        *

SAMPLE DRIVER               *

INTERNET AND INTRANET USE OF LABTAB         *

CONCLUSIONS   *

TABLE OF CONTENTS

 

 

SHORT TABLE OF CONTENTS      *

TABLE OF CONTENTS     *

COPYRIGHT WARNING   *

DOCUMENT OVERVIEW *

INSTALLATION MANUAL - LICENCES     *

CHARACTERISTICS         *

GENERAL CHARACTERISTICS     *

Public of non-programmers or programmers *

Hardware compatibility     *

Software compatibility       *

Advantages of LabTab2 in the field of instrumentation            *

HARDWARE CHARACTERISTICS              *

Support of the main brands of GPIB controllers          *

Support of serial and parallel ports *

SOFTWARE CHARACTERISTICS                *

Non-programmer access to LabTab2 - Excel function *

LabTab2 toolbar and library benefits             *

Arguments - Parameters - Type and return value        *

LabTab2 objects and classes           *

Using LabTab2 classes with COM/ActiveX *

LabTab2 objects creation with COM             *

Creating LabTab2 objects with "New"          *

Creating LabTab2 objects with "CreateObject"           *

Using LabTab2 COM objects with LabVIEW              *

Using LabTab2 COM objects with Visual C++ 6         *

Calling LabTab2 as a conventional DLL        *

HTML Help         *

Universal test utility          *

Variant arrays support       *

Time measurement of microsecond resolution - Clk object        *

Reading and writing Variant on files              *

INSTALLATION - INSTALL DISK CREATION - UNINSTALLATION *

Installation with a WinZip® self-extracting file            *

Installation with an install disk        *

Install disk creation            *

Uninstallation      *

TESTS AFTER INSTALLATION    *

Toolbar test         *

Tests with programs          *

Test with Microsoft Internet Explorer            *

Test with Microsoft Excel *

Test with Microsoft Internet Explorer and Microsoft Excel       *

Test with LabVIEW           *

VERSIONS           *

Demonstration version      *

OEM version - Use of instrument drivers integrated to LabTab               *

Full version          *

USER'S MANUAL - LABTAB         *

LABTAB CONFIGURATION          *

Creation of a LabTab2 shortcut on the desktop           *

Toolbar *

Copyright - software activation       *

LabTab2 modes  *

Software activation            *

Config - Ports Configuration            *

LabTab2 ports configuration           *

First configuration level - "Iox" port              *

Second configuration level - "Gpib" port      *

Second configuration level - "Ser" port         *

Second configuration level - "Par" port         *

Third configuration level - "Ser1" et "Ser2" ports       *

Third configuration level - "Par1" et "Par2" ports       *

Troisième niveau de configuration - Ports Gpib1 à Gpib4          *

Fourth configuration level - Hewlett-Packard / Agilent screen *

Fourth configuration level - Iotech screen    *

Fourth configuration level - Keithley-Metrabyte screen            *

Fourth configuration level - Ecran National Instruments screen              *

Fourth configuration level - COM1 and COM2 ports *

LabTab2 ports configuration use in LabTab2 library  *

"Help" - Help utility           *

"Test" - Test utility            *

How to put measurements in Excel in 5 mn with LabTab            *

What you need   *

What you have to do         *

Imagine what you can do now         *

How to format experimental data in Excel in 5 mn with LabScript             *

What you need   *

What you have to do         *

Imagine what you can do now         *

PROGRAMMER'S MANUAL - IOX               *

LIBRARY INSTALLATION             *

NATIVE INTERFACE - COM INTERFACE  *

LIBRARY OBJECTS           *

FUNCTIONS DECLARATION IN EXCEL-VBA           *

Opening a new Excel workbook       *

Opening VBA and inserting a module            *

Adding a reference to the LabTab2 DLL - Iox2c          *

Saving the workbook with the references      *

Re-opening of a workbook with a reference to LabTab2            *

LIBRARY CHARACTERISTICS      *

Argument type – Variant pointers   *

Parameters content – Variant containing a value         *

Return value and error code of LabTab2 functions     *

Objects, classes and functions of LabTab2  *

Name convention for the functions                *

OBJECTS AND FUNCTIONS          *

Excel object - Data transfer to Excel                *

Use        *

Fonctions             *

LabTab( Workspace_Fullname, Worksheet_Name, Row_Value, Column_Value, Address, Output_String, Wait_Value, LabScript_Format)             *

LabScript ( Workspace_Fullname, Worksheet_Name, Row_Value, Column_Value, Labscript_Variable, LabScript_Format)               *

VbaExcel ( Workspace_Fullname, Worksheet_Name, Row_Value, Column_Value, VbaExcel_Variant, LabScript_Format)               *

VbaExcel object - transfers to VbaExcel         *

Use        *

Functions             *

LabTab(VbaExcel_Variant_result, Address, Output_String, Wait_Value, LabScript_Format)          *

LabScript(VbaExcel_Variant, LabScript_Variant, LabScript_Format)      *

VBScript object - transfers to VBScript          *

Use        *

Functions             *

LabTab(VBScript_Variant_result, Address, Output_String, Wait_Value, LabScript_Format)           *

LabScript(VBScript_Variant, LabScript_Variant, LabScript_Format)       *

LabScript object - transfers to LabScript format           *

Use        *

Functions             *

LabTab(LabScript_Variant, Address, Output_String, Wait_Value, LabScript_Format)      *

VbaExcel (LabScript_Variant, VbaExcel_Variant, LabScript_Format)      *

Clk object - Time control   *

Use        *

Delay(Seconds)  *

Seconds (t)          *

Iox object              *

Use        *

Common I/O Functions     *

Configure-Unconfigure matching   *

Functions             *

Configure()          *

Define() *

Enter (adr , data, [format]) *

Output (adr , data, [format])             *

Unconfigure()      *

Gpib object - Specific programmation of the GPIB bus               *

Use        *

Instructions common with the "Iox" object  *

Specific instructions of "Gpib" objects         *

Fonctions             *

Ppoll (Byte_Value)             *

Spoll (Address, Byte_Value)           *

Send String_commands    *

Gpib bus commands          *

Ser object - Specific programming of RS-232 ports      *

Use        *

Instructions common with "Iox" object         *

Specific Instructions of "Ser" objects            *

Low level programming of RS-232 input lines:             *

Low level programming of RS-232 output lines:           *

Par object - Specific programming of CENTRONICS ports        *

Use        *

Instructions common with "Iox" object         *

Specific Instructions of "Par" objects            *

Low level programming of CENTRONICS output lines:             *

Lvx object - Utility functions for variants      *

Use        *

Len_Variant         *

High speed Excel transfers               *

Conversion between variant and binary        *

Conversion between variant and file              *

Functions             *

Len_Variant (Len, Data )   *

Variant_Range (a, Workbook_FullName, Sheet_Name,lin1, col1, lin2, col2)          *

Range_Variant (Workbook_FullName, Sheet_Name,lin1, col1, lin2, col2, a)          *

Variant_Binary (R, B, I , J, [P] )        *

Binary_Variant (B , I , J, R, [P])        *

File_Variant( File ,V )         *

Variant_File( Variant , File)               *

Mix object _Miscellaneous utility functions *

Use        *

Decimal separator change *

HTML files display            *

Functions             *

DecimalSeparator ( data , lang1, lang2)          *

HtmlFileShow ( F )              *

USE WITH OTHER LANGUAGES THAN VBA          *

Introduction         *

Native interface of LabTab2 library.               *

LabVIEW              *

Microsoft Internet Explorer - VBScript – ASP – IIS     *

Compilation of LabTab2 modules in C, C++ and Visual Basic   *

Visual Basic         *

Visual C++ version 6.0       *

Listing C++          *

Visual C++ version 6.0 used with COM         *

Listing C++          *

Listing for call from Excel  *

COMPATIBILITY ISSUES               *

Using LabTab1 applications            *

Using LabTab1 code outside Excel/VBA       *

Excel-VBA            *

Microsoft Office - VBA     *

Visual Basic and Internet Explorer-VBScript *

LabVIEW and Visual C++, …           *

Toolbar use          *

ADVANCED TOPICS        *

Choosing among LabTab2 objects for programming  *

Using several ports sequentially     *

Using several ports simutaneously *

Handling optional arguments           *

Synthesis and measure of logical signals      *

Pulse emission     *

Measuring a pulse width   *

Multitasking with VBA - DoEvents                *

Do Events - Program interruption    *

Programming non blocking delays  *

SAMPLE DRIVER               *

INTERNET AND INTRANET USE OF LABTAB         *

CONCLUSIONS   *

COPYRIGHT WARNING

LabTab version 2 or LabTab2 is instrumentation software. The elements of LabTab2 are, among others, files including code sequences represenative of software and the associated documentation. Copyright laws and international treaties protect LabTab2 and its elements.

The application programs, which call LabTab2 code sequences without including any of them, are royalty free.

That LabTab2 is protected by copyright laws means, among other things, that you must not make copies of the elements of LabTab2 on any media, without authorization, i.e. without the author receiving a fee, he agrees on.

No sentence included in this manual can be interpreted in a sense contrary to the content of this paragraph.

That application programs are royalty free, means that if you are writing programs which call LabTab2 code sequences without including any of them, you have no authorization to ask to the author of these sequences to distribute these application programs.

LabTab2 Version c – © Copyright Mai 2002, Iox Corp.

Documentation Version EN1© Copyright Oct 2002, Iox Corp.

Visual Basic Edition Applications, Microsoft Excel , Windows are Microsoft corporation trademarks.

LabVIEW is a National Instruments trademark.

National Instruments, Hewlett-Packard , Iotech , Keithley-Metrabyte are trademarks of these companies.

Centronics is a trademark.

 

DOCUMENT OVERVIEW

This document about LabTab2 includes:

INSTALLATION MANUAL - LICENCES

 

CHARACTERISTICS

GENERAL CHARACTERISTICS

 

Public of non-programmers or programmers

LabTab2 is Windows software for research scientists, engineers and OEM working in the field of laboratory instrumentation.

The main characteristics of LabTab2 is that it can be used by non-programmers with Excel or by programmers with any Windows language.

It enables users to:

Hardware compatibility

LabTab2 includes, among others:

The main characteristics of LabTab2 is to define, for the programmer, input-output data ports for the library functions and to provide the users with tools for configuring the corresponding input-output data paths.

Programs written with the functions of the LabTab2 library are independent of the configuration, especially concerning hardware, of the data input-output paths.

 

Software compatibility

LabTab2 enables to write I/O programs within all Windows programming languages, not included with LabTab2, among which:

In particular, the translation of programs written with LabTab2 within languages enabling their compilation in COM or Windows DLL components enables to use them from any Windows software.

As LabTab in version 1 was designed for Excel-VBA, this manual was written mainly for this environment. Nevertheless, LabTab2 is as well adapted to Internet Explorer and VBScript or LabVIEW and Visual C++.

 

Advantages of LabTab2 in the field of instrumentation

For the manufacturers or owners of laboratory instruments with one or several interfaces, LabTab2 enables to write and maintain only one driver for any GPIB controllers on the market, the RS-232 and GPIB interfaces of a same instrument and all the programming languages.

A library of instrument drivers written with LabTab2 appears so of long and wide use.

HARDWARE CHARACTERISTICS

Support of the main brands of GPIB controllers

LabTab2 supports the GPIB controllers of several brands:

Support of serial and parallel ports

LabTab2 supports the following ports:

SOFTWARE CHARACTERISTICS

Non-programmer access to LabTab2 - Excel function

LabTab2 introduces for any of its objects, the function "Excel" to simplify transfers to Excel. With this function, you can enter binary data directly into Excel columns, only by providing a format string, written with the "LabScript" notation of LabTab2 and describing the byte stream entered,.

Your data litterally flows into the columns of a worksheet, without any programming effort.

As the Excel function can be used alone, you can realize drivers with the same unique line of code, just by changing the format parameter values. This enables non-programmers to control LabTab2 power easily and with the same transfer speed as the ones of experienced programmers.

 

LabTab2 toolbar and library benefits

LabTab2 comprises of the executable toolbar " LabTab2c.exe " and the Windows library "Iox2c.dll".

The toolbar is launched with the " LabTab2c " icon of the Windows desktop (if you have define such a shortcut) or by executing the file "c:\LabTab\2c\LabTab2c.exe". It can be closed or opened independently of the execution of the programs calling the LabTab2 library and do not influence running programs.

The library is located in the file "C:\Windows\Iox2c.dll".

Arguments - Parameters - Type and return value

The arguments of functions are all of "variant pointer" type. The parameters (argument values) must be of type "variant containing a value", the return type is an integer on four bytes and the return value is strictly inferior to one on error.

These choices result in very simple declaration and use of "LabTab2" functions on Windows platforms.

For instance, in VBA, any argument "X" of a LabTab2 function defined with the "declare" instruction is only mentioned by its name in the argument list and the corresponding parameter "x" on function call may be declared simply by "Dim x". The return type is always "long".

For example, the function "Clk_Seconds" which returns a counter of microsecond resolution is declared and use in VBA with the following code:

Declare Function Clk_Seconds Lib "Iox2c.dll" (T) as long

Sub Test

Dim t

R= Clk_Seconds (t)

Msgbox (t)

End sub

In C++, a function argument is of "VARIANT*" type and a variant parameter is of "variant containing a value", type when it has not the "VT_BYREF" attribute in its "vt" field. The return type is always int.

LabTab2 objects and classes

The LabTab2 library functions are divided into subsets called objects. Each object is given a unique name in the library.

Outside the library, objects are associated with "classes", the names of which are made of the reunion of an object name with an underscore ("_"). The main objects are:

For Windows user, the objects are associated to classes, the name of which are formed by the union of the object name and an underscore character "_" as in "Iox_" for "Iox".

Using LabTab2 classes with COM/ActiveX

The LabTab2 library is installed as a COM component and the LabTab2 classes are installed as COM classes.

LabTab2 objects creation with COM

The LabTab2 classes, installed as COM classes, can be used to define COM objects in any application having defined a COM reference to LabTab2.

For instance, in VBA, it is possible to create an "Iox" COM object from the "Iox_" class with an expression:

"Dim Iox as new Iox_".

It can be seen that by giving the same name to the created COM object as the one of the object associated with the class, an application can "create" the LabTab2 objects.

The LabTab2 objects can so be used outside Excel-VBA as ordinary objects by any application supporting the creation of COM or ActiveX objects. This includes non-limitatively: Microsoft Office, Visual Basic 6, Visual C++ 6, LabVIEW, VBscript etc…

After creating COM objects from the LabTab2 classes, the LabTab2 functions may be then accessed as ordinary members (methods) of these objects.

If your langage does not support COM or ActiveX objects creation, please report to the following topic " Calling LabTab2 as a conventional DLL ".

 

Creating LabTab2 objects with "New"

In langages including the "new" statement (Microsoft Office, Visual Basic), creating LabTab2 COM objects from LabTab2 classes is straightforward. You only have to declare a reference to the library named " Iox2c 1.0 Type Library ", located in the file " C:\windows\Iox2c.dll " and create, for instance, the "Iox" object from the interface "a_Iox" with the statement:

" Dim Iox as new Iox_ "

 

Creating LabTab2 objects with "CreateObject"

In langages including only the statement " CreateObject " (VBScript, Internet Explorer), the "  Iox " object is obtained directly by the statements:

" Dim Iox as object: Set Iox=CreateObject (" Iox2c.Iox_ ") "

A sample is provided in the "c:\LabTab\2c\Excel" and "c:\LabTab\2c\IE" directories.

 

 

Using LabTab2 COM objects with LabVIEW

With LabVIEW, it is possible to define an ActiveX object " Iox2c 1.0 Type Library " as an ordinary ActiveX object. Please refer to the LabVIEW documentation. A sample is provided in the "c:\LabTab\2c\LabVIEW" directory.

 

Using LabTab2 COM objects with Visual C++ 6

In Visual C++ 6, you can use the "#import" directive of the compiler. Your LabTab2 components compiled with VC++ can be used in any Windows application. A sample is provided in the "c:\LabTab\2c\VC6" directory.

 

Calling LabTab2 as a conventional DLL

The LabTab2 library can be used as a conventional DLL, without COM support. To use this so-called native access, each of the functions name can be deduced from its COM call in which the dot is replaced by an undescore "_" .

For instance, if the function "configure" of the Iox object is called from a langage with COM support with:

"Iox.Configure" then the name exported by the LabTab2 library will be "Iox_Configure" with the same arguments.

HTML Help

The LabTab2 help is now in HTML format

Universal test utility

A new test button in the LabTab2 toolbar enables to send commands using the "Iox" LabTab2 port and visualize the results on screen. It is available even in demonstration mode.

Variant arrays support

The "Output/ Enter " functions of LabTab2 accept as second argument data arrays of Variant type having arbitrary complexity. It is so possible to describe a data entry, by the definition of a structure, before an Enter instruction and then to fill this structure in one time with this instruction. The result of this is the possibility to write drivers of improved readability and compacity, with only a few LabTab instructions, which facilitates any code translation.

In case no format directive (see below) is given to the "enter" functions on the structure of the result, a "binary" formats that privileges speed is used by LabTab. The Lvx interface provides the function: "Variant_Binary" to convert this binary format to a "variant" of arbitrary complexity and "Binary_Variant" for the inverse operation. It is so possible to use variant arrays "a posteriori" on enter results.

Time measurement of microsecond resolution - Clk object

In the Clk (Clock) interface are available the functions:

Compared to this, the "Vbx" object, compatible with version 1 provides only with a "Delay" instruction having an uncertainty of about 55 milliseconds.

Reading and writing Variant on files

The "Lvx" object induces new functions: File_Variant to write a variant array to a file and Variant_File to load a file in a variant array.

 

INSTALLATION - INSTALL DISK CREATION - UNINSTALLATION

 

Installation with a WinZip® self-extracting file

Use the toolbar options normally (see below).

Installation with an install disk

Use the toolbar options normally (see below).

Install disk creation

To create an install disk on "A:" directory:

"MakeDisk" works on any directory other than "A:\" and preserve integrally the LabTab installation.

Uninstallation

To uninstall "LabTab":

" Uninstall " works on any directory other than "A:\" and can be cancelled immediately, by clicking on the "Install" button displayed at the end of operation. Any future installation restaures also LabTab identically.

 

TESTS AFTER INSTALLATION

Toolbar test

Just after installing LabTab2, you are in demonstration mode. In this mode, all the functionnalities of the LabTab toolbar are active and especially the "Test" utility, which enables you to dialog on screen with your instrument.

 

Tests with programs

All the functions of the LabTab2 library are available for evaluation purposes. Among others:

Program samples using these functions are provided with the "C:\LabTab\2c" directory.

For the tests in programs, you need to have:

 

Test with Microsoft Internet Explorer

Test with Microsoft Excel

Test with Microsoft Internet Explorer and Microsoft Excel

This test uses the Excel functions of LabTab2

Test with LabVIEW

 

VERSIONS

Demonstration version

After installation LabTab2 operates in demonstration mode.

Arbitrary data outputs over "GPIB", "RS-232" and "CENTRONICS" ports are desactivated in this version of LabTab. You can only send the "*IDN?" characters. To activate arbitrary data outputs, please report to the section "Software activation" below.

OEM version - Use of instrument drivers integrated to LabTab

You may have received an OEM version of LabTab, in which LabTab2 is used as a driver for a specific instrument, for instance a "HP34401A" voltmeter. In this case, after a normal installation of LabTab2, the copyright screen displays "Licensed for HP34401A voltmeter " in the field "Product status" and still go on displaying the "full product number" of LabTab2 as well as the Licence number input field of LabTab2.

In this version, in addition to the functions of the demonstration version, you have programming access to the input-output data transfers designed for your instrument, gathered in a LabTab2 class beginning usually named as your instrument as in "HP34401A_". The LabTab2 class designed for your instrument can be used in your programs as the LabTab2 objects. You can so refer to the present documentation to gain access to these functions in your programs. For any other information, please refer to the documentation provided with your pilot or contact your provider.

Arbitrary data outputs over "GPIB", "RS-232" and "CENTRONICS" ports are desactivated in this version of LabTab. You can only send the "*IDN?" characters. To activate arbitrary data outputs, please report to the section "Software activation" below.

Full version

This version is obtained through , the communication of your product number, the obtention of your product key and the activation of the software. All the functions of LabTab2 are active in this mode.

To activate LabTab2, please report to the section "Software activation" below.

 

USER'S MANUAL - LABTAB

 

LABTAB CONFIGURATION

 

After installing LabTab2, the executable file " LabTab2c.exe " can be used from the "C:\LabTab\2c\LabTab2c.exe" localization to:

 

Creation of a LabTab2 shortcut on the desktop

 

You can run LabTab2 by executing the file "c:\LabTab\2c\LabTab2c.exe" after installation. However, it is trongly recoommended to create a shortcut to this file on the Windows desktop. With only a double-clickon this shortcut, and displaythe LabTab2 toolbar with its options:

With only a click on this shortcut, you can run LabTab2 and display the LabTab2 toolbar with its options as a starting screen.

 

Toolbar

There are four tools on the toolbar: "Copyright" , "Config", "Help" and " Test"

 

Display the Copyright utility for entering your licence number and activate LabTab2.

Display the configuration utility to specify the I/O paths used by the LabTab2 library.

Display the present document online.

Display the test utility for dialoging with an instrument

Copyright - software activation

LabTab2 modes

If you think that LabTab2 can be useful for you in its complete version, you can buy to your local reseller a key, that enables you to activate the arbitrary data inputs-outputs on the LabTab2 ports.

The "Copyright" tool enables to perform or verify the LabTab2 activation.

The "Copyright" utility display one among these two screens (with your own product and licence numbers) :

The first screen is displayed in demonstration mode. The second screen is displayed after the software activation..

Software activation

To activate your software, communicate to your local reseller, your product number which can be:

You can use then your licence number, returned to you by your local reseller, in one of the following way:

After these operations, the licensed mode screen is displayed in the "Copyright" utility and LabTab2 is fully active.

Config - Ports Configuration

The "Config" button enables to display the screen collection of the LabTab2 configuration utility.

Each screen includes always, in the upper part, the same toolbar with 4 buttons:

 

 

Quits the configuration utility without saving any change made

Saves the changes made in the configuration utility and quits

Displays the previous screen if it exists

Saves the changes made in a screen and displays the next screen if it exists

In addition to this toolbar, the configuration screens include dropdown listboxes varying in number and content. The configuration is performed by choosing in the lists and validating by "OK".

You navigate with the "<<" et "OK" buttons.

When you leave the configuration window via the "Save/Exit" button, your configuration is saved automatically and you are assured to see it at next opening. By leaving with the "Exit" button or by closing the window, none of your changes, even validated by "OK" is saved.

LabTab2 ports configuration

The ports of the LabTab2 library are objects with data input-output functions. They are identified by their names: "Iox", "Gpib", "Gpib1" etc. … and their type equal to "a","b" or "c".

The configuration utility has access to the descriptions of LabTab2 ports and of physical ports corresponding to hardware of the host computer, on which the installation was made.

The ports are treated, by the configuration utility , as variables, the content of which can be:

The LabTab2 library functions explore recursively, when called, the LabTab2 ports content to find the parameters of a physical port , used for data emission or reception.

The LabTab2 configuration utility enables to define conveniently, the content of LabTab2 ports. For this, they are organized following a descending hierarchy in which a port can be connected only to a lower level port.

There are three levels of configuration, associated to the port types.

At first level,is the port of "a" type :"Iox"

At second level, are the ports of "b" type: "Gpib","Par","Ser"

At third level, are the ports of "c" type:

Each GPIB brand is mentioned twice in order to be able to configure two ports of the same brand. This case occurs when two GPIB boards of the same manufacturer are present on the PC where LabTab2 is installed.

The levels 1 to 3 concern ports common to all the hardware manufacturers. These port names are the only ones defined in the LabTab2 library. Their names are recalled below:

A fourth level of configuration enables to give the parameters of the GPIB controller of a selected brand, which is physically present on the computer with LabTab2 installed. It is also use to give the parameters of the COM ports.

 

 

First configuration level - "Iox" port

At this level, the LabTab2 "Iox" port can be connected to one of the ports "Gpib", "Ser" or "Par".

This choice defines the type of the link to configure: GPIB, serial or parallel link, respectively.

 

Second configuration level - "Gpib" port

At this level, the LabTab2 "Gpib" object can be connected to one of the ports "Gpib1", "Gpib2", "Gpib3" or "Gpib4".

This choice defines the number of the GPIB link to configure.

 

Second configuration level - "Ser" port

At this level, the LabTab2 "Ser" port can be connected to one of the ports "Ser1" or "Ser2".

This choice defines the number of the serial link to configure.

 

Second configuration level - "Par" port

At this level, the LabTab2 "Par" port can be connected to one of the ports "Par1" ou "Par2".

This choice defines the number of the parallel link to configure.

 

Third configuration level - "Ser1" et "Ser2" ports

At this level, the content of LabTab2 ports "Ser1" and "Ser2" may be filled with the description of a RS-232 port, physically present on the computer where LabTab2 is installed.

This port is described by its name (COM1,COM2).

 

Third configuration level - "Par1" et "Par2" ports

At this level, the content of LabTab2 ports "Par1" and "Par2" may be filled with the description of a CENTRONICS port, physically present on the computer where LabTab2 is installed.

This port is described by its name (LPT1,LPT2,…).

 

Troisième niveau de configuration - Ports Gpib1 à Gpib4

At this level, the content of LabTab2 ports "Gpib1", "Gpib2", "Gpib3" or "Gpib4" may be filled with the description of a GPIB port, physically present on the computer where LabTab2 is installed.

The physical GPIB port is described by its brand.The brands available are:

  • Hewlett-Packard /Agilent
  • Iotech
  • Keithley-Metrabyte
  • National Instruments

Each brand is mentionned a second time with the suffix (2) in order to enable the configuration of two GPIB ports of the same brand on the same computer.

 

Fourth configuration level - Hewlett-Packard / Agilent screen

This screen enables to describe the GPIB controller attached to the

Hewlett-Packard or Hewlett-Packard(2) port.

"Board type" field is est optional and used to differentiate between boards for the user.

"Board Name" field is compulsory. Its value can be found in the configuration utility of the manufacturer in the "SICL name" field and may vary from hpib7 to hpib15.

 

Fourth configuration level - Iotech screen

This screen enables to describe the GPIB controller attached to the Iotech or Iotech(2) port.

"Board type" field is est optionnal and used to différentiate between boards for the user.

"Board Name" field is compulsory. Its value can be found in the configuration utility of the manufacturer with values ranging from "IEEE0" to "IEEE3" for one to four boards installed.

Fourth configuration level - Keithley-Metrabyte screen

This screen enables to describe the GPIB controller attached to the Keithley-Metrabyte or Keithley-Metrabyte (2) port.

"Board type" field is est optional and used to differentiate between boards for the user.

"Board Name" field is compulsory. Its value can be found in the configuration utility of the manufacturer with values ranging from "0" to "3" for one to four boards installed.

"I/O address" field is optional for PCI boards, the default value &h2B8 is recommended in such case. For ISA boards, the value of this address must be read on board jumpersand convert to its hexadecimal form.

 

Fourth configuration level - Ecran National Instruments screen

This screen enables to describe the GPIB controller attached to the National Instruments or National Instruments (2).

"Board type" field is est optional and used to differentiate between boards for the user.

"Board Name" field is compulsory. Its value can be found in the National Instruments topic of Windows configuration panel/system/devices with values ranging from "GPIB0" to "GPIB3" for one to four boards installed.

 

Fourth configuration level - COM1 and COM2 ports

At this level, the RS-232 communication parameters for ports "COM1" and "COM2" may be provided.

These RS-232 parameters as the ones of the MODE command of DOS:

  • speed in bauds
  • parity
  • data bits number
  • stop bits number
  • hardware handshake. For this parameter, please notice that an empty string is used to notify the absence of handshake as in the MODE command and is recommended by default.

The choices define the serial link parameters to configure.

There are few handshakes, and in case of no communication, you can try each of them, starting with no handshake.

The use of a handshake requires usually the making of a specific cable.

 

LabTab2 ports configuration use in LabTab2 library

When the content of the LabTab2 ports has been defined and you exit the configuration screen by "Save/Exit", your configuration is saved permanently on disk. It determines then a new default data I/O path for the functions of the LabTab2 library.However, running applications using the LabTab2 library, are not affected by this change and go on using the LabTab2 configuration which was active at their startup time. To make them use the new configuration, you must restart them.

The configuration choices saved, apply by default in the LabTab2 library, to the "Excel" functions of any object and to the "Define" functions which define the data I/O path of the Iox, Gpib , Ser , Par , Gpib1 to Gpib4 , Ser1, Ser2, Par1 and Par2 objects of LabTab2.

When these functions do not use any parameter, their I/O path is determined automatically from the LabTab2 ports content, which is recursively examined until reaching the description of a physical port.

It is so possible with the same calls to the LabTab2 functions, and hence with the same program, to exchange data via the "Iox" port, with different physical ports. Simply by changing the configuration.

The configuration utility enables indeed the programs using the LabTab2 functions to be reused as such on various hardwares.

"Help" - Help utility

This utility enables to display the present document on the screen.

N.B.: with NT4 sp1 or Internet Explorer up to version 2 included, help is not available from the "Help" button of the LabTab2 toolbar. It can be obtained nonetheless by double-clicking on the "c:\LabTab2\2c\Help\Iox2c.htm" file.

 

"Test" - Test utility

This utility is available in the demonstration mode. For it to work properly, the configuration utility must have been use before its starting up. This is for connecting the "Iox" port to a physical port present on the computer.

To perform this operation, refer, if necessary, to the topic "Config. - Configuration utility" above in this document.

The test utility is an example of program for universal data I/O that can be realized with LabTab2.

The test program, taking into account the values displayed on the joint screen, is the VBA equivalent of the following program:

 

Sub Test

With Iox

.Define

.Configure

.Output 22, "*idn?"

Clk.Delay 0.1

.Enter 22,a

.Unconfigure

End with

Msgbox a

End Sub

 

enables to execute the program once

closes the window

starts the continuous execution

stops the continuous execution

Address

Enter a GPIB address: 0 to 30

( ignored for an RS-232 port)

Output String

Receive a string to emit

CR

Adds a carriage return or ASCII(13) at the end of "Output string"

LF

Adds a linefeed or ASCII(10) at the end of "Output string"

 

N.B.: CR and LF can be both sent in this order

Value

Receives the delay between Output and Enter

offset

Actual delay = Value + offset

Enter String

Receives the entered string

Clears the "Enter string" , "Error report" and "Address" fields in "Enter"

 

How to put measurements in Excel in 5 mn with LabTab

 

What you need

If you do not have a LabTab distribution, you can download it on the Internet site: www.labtab.com.

You must have a PC or compatible computer with Windows 95 or later installed.

You must have installed a GPIB or IEEE-488 controller from National Instruments, Hewlett-Packard/Agilent , Keithley-Metrabyte/CEC or Iotech. You must have linked a laboratory instrument IEEE-488 compliant to this controller, with an IEE-488 cable. Your instrument must be capable of answering to an "*idn?" interrogation and you should know its "IEEE-488 address", assumed to be 22 here.

You must have Excel 5 or later.

 

What you have to do

From the LabTab site download LabTab and uncompress it on the hard disk "C". This operation is reversible without leaving any residue of LabTab on your computer by a bare further uninstall operation.

At the end of download, you must have a file at "C:\LabTab\2c\LabTab2c.exe". Open it with a double click, the LabTab toolbar appears.

Click on "Config" and select "Gpib" in the dropdown box displayed and click "OK". In the screen sequence, choose "Gpib1" then "National Instruments" and then the "GPIB0" identifier and click a last time on "OK" to validate your choice. Choose "Save/Exit" to go back at the toolbar screen. Fr the other brands of controllers, proceed the same and choose "IEEE0" as the identifier of "Iotech" controller, "hpib7" for "Hewlett Packard" controller and "&2B8" for "CEC/Keihley" controllers.

Click on "Test" and enter "*idn?" in the "Output string field", enter the "GPIB/IEEE-488" address of the instrument in the corresponding field and click "OK". You should see the identifier of your instrument in the "Enter string" field.

Open "Excel" then "Visual Basic for Applications" (VBA), by pressing on "Alt" and "F11" simultaneously. In the "Tools" menu", choose "References", goto the line "Iox2c type library" and mark the crossbox of this line. In the "insert" menu", choose "Module", a blank module "VBA" appears. In this module, type:

Dim Excel as new Excel_ ' do not forget the "_"

Sub Test

     W = ThisWorkbook.FullName

     S = ThisWorkbook.Worksheets(1).Name

     R=LabTab.Excel(W,S,1,1,22,"*idn?",0.3, F)

End Sub

Put your cursor on the text of your code and click once, then press on "F5" to run the code.

The answer of your instrument appears in the upper left cell of the first worksheet of your workbook.

 

Imagine what you can do now

LabTab enables to use this same program to introduce data from any instrument in your Excel worksheet ! To do this, simply buy the LabTab licence, replace the "*idn?" command and fill the format string F (left empty in the above example) by values adapted to each instrument.

You will be able to enter easily a Lecroy® oscilloscope waveform with all its parameter in an Excel worksheet and thus, in all your experimental reports written in Word, instantaneously. You will be able also to use LabTab within LabVIEW® to transfer your data in Excel without your programming.

 

How to format experimental data in Excel in 5 mn with LabScript

 

What you need

The former program must work correctly with F parameter empty at entrance. You must know how to enter a string inside quotes in place of "F" in the call to LabTab.Excel or within a line: F="" before this call.

 

What you have to do

The "Excel.LabTab" function has a last argument that we left empty in the above eaxample.

When this argument is a non-empty string conforming to the "LabScript" notation, detailed below, the function formats data that it enters automatically in the columns of an Excel worksheet. To see the data coming from an instrument in an Excel workbook, it is so enough to provide a LabScript string adapted to its byte stream, using the syntax described now.

A valid "LabScript" string is made of one or more column descriptor separated by comas with no blanks as in: "I2,S(10),I4[5],R8{8},NS(15)<English>".

Each descriptor uses always a binary type name, as "I2", which will be common to all the cells of a column and if necessary the size in bytes of the type inside parenthesis as in " S(10)", the number of cells to use inside brackets as in "I4[5]", the period for bytes swapping inside braces as in R8{8} and the english name of the original language in which byte stream was produced, inside strictly inferior and superior signs, as in "NS(15)<English>". The order of these fields in a descriptor is arbitrary so if "I4[3](4){2}<English>" is valid then "[3]<English>(4){2}I4" is valid.

For instance, receiving a byte 255 followed by the byte 0, from an instrument, may be entered in Excel as the signed number -128 , if the "I2" format is used. The reverse sequence 0 then 255 , associated to the format "I2{2}" , will enter -128 in Excel as well.

The type names available in version 2.c are:

The size in bytes of the binary type appears to be necessary only for the string types "S","S2" and "NS" the nuber of characters of which can vary. So "S(10)" designates a string made of 10 bytes on & 1 byte per character basis which is 10 characters. For other types, this indication is optional and "I4" is equivalent to "I4(4)".

The number of cells defaults to 1 and "I4[1]" is equivalent to "I4".

The swapping period may be necessary to transform the most significant bytes in less significant ones for he types of size superior to one which are "I2", "I4", "R4","R8" et "S2". This period must be a divider of the type size in bytes. It defaults to 1 which corresponds to no swapping. So "I2" is equivalent to "I2{1}".

Finally, the default language is assumed to be the Excel user language. It is explicitely mentionned with the "NS" type since it enables to transform the decimal separator used in the byte stream, in the decimal separator of the user . The resulting string can then be used in Excel formulas as a number.

The types above are adapted to Windows applications. They induce the transmisson of the least significant bytes first, as ASCII characters between 0 and 255. To describe bytes encoded as two hexadecimal characters per bytes with the most significant hexadecimal character emitted first, LabScript includes the following "hexadecimal" types:

For instance, the sequence "8000" in hexadecimal, associated to the format "I2H2" is entered in Excel as the bytes 128 and 0 and so -128.

For the hexadecimal types, it is possible to provide up to 4 periods for byte swapping of the type. They only have to be separated by semi-colons ";" inside the braces. The order of the periods for byte swapping is not significant and "I2H2{4;2}" is identical to "I2H2{2;4}". Omitted or invalid periods default to 1.

For instance: the sequence "0080" in hexadecimal with the format "I2H2{4;2}" is entered in Excel as the bytes 128 and 0 and thus -128. Indeed, the swap with a period of 4 bytes gives first "0800" then on 2 bytes "8000".

 

Imagine what you can do now

Here are some examples of LabScripts formats:

"I" declares one byte in the stream as an integer for the column 1 and row 1 of the worksheet.

"I[40]" declares 40 "I" types for the rows 1 to 40 of column 1.

"I[10],I[30]" declares 10 integers for column 1 and 30 for column 2.

"S(40) declares 40 bytes for the characters of string with 1 byte per character basis, for column 1 row 1.

"S2(40) declares 40 bytes for the characters of string with 2 bytes per character basis, for column 1 row 1.

"S(8)[5]" declares 5 strings of 8 bytes for column 1 row 1.

"S(8)[5], S(2)[20]" declares 5 and 20 strings for columns 1 and 2.

"I4{4}[1000]" declares 1000 integers on 4 bytes for column 1 with byte swapping.

"NS(20)<English>" declares a sting of 20 bytes representing a number in english. For the user languages that need it , the dot decimal separator will be converted into a coma.

As all these examples can show you, you can quickly put in Excel, without specific programming skills, the data of any instrument. Just describe in a valid LabScript string, the instrument binary response with the help of the manufacturer documentation and provide it as a format argument to the "Excel.LabTab" function.

With the hexadecimal types, it is also possible to carry data with their "LabScript" format over "text" data channels (WWW,HTTP,HTML,XML, etc…) up to Excel or any other Windows application.

To do so, it is only required to use on a server the "LabScript.LabTab" function, which converts data from instruments in "LabScript" format, send data with format to a client , then enter data in Excel, while respecting their format, with the "Excel.LabScript" function by the client's. No "LabTab" licence is necessary for the clientsand only one "LabTab" licence is required for the server.

 

PROGRAMMER'S MANUAL - IOX

 

LIBRARY INSTALLATION

LabTab2 installs a "library" containing "functions" regrouped in "objects".

It is contained in the "C:\Windows\Iox2c.dll" file and is recognised by Windows as a "DLL" (conventional) and a "COM DLL" (Conforming to COM). It uses by default the LabTab configuration.

NATIVE INTERFACE - COM INTERFACE

For the programs that can call in a DLL, the library exports its functions as "procedures" and Windows provides tools for calling these procedures, via the "native" interface of the library.

For the programs that can call in a COM DLL, the library exposes "classes" and Windows provides at first tools to create the library objects as "instances" of these classes and then tools to call the functions of these objects as "methods" of these instances, via the "COM" interface of the library.

For comparison purposes, the COM interface can be used with any Windows software but the components using this interface need a manual registration by the user when deploying the component. At the opposite, the components using the "native interface" cannot be used by scripting "languages" as VBScript but do not need any registration.

The COM interface is used by default below.

 

LIBRARY OBJECTS

The library objects are divided in "application oriented" objects and "port oriented" objects. The "application oriented" objects are are easier to use and give shorter programs for a given application. The "ports oriented" objects are divided in " ports " with data input/output functions and " utilities " for data processing. They are suitable for any application under Windows and enable to use the full potential of LabTab though giving larger programs.

The "application oriented" objects are "Excel", "VbaExcel" and "LabScript". Their main function is the "labTab" function that enables to make data input-output with the "Iox" path defined in the LabTab configuration with the value "Gpib" , "Ser" or "Par".

The ports are associated with a type "a", "b" or "c" depending on their hardware dependency:

The utilities are of type " a " (hardware independent)

FUNCTIONS DECLARATION IN EXCEL-VBA

To use, at first, LabTab2 functions, from a VBA module of an Excel workbook, you have to:

For each re-opening of the Excel workbook saved, LabTab2 will be loaded automatically.

Opening a new Excel workbook

Run Excel. Excel opens a workbook named "Workbook1"

Opening VBA and inserting a module

The VBA editor is opened by pressing together the " Alt " and " F11 " keys of your keyboard.

In the "project" window, click once on "VBA Project (Workbook1)".

In the "Insert" menu, choose the topic "Module", a new window appears then and you can type VBA code in it. Click once in this window and type the following code: "Sub Test" then press on "Enter". You should see the following code appear:

Sub test ()

End sub

You have just typed your first VBA program ! You may have noticed a useful property of VBA, which is the statement completion: VBA has automatically added the parenthesis and the text "end sub"

Adding a reference to the LabTab2 DLL - Iox2c

From the VBA "Tools" menu choose "References". In the "Available references" list: cross the checkbox " Iox2c 1.0 Type Library" and click on " OK ".

LabTab2 classes are available to create LabTab2 ports in the VBA "Module1" of "Workbook1". To check this, type below the line "Sub Test()", the following code followed by a space after "New":

" Dim Iox as New "

As LabTab2 uses the statement completion of VAB, you should see a list of available classes appear, including among others "Iox_ "

Choose " Iox _" to obtain the following code:

" Dim Iox as New  Iox_"

You can then use the LabTab2 instructions in your program, they can be seen with statement completion by typing under the previous line, the word "Iox" followed by a dot "." .VBA will display all the instructions available for the "Iox" object which was define from the "a_Iox" class.

From a langage without the new keyword, you would use the syntax:

" Dim Iox : Set Iox=CreateObject(" Iox2c.Iox_ ") "

In this case, no reference to Iox2c 1.0 Type Library is necessary but the statement completion is not active.

The availability of the LabTab2 instructions in VBA is obtained for the "Iox_" class.

For the other LabTab2 classes, just replace the class name "Iox" with the name of the desired LabTab2 objects. The names of the LabTab2 objects are the following:

"Iox"

"Gpib", "Ser", "Par"

"Gpib1" ,"Gpib2", "Gpib3", "Gpib4"

"Ser1" , "Ser2"

"Par1" , "Par2"

"Vbx"

"Lvx" , "Mix"

Saving the workbook with the references

If you wish, save your "workbook1" in switching back to Excel with the "Alt" and "F11" key, choosing the "File"" menu" and the topic "save". During this operation, Excel saves the reference to the LabTab2 instructions added to your workbook.

Re-opening of a workbook with a reference to LabTab2

If you re-open " workbook1", in which a reference to LabTab2 instructions was added and saved, they are loaded automatically and no other operation is needed to make these instructions available in your VBA modules.

 

LIBRARY CHARACTERISTICS

Argument type – Variant pointers

LabTab2 library functions accept as universal function argument type in the fucntions declarations, the "variant pointer" type, which a data type common to VBA,VB,VBScript,LabVIEW and Visual C++6.

In VBA, this argument type is declared simply by giving its name in the argument list (native or COM interface).

In VC++6, the argument type of the functions of LabTab2 is "VARIANT*" (variant pointer).

 

Parameters content – Variant containing a value

A parameter is, by definition, the value of an argument on function call. When the argument is a variant pointer, the parameter is a variant address. The content of the parameter is so a variant and a variant can itself contain either a value or a reference.

In particular, VBA treats differently, on return of a function, the parameters, the content of which is a varaint containing value and those containing a reference. The ones containing a reference cannot be modified on function return, except if they contain references to strings. To obtain a uniform behaviour in all the languages, it is required for the content of parameters of any library function, to be always a variant containing a value.

In VC++6, a variant containing a value can be obtained when not using the "VT_BYREF" attribute in its "vt" field value. The function "VariantCopyInd" enables also to copy any variant ( containing a value or a reference) in a variant containing a value.

In VBA, one can obtain a variant "A" containing a value, in using the variable without its having been declared or declared with the keyword "Dim" used alone, as in the expression "Dim A".

It is also possible to copy any variant "B" ( containing a value or a reference) in a variant "A" containing a value by the very simple expression: "A=B".

Some examples of declarations of variant containing a value in VBA:

Dim s: s="" ‘ empty string

Dim b: b=CByte(3) ' unsigned byte

Dim d: d=CDbl(1.23) ' double

Dim t: dim v(0): v(0)=CLng(5): t=v ' one element vector

In VBScript, all the variants contain values.

Return value and error code of LabTab2 functions

Any function of the library returns a long integer (4bytes), strictly inferior to 1 on error.

Objects, classes and functions of LabTab2

The LabTab2 library, included in the "c:\LabTab\2c\Iox2c.dll" file, offers to the Windows programmer, a set of functions, or instructions, divided into subsets or "objects" . The objects are known outside the library under the name of their "class" which is the reunion of the type value and the object name by an underscore ("_"). LabTab2 include the following objects:

Name convention for the functions

The full name of a function is built from:

The separator varies with the type of call to the LabTab2 object:

Example:

The "Define" function in "Iox" class can be called by "Iox_Define" , "Iox.Define" or "Iox->Define()".

For an object declared with the keyword "New", you can obtain the functions list of this LabTab2 object, by typing its name followed by a dot (statement completion) or only a dot inside a structure "With" "End with" .

 

OBJECTS AND FUNCTIONS

Excel object - Data transfer to Excel

Use

The Excel object includes the major function "LabTab", to transfer data to Excel from laboratory instruments . It enables to use the input-output path for data, defined with the configuration utility of the Labtab toolbar, in order to enter data in the columns of an Excel Worksheet. Th corresponding workbook can be open or closed, on your machine or on a distant one.

The entered data can be formatted with LabScript.

To get a universal program using the Excel function of LabTab, please refer to the following topic in this document:

"How to put measurements in Excel in 5 mn with LabTab"

To get a detailed description of the LabScript format, please refer to the following topic in this document:

"How to format experimental data in Excel in 5 mn with LabScript"

This object includes also the "VbaExcel" and "LabScript" functions to transfer data, obtained from the "VbaExcel" and "LabScript" objects, to Excel.

This object can be used inside couples of "Configure" and "Unconfigure" functions of the "Iox" object, the functions of which it uses ( cf "Iox" description" ).

Fonctions

 

LabTab( Workspace_Fullname, Worksheet_Name, Row_Value, Column_Value, Address, Output_String, Wait_Value, LabScript_Format)

 

First argument

Workspace_Fullname is the name with path of the Excel workbook which will receive the response of the instrument. ( ex: "C:\Tests\Test1.xls")

Second argument

Worksheet_Name is the name of the worksheet to use for entering the bytes of the response ( ex: "Sheet1")

Third argument

Row_Value is the number of the first line to use in the worksheet

Fourth argument

Column_Value is the number of the first column to use in the worksheet

 

Fifth argument

Address is the IEEE-488 address of the instrument and is ignored for RS-232

Sixth argument

Output_String is a string argument to send to the instrument

Seventh argument

Wait_Value is a value in seconds to wait after the "output" operation.

Eighth argument

LabScript_Format is the string written in LabScript format that describes how the response bytes are entered in the cells of the columns of the Excel worksheet ( ex: "I4[100],S(100)" ).

To get a detailed description of the LabScript format, please refer to the following topic in this document:

"How to format experimental data in Excel in 5 mn with LabScript"

To get a universal program using the Excel function of LabTab, please refer to the following topic in this document:

"How to put measurements in Excel in 5 mn with LabTab"

 

LabScript ( Workspace_Fullname, Worksheet_Name, Row_Value, Column_Value, Labscript_Variable, LabScript_Format)

First argument

Workspace_Fullname is the name with path of the Excel workbook which will receive the response of the instrument. ( ex: "C:\Tests\Test1.xls")

Second argument

Worksheet_Name is the name of the worksheet to use for entering the bytes of the response ( ex: "Sheet1")

Third argument

Row_Value is the number of the first line to use in the worksheet

Fourth argument

Column_Value is the number of the first column to use in the worksheet

Fifth argument

Labscript_Variable is a string obtained from the "LabScript.LabTab" function. ( see this function)

Sixth argument

LabScript_Format is the string written in LabScript format that describes how the response bytes are entered in the cells of the columns of the Excel worksheet ( ex: "I4[100],S(100)" ).

To get a detailed description of the LabScript format, please refer to the following topic in this document:

"How to format experimental data in Excel in 5 mn with LabScript"

To get a universal program using the Excel function of LabTab, please refer to the following topic in this document:

"How to put measurements in Excel in 5 mn with LabTab"

 

VbaExcel ( Workspace_Fullname, Worksheet_Name, Row_Value, Column_Value, VbaExcel_Variant, LabScript_Format)

First argument

Workspace_Fullname is the name with path of the Excel workbook which will receive the response of the instrument. ( ex: "C:\Tests\Test1.xls")

Second argument

Worksheet_Name is the name of the worksheet to use for entering the bytes of the response ( ex: "Sheet1")

Third argument

Row_Value is the number of the first line to use in the worksheet

Fourth argument

Column_Value is the number of the first column to use in the worksheet

Fifth argument

Variant is a variable obtained from the "VbaExcel.LabTab" function or "VbaExel.LabScript". ( see these functions)

Sixth argument

LabScript_Format is the string written in LabScript format that describes how the response bytes are entered in the cells of the columns of the Excel worksheet ( ex: "I4[100],S(100)" ).

To get a detailed description of the LabScript format, please refer to the following topic in this document:

"How to format experimental data in Excel in 5 mn with LabScript"

To get a universal program using the Excel function of LabTab, please refer to the following topic in this document:

"How to put measurements in Excel in 5 mn with LabTab"

 

VbaExcel object - transfers to VbaExcel

 

Use

The VbaExcel object has two functions: "LabTab" and "LabScript" to transfer data obtained from instruments and from the "labScript" object.

This object can be used inside couples of "Configure" and "Unconfigure" functions of the "Iox" object, the functions of which it uses ( cf "Iox" description" ).

 

Functions

LabTab(VbaExcel_Variant_result, Address, Output_String, Wait_Value, LabScript_Format)

First argument

VbaExcel_Variant_result is a result in vector of column vectors form. This form is adapted to further use with the "Excel.VbaExcel" function. If "R" is the name of the result , then the i th element of column j is accessed in VBA by the expression "R(j)(i,0)" and the whole column j is is accessed by "R(j)". The index i and j start both at 0.

Second argument

Address is the IEEE-488 address of the instrument and is ignored for RS-232

Third argument

Output_String is a string argument to send to the instrument

Fourth argument

Wait_Value is a value in seconds to wait after the "output" operation.

Fifth argument

LabScript_Format is the string written in LabScript format that describes how the response bytes are entered in the cells of the columns of the Excel worksheet ( ex: "I4[100],S(100)" ).

To get a detailed description of the LabScript format, please refer to the following topic in this document:

"How to format experimental data in Excel in 5 mn with LabScript"

To get a universal program using the Excel function of LabTab, please refer to the following topic in this document:

"How to put measurements in Excel in 5 mn with LabTab"

 

LabScript(VbaExcel_Variant, LabScript_Variant, LabScript_Format)

 

First argument

VbaExcel_Variant is a variant result in vector of column vectors form. This form is adapted to further use with the "Excel.VbaExcel" function. If "R" is the name of the result , then the i th element of column j is accessed in VBA by the expression "R(j)(i,0)" and the whole column j is is accessed by "R(j)". The index i and j start both at 0.

Second argument

LabScript_Variant is a variant containing a string with each of its characters representing a number from 0 to 255 which is its ASCII number in the default language of the system ( LabScript representation on Windows platforms)

Third argument

LabScript_Format is the string written in LabScript format that describes how the response bytes are entered in the cells of the columns of the Excel worksheet ( ex: "I4[100],S(100)" ).

To get a detailed description of the LabScript format, please refer to the following topic in this document:

"How to format experimental data in Excel in 5 mn with LabScript"

To get a universal program using the Excel function of LabTab, please refer to the following topic in this document:

"How to put measurements in Excel in 5 mn with LabTab"

 

VBScript object - transfers to VBScript

 

Use

The VBScript object has two functions: "LabTab" and "LabScript" to transfer data obtained from instruments and from the "LabScript" object.

This object can be used inside couples of "Configure" and "Unconfigure" functions of the "Iox" object, the functions of which it uses ( cf "Iox" description" ).

 

Functions

LabTab(VBScript_Variant_result, Address, Output_String, Wait_Value, LabScript_Format)

First argument

VBScript_Variant_result is a result in vector of column vectors form. If "R" is the name of the result , then the i th element of column j is accessed in VBScript by the expression "R(j)(i,0)" and the whole column j is is accessed by "R(j)". The index i and j start both at 0.

Second argument

Address is the IEEE-488 address of the instrument and is ignored for RS-232

Third argument

Output_String is a string argument to send to the instrument

Fourth argument

Wait_Value is a value in seconds to wait after the "output" operation.

Fifth argument

LabScript_Format is the string written in LabScript format that describes how the response bytes are entered in the cells of the columns of an Excel worksheet ( ex: "I4[100],S(100)" ).

To get a detailed description of the LabScript format, please refer to the following topic in this document:

"How to format experimental data in Excel in 5 mn with LabScript"

To get a universal program using the Excel function of LabTab, please refer to the following topic in this document:

"How to put measurements in Excel in 5 mn with LabTab"

 

LabScript(VBScript_Variant, LabScript_Variant, LabScript_Format)

 

First argument

VBScript_Variant is a variant result in vector of column vectors form. If "R" is the name of the result , then the i th element of column j is accessed in VBA by the expression "R(j)(i,0)" and the whole column j is is accessed by "R(j)". The index i and j start both at 0.

Second argument

LabScript_Variant is a variant containing a string with each of its characters representing a number from 0 to 255 which is its ASCII number in the default language of the system ( LabScript representation on Windows platforms)

Third argument

LabScript_Format is the string written in LabScript format that describes how the response bytes are entered in the cells of the columns of the Excel worksheet ( ex: "I4[100],S(100)" ).

To get a detailed description of the LabScript format, please refer to the following topic in this document:

"How to format experimental data in Excel in 5 mn with LabScript"

To get a universal program using the Excel function of LabTab, please refer to the following topic in this document:

"How to put measurements in Excel in 5 mn with LabTab"

LabScript object - transfers to LabScript format

 

Use

The LabScript object has two functions: "LabTab" and "VbaExcel" to transfer data obtained from instruments and from the "VbaExcel" object.

This object can be used inside couples of "Configure" and "Unconfigure" functions of the "Iox" object, the functions of which it uses ( cf "Iox" description" ).

 

Functions

LabTab(LabScript_Variant, Address, Output_String, Wait_Value, LabScript_Format)

 

First argument

LabScript_Variant is a variant result containing a string entered from the instrument, with each of its characters representing a byte from 0 to 255 which is its ASCII number in the default language of the system ( LabScript representation on Windows platforms)

Second argument

Address is the IEEE-488 address of the instrument and is ignored for RS-232

Third argument

Output_String is a string argument to send to the instrument

Fourth argument

Wait_Value is a value in seconds to wait after the "output" operation.

Fifth argument

LabScript_Format is the string written in LabScript format that describes how the response bytes are entered in the cells of the columns of the Excel worksheet ( ex: "I4[100],S(100)" ).

To get a detailed description of the LabScript format, please refer to the following topic in this document:

"How to format experimental data in Excel in 5 mn with LabScript"

To get a universal program using the Excel function of LabTab, please refer to the following topic in this document:

"How to put measurements in Excel in 5 mn with LabTab"

 

VbaExcel (LabScript_Variant, VbaExcel_Variant, LabScript_Format)

First argument

LabScript_Variant is a variant result containing a string received from the instument, with each of its characters representing a number from 0 to 255 which is its ASCII number in the default language of the system ( LabScript representation on Windows platforms)

Second argument

VbaExcel_Variant is a variant in vector of column vectors form. This form is adapted to further use with the "Excel.VbaExcel" function. If "R" is the name of the result , then the i th element of column j is accessed in VBA by the expression "R(j)(i,0)" and the whole column j is is accessed by "R(j)". The index i and j start both at 0.

Third argument

LabScript_Format is the string written in LabScript format that describes how the response bytes are entered in the cells of the columns of the Excel worksheet ( ex: "I4[100],S(100)" ).

To get a detailed description of the LabScript format, please refer to the following topic in this document:

"How to format experimental data in Excel in 5 mn with LabScript"

To get a universal program using the Excel function of LabTab, please refer to the following topic in this document:

"How to put measurements in Excel in 5 mn with LabTab"

 

 

Clk object - Time control

Use

The "Clk" object contains two methods for time control:

 

Delay(Seconds)

Delay enables to wait for a duration, th value of which is transmitted as the argument, before the execution of the program resumes ( 1 microsecond resolution).

Delay returns n+1 where n is the time offset in microseconds, added to "seconds" by the function execution.

It is so possible to know the error on the realization of "Delay". In particular, when multiple programs are executed simultaneously, this value may be tested to ensure the effective value waited for.

Seconds (t)

Seconds returns a variant containing a double which corresponds to the number of seconds elapsed since the starting of LabTab2 session. This value never returns to 0 and its resolution is 1 microsecond.

This function accepts an untyped variant, containing a double or a variant which can be converted to this format.

Iox object

Use

In addition to the functions of the "Clk" objects, that it includes, the "Iox" object has, to control Gpib, serial and parallel ports, functions common to all the LabTab2 I/O objects:

 

Common I/O Functions

Define,Configure, Output , Enter et Unconfigure are the only I/O functions of the "Iox" object. They appear in this order in programs.

They can be used on all the Gpib , serial and parallel ports thanks to the LabTab2 configuration utility. A typical I/O sequence is:

Iox.Define

Iox.Configure

Iox.Unconfigure

With inside the Configure and Unconfigure functions , sequences  of this type:

Iox.Output adresse, " characters "

Iox.Wait seconds

Iox.Enter address , variable

In Output adresse, " characters ": address is a GPIB address if the port supports addressing (Gpib) or a dummy value otherwise (Ser and Par).

" characters " represents ASCII codes transmitted as a string or a variant to the device at the "address".

In " Enter address , variable": variable is a variant to receive the bytes from the device.

Example:

dim Iox as new a_Iox

Sub Idn

Iox.Define

Iox.Configure

Iox.Output 22 , " *idn ? "

Iox.Wait 0.3

Iox.Enter 22,a

Iox.Unconfigure

End sub

This programme sends "*idn?" via the "Iox" port and waits for a response. It is the program of the "Test" utility.

Configure-Unconfigure matching

The Configure and unconfigure instructions must match in number.

You can realize sequences of instuctions starting with Configure and ending with Unconfigure and group them into subroutines.

You can then insert these sequences inside other Configure-Unconfigure sequences without specific rules because the configure and unconfigure instructions are executed only once for a given object.

For instance, if you have the subroutine:

Sub Idn

Iox.Configure

Iox.Output 15 , " *idn ? " :Iox.Delay 0.3:Iox.Unconfigure

End sub

You can write :

Sub Idn2

With Iox

.Configure

.output 15 , " *idn ? "

Idn

.Unconfigure

Idn

End with

Idn

End sub

The last program will execute several times the emission of " *idn ? "

Functions

Configure()

This function configures the hardware according to the software definitions of the I/O path, set up by the "Define" function. The I/O path of concern is exclusively reserved to LabTab2 up to the execution of a final unconfigure instruction.

Define()

This function is used to set up the data I/O path used by the Output/Enter functions.

Most of the time this instruction is used without argument. In this case, all the information necessary to set up the I/O path is obtained from the LabTab2 manual configuration utility.

For instance, if you have selected in the first level of configuration "Gpib" in the "Iox" field, then the first argument of Define i.e. "IoxX" will default to "Gpib".

 

It is the first instruction of an I/O sequence. It makes the software operations necessary to determine the data I/O path. This path is determined in the order below from:

The names of its optional arguments are those of the LabTab2 ports or of their configuration parameters as shown in the manual configuratin utility, with an "X" suffix.

The "Iox" port correpond so to the "IoxX" argument of Define.

For instance:

If the "Iox" port connected to the "Gpib" port in the manual configuration utility, then both syntaxes below are equivalent:

"Define" or Define "Gpib"

However, if the "Iox" port is now connected to the "Ser" port by manual configuration, then the first synatax will use the "Ser" port for data I/O while the second syntax will go on using the "Gpib" port without , nevertheless, changing the configuration value. A third "Define" instruction without arguments will then use the "Ser" port again.

If an argument of "Define" contains a value not mentioned in the configuration options, then the default value of the configuration is used and sent back.

For instance:

If the "Iox" port is connected to the "Gpib" port in the configuration utility:

IoxX=" " : Define IoxX

Will send back "Gpib" in IoxX on Define output.

N.B.: In LabVIEW, you must use the "DefineEx" function with the same argument as a replacement of "Define" to have manual configuration values returned.

For most of the parameters, it is sufficient to initialize to an empty string. Nonetheless, for the handshake parameter, an empty value is permitted in manual configuration(equivalent to no handshake), it is so recommended to initialize this parameter with a string containing a question mark.

The set of optional arguments of Define enables to read or modify dynamically the configuration used by a program.

The dynamic reading of configuration is useful, for instance, to realize a pilot common to a GPIB and a RS-232 interface. It enables to read the Iox port content, for instance to adapt a terminator.

The dynamic change of configuration is useful, for example with protocols adapting the bauds rate on serial lines during the program execution.

The default configuration used as a reference cannot be change during LabTab2 library lifetime. It is the snapshot of the manual configuration on LabTab2 library load. The modification of this snapshot can only be temporarily changed by the optional arguments of "Define".

Enter (adr , data, [format])

Enter enables to receive bytes from an adress "adr" and to put them in a variant "data" provided or to build this variant automatically according to the directives contains in an optional "format" string

Enter stops when:

 

First argument

The first argument is a GPIB address between 0 and 30 (0 being the GPIB controller) and is ignored for serial and parallel ports.

 

Second argument

The second argument is a LabScript string with one character to represent each byte entered as an ASCII code.

Third argument

The third argument "format" is a variant containing a string.

If a valid "format" is provided , "Enter" retourne 1 sinon 0 et -1 sur erreur. Building a valid is achieved under the rules of the so-called "LabScript" notation. To get a detailed description of the LabScript format, please refer to the following topic in this document:

"How to format experimental data in Excel in 5 mn with LabScript"

N.B.: The Enter instruction is inactive when the physical port is a CENTRONICS parallel port. To obtain logical inputs, please refer to "Low level programming of serial ports", in this document

N.B.: The version 1 of LabTab does not support "LabScript" formats for "Enter" arguments, but only empty variant without type, simply declared as "dim data".

 

Output (adr , data, [format])

Output enables to send "data" in a LabScript string representing bytes to an address "adr". The address is ignored for serial and parallel ports.

The optional third argument "format" designates a character string interpreted as a "LabScript" format ( cf "Enter" function for a description of the "LabScript" format) which enables to reverse the byte order of bytes packets in the binary representation of "data" before their being emitted.

 

To send bytes in a variant, you have to declare them by the converson function Cbyte or transform them in characters by using the VBA function "Chr" and then concatenate them in a string with the "&" instruction.

For instance to send the bytes 1 et 255 , vous faites:

Iox.Output 15 , chr(1) & chr(255)

Unconfigure()

It is the last instruction of an I/O sequence. It frees the physical ports from exclusive use for LabTab2.

 

Gpib object - Specific programmation of the GPIB bus

We shall name "Gpib" object any object beginning by the prefix "Gpib" as: "Gpib,Gpib1,Gpib2,Gpib3,Gpib4". Such objects share the same functions for controlling the GPIB bus.

 

Use

The "Gpib" object is more specific than the "Iox" object. Indeed, it can only address the so-called "GPIB", "HPIB" or "IEEE-488" links for which it offers specially designed instructions.

If you use only the instructions common to "Iox" and "Gpib" objects, please consider using the more general object "Iox" otherwise choose "Gpib".

 

 

 

 

 

Instructions common with the "Iox" object

A "Gpib" object has for controlling GPIB bus , instructions of the "Iox" object, as on all the I/O LabTab2 objects .

Please refer to the "Iox" object description for a detailed description of these functions.

 

Specific instructions of "Gpib" objects

A "Gpib" object has specific instructions for low-level programming of GPIB bus. You will have to use a "Gpib" object if you need the instructions:

Send sends low level GPIB commands to the bus (Dcl, Get, Gtl, Llo, Mla, Mta, Sdc, Spd, Spe, Tct, Unl, Unt, Listen, Talk, Sec, Ppc, Ppd, Ppu et Ppe ).

Ppoll performs a parallel poll on GPIB bus.

Spoll performs a serial poll on GPIB bus.

 

Fonctions

 

Ppoll (Byte_Value)

Sends back a byte in "Byte_Value" being the response of GPIB bus to a parallel poll.

 

Spoll (Address, Byte_Value)

Sends back a byte in "Byte_Value" being the response of GPIB bus to a serial poll at "Address".

 

Send String_commands

Send instruction accepts as argument, low-level GPIB instructions. These instructions are treated as strings and can be concatenated with the "&" character.

The GPIB controller is always at address 0 without secondary address.

The detailed description of these commands should be obtained from specialized books and they are out of the scope of this first contact with LabTab2 manual. Only the syntax to make them operate is psecified.

The characters corresponding to low level commands correspond to the function names followed by an underscore "_" in the function list of the Gpib and Gpibn objects where n où n is a figure.

The arguments of these functions may then be concatenated as ordinary strings to constitute the "Send" argument.

Les arguments de ces fonctions peuvent ensuite être concaténés comme des chaînes ordinaires pour former l’argument de Send.

Example :

With Gpib

S= " "

.Unt_(C) : S=S & C

.Unl_(C) : S=S & C

.Mta_(C) : S=S & C

.Listen_(15,C) : S=S & C

.Send S

end With

sends " UNT UNL MTA LISTEN 15 " on the bus.

 

Gpib bus commands 

One can separate commands with and without address.

In these functions, the returned value is a string. These strings must be concatenated to be used as an argument for "Send".

The address of a command is a figure between 0 and 31 (the controller is always initialized to the 0 address by LabTab2).

Commands without address :

Dcl_ (s) : DEVICE CLEAR

Get (s) : GROUP EXECUTIVE TRIGGER

Gtl_ (s) : GO TO LOCAL

Llo_ (s) : LOCAL LOCKOUT

Mla_ (s) : MY LISTEN ADDRESS ( équivaut à LISTEN(0) en LABTAB )

Mta_ (s) : MY TALK ADDRESS ( équivaut à TALK(0) en LABTAB)

Sdc_ (s) : SELECTED DEVICE CLEAR

Spd_ (s) : SERIAL POLL DISABLE

Spe_ (s) : SERIAL POLL ENABLE

Tct_ (s) : TAKE CONTROL

Unl_ (s) : UNLISTEN

Unt_ (s) : UNTALK

Commands with adress :

Listen_(s,adr, ) : LISTEN(adr)

Talk_(s,adr ) : TALK (adr)

Sec_ (s,adr) : SECONDARY(adr) emission of a second address byte after a first one (secondary address)

Example 1:

Listen_(s1,5) followed by Sec_(s2,1) and Send (s1 & s2) makes a listener, the device at the primary address 5 and secondary 1.

Example 2 :

Talk_(s1,5 followed by Sec_(s2,1) and Send (s1 & s2) makes a talker, the device at the primary address 5 and secondary 1.

 

Parallel poll commands (PARALLEL POLL) :

These commands are used to determine the parallel poll response of devices on the bus.

One byte command - Ppu_(s) : PARALLEL POLL UNCONFIGURE

Prevents any device to answer a parallel poll, whatever its GPIB address.

Two-bytes command - Ppc_ (s1) : PARALLEL POLL CONFIGURE

Configure the listeners response to a parallel poll request.

This command must be followed by either the disable Ppd_(s2) or enable Ppe_(s2,S,N) command.

Ppd_(s2) - PARALLEL POLL DISABLE

As the second byte of a GPIB command, it must be send just after the emission of a "Ppc_" command. It prevents any listener to answer a parallel poll, after receiving this command.

Ppe_(s2,S,N) - PARALLEL POLL ENABLE

Build the byte response of listeners to a parallel poll. The arguments S and N defines the bit value and position sent back on parallel poll by the listeners, as follows:

Example :

Listen(s0, 20 ) followed by Ppc_(s1)  then Ppe_(s2,1,3) and Send (s0 & s1 & s2) defines an answer of 1 on the fourth bit in a response to a parallel poll of the device at address 20, thus a value of 8 ( 2 to the power of 3 )for this byte.

Listen(s0, 20 ) followed by Ppc_(s1)  then Ppd_(s2) and Send (s0 & s1 & s2) suppresses the parallel poll response of the device at address 20.

 

 

 

 

 

 

Ser object - Specific programming of RS-232 ports

A "Ser" object is any object with a name starting with the prefix "Ser" as: "Ser,Ser1,Ser2". These objects share common functions.

Use

A "Ser" object is more specific than the "iox" object. Indeed, it can only control RS-232 ports for which it has specific instructions.

If you use only instructions common to "Iox" and "Ser" objects, please consider using the more general "Iox" object.

Otherwise, choose "Ser".

Instructions common with "Iox" object

A "Ser" object has for controlling RS-232 ports , instructions of the "Iox" object, as on all the I/O LabTab2 objects .

Please refer to the "Iox" object description for a detailed description of these functions.

 

Specific Instructions of "Ser" objects

A "Ser" object has specific instructions for programming RS-232 ports at a low-level. You must choose a "Ser" object to use this instructions.

Low-level programming of the RS-232 ports enables to have logical inputs and outputs on the different versions of

Windows 95,98,Me,NT ,2000 and XP.

Low level programming of RS-232 input lines:

This lines correspond to names:

- "  Data Carrier Detection " or " CD " or " RSLD " (pin 1 on DB9 RS-232 PC connector)

- "  Ring Indicator " or " RI " " ( pin 9 on DB9 RS-232 PC connector)

- "  Data set ready " or " DSR " "( pin 6 on DB9 RS-232 PC connector)

- "  Clear to Send " or " CTS " " (pin 8 on DB9 RS-232 PC connector)

The status of these input lines on a PC is obtained for a "Ser" object by the instructions:

"  Cd_ " , " Ri_ ", "Dsr_ " et " Cts_ " respectively (name of these lines followed by an underscore "_").

The syntax of all these functions is identical: they return a variant which is a 1 for a high level on the line or a 0 for a low level. They enable to use 4 logical inputs.

The main interest of these inputs is the high input bandwidth. It is so possible to reproduce a square signal between 2V and -2V up to a frequency of 200 kHz on a Pentium III 1GHz.

 

Low level programming of RS-232 output lines:

This lines which can be driven, correspond to names:

These lines give logical output thanks to "RTS_on / RTS_off" and "DTR_on/DTR_off" functions of a "Ser" object. The functions "RTS_on" and "DTR_on" set up RTS et DTR respectively while " RTS_off and "DTR_off" set them down.

 

 

Par object - Specific programming of CENTRONICS ports

A "Par" object is any object with a name starting with the prefix "Par" as : "Par,Par1,Par2". These objects share common functions.

 

Use

A "Par" object is more specific than the "Iox" object. Indeed, it can only control parallel ports.

If you use only instructions common to "Iox" and "Par" objects, please consider using the more general "Iox" object.

For instance, if you use a RS-232 or GPIB port together with a parallel port, you must choose the "Par" object if you want them to be opened simultaneously.

Instructions common with "Iox" object

A "Par" object has for controlling CENTRONICS ports , instructions of the "Iox" object, as on all the I/O LabTab2 objects .

 

Please refer to the "Iox" object description for a detailed description of these functions.

The "Enter" instruction is not active for the CENTRONICS ports in this LabTab2 version.

 

Specific Instructions of "Par" objects

There are no specific instructions for "Par" objects.

Low level programming of CENTRONICS output lines:

The PC parallel port enables in its normal use to send characters to a Centronics printer.

The " par ", "par1 " et " par2 " enables with no restrictions to write on such printers of this type.

It is also possible to use the parallel port in a stand-alone way to provide eight digital output lines. In thiscase, one can use the "Output" instructions in a standard way.

The conditions to use this port are usually:

A typical sequence for writing the logical level 1 on pin 2 of the DB25 connector connected to the "Par" port is then:

With par

.define

.configure

.output 0, chr(1)

.unconfigure

end with

The availability of these logical outputs is obtained with Windows 95,98,Me,NT, 2000 and XP.

The enter instruction exists for Windows parallel ports but is reserved for a future use. No data can be input with LabTab2 on this type of port by the "Par","Par1" or "Par2" objects.

Lvx object - Utility functions for variants

 

Use

The Lvx object offers functions available outside the I/O objects:

 

Len_Variant

This function puts in its first argument the length in bytes of the Variant given as its second parameter.

High speed Excel transfers

For exchanging data with Excel, the Lvx instructions are Range_Variant and Variant_Range. With this minimum set of instructions, you can import at high speed, the data in Excel sheets.

They can send to Excel ranges (Range_Variant) or receive from Excel ranges(Variant_Range) arrays at high speed.

These instructions are about 10 times faster than the transfers involving cells and array elements.

They work from any Windows application, Excel and the selected Workbook can be open or closed.

 

Conversion between variant and binary

The binary format is the one of a variant returned by the Enter function when the entry format of its result is empty ( not declared variant or variant declared only by "Dim"). LabTab2 choose then a format depending only on the platform and representative of a byte vector, to optimize speed. To use the entered bytes, you must convert them in a variant adapted to your treatment, with the help of the Variant_Binary function. You can make the inverse operation with Binary_Variant.

Conversion between variant and file

You can write a variant to a file with the File_Variant function and read a variant from a file with the Variant_File function.

Functions

 

Len_Variant (Len, Data )

Returns the byte length of Data in Len.

 

Variant_Range (a, Workbook_FullName, Sheet_Name,lin1, col1, lin2, col2)

This instruction creates a variant array "a" with two dimensions of first element index 1 from:

The Excel worksheet " Sheet_Name" situated in the workbook "Workbook_FullName" (full DOS name with path name and extension ) and the range corresponding to the upper left cell (lin1,col1) and lower-right (lin2,col2).

" a " must be empty in input, for example, dimensioned by "dim a" and it is transformed in a matrix with index origin 1 for lines and columns. It can, for instance, be used as such by "RangeFromMatrix".

One has to notice that " RangeToMatrix" is the only way to create a matrix with index origin equal to 1 in script langages as VBscript.

Example :

Dim a

Lvx.RangeToMatrix "c:\Temp\Test.xls", "Feuil1",1, 1, 2, 2, a ‘ ceate a 2x2 matrix

 

Range_Variant (Workbook_FullName, Sheet_Name,lin1, col1, lin2, col2, a)

This instruction sends the variant array "a" to the Excel worksheet " Sheet_Name" situated in the workbook "Workbook_FullName" (full DOS name with path name and extension ) and the range corresponding to the upper left cell (lin1,col1) and lower-right (lin2,col2).

"a" must be a one-column matrix to be put in column, a vector is considered as a line. If the range is too small, "a" values are truncated.

To export this function in other langages than VBA, a must be declared with a zero index origin for all its dimensions. For example: "dim a(2,3)". However, if this matrix is the reslut of "RangeToMatrix", then its index origin is 1 but still correctly handled by this instruction.

Exemple :

Dim a

Lvx. Range_Variant "c:\Temp\Test.xls", "Feuil1",1, 1, 2, 2, a ‘ sends a , matrice 2x2, in "Feuil1"

This instruction replaces in Vbx, the MatrixToRange instruction of the Vbx version 1 object.

 

Variant_Binary (R, B, I , J, [P] )

This function copies "J" bytes of "B", starting at byte "I" (origin =1), in "R", swapping each group of "p" bytes if this optional parameter is given.

R can be an arbitrary complex variant (variant array etc. …) built from numeric and string types.

Bconvert does not respect the type of result in only one case: result is of null length in bytes. In this case, instead of converting no bytes, the first element of result will be extended to receive J bytes:

In any other case, the types of the R elements is respected, in particular, if the number of bytes in R is not J, then the function fails to execute.

As mentionned earlier, defining as a variant array the result of the Enter instruction before calling it, may make this instuction not frequent for data input-output.

For instance: 

Dim s as string ‘variable string

Len_Variant( L , data) ‘ we assume that data contains bytes

Variant_Binary ( s, data, 1 , L) ' transfers the whole bytes of data in the only element of result, which is s string.

Binary_Variant (B , I , J, R, [P])

This function copies in J bytes of B, starting at byte I (origin =1) the bytes of R, swapping each group of "p" bytes if this optional parameter is given.

R can be an arbitrary complex variant (variant array etc. …) built from numeric and string types.

When the number of bytes in R is not J, the function fails.

 

File_Variant( File ,V )

Transfer of the bytes of a variant "V" to a file described by its full name including path in "File".

Variant_File( Variant , File)

Transfer of the bytes, from a file described by its full name including path in "File", into a variant "V" .

 

Mix object _Miscellaneous utility functions

 

Use

The Lvx object offers the functions:

 

Decimal separator change

DecimalSeparator enables to replace on place in a variable the decimal separator of a langage 1 by the one of langage2. This is useful to write international applications.

 

HTML files display

The HtmlFileShow function enables to display in Internet Explorer a file in HTML format given in its unique argument. This is useful if you need, for example, to display from a program an Help in HTML format.

 

Functions

 

DecimalSeparator ( data , lang1, lang2)

Change the decimal separators of language "Lang1" found in "data" in the decimal separators of language "Lang2".

Language names are given in english.

For instance:

S="1.234"

DecimalSeparator(S,"english","french") ' gives S="1,234"

HtmlFileShow ( F )

Displays on screen the HTML file of name given in F.

 

USE WITH OTHER LANGUAGES THAN VBA

 

Introduction

It is quite possible to program with LabTab2 library from other langages as VBScript, one of the langages of Microsoft Internet Explorer.

Examples are included within the distribution disk of LabTab2. The LabTab2 library being a COM component, the declaration of the Iox2c.dll classes in any langage is identical to the one of the classes of any COM or ActiveX component.

Please refer to the online help of your programming environment to have ActiveX components declared.

 

Native interface of LabTab2 library.

In the case where you do not wish to use COM classes, it is possible to call directly the LabTab2 DLL, Iox2c.dll, in the Windows directory.

Conventionnally, the native full function name of an object is obtained from the class name with underscore and the function name. This convention is true for any class and function of Iox2c.dll.

For instance, the "Enter" function of the "a_Iox" class can be called with the same arguments by the "a_Iox_Enter". function.

The whole syntax of labTab2 can thus be used from the native interface. To avoid confusion between classes and objects, full function names should use "object" names ( class names without prefix) where possible.

In VBA, the function can be declared by :

"Declare Function Iox_Enter Lib "Iox2c.dll" (adr , data, optional n) As Long"

 

You can, with the native interface, write in LabTab2, I/O sequences , from langages supporting only the call to a conventional DLL. For a commercial script, this may be valuable, for instance to avoid registering your applications by your clients.

LabVIEW

LabVIEW can call conventional DLL or ActiveX DLL. You can refer to the documentation of this software to use LabTab2 with it.

A program sample (VI) is provided with LabTab2 for using LabTab2 as an activeX component with LabVIEW which is the recommended method.

In LabVIEW, the use of the "Port" function is the way to write common "RS-232"/"GPIB" drivers since LabVIEW accepts but do not return the optional arguments of "Define".

 

Microsoft Internet Explorer - VBScript – ASP – IIS

With Microsoft Internet Explorer, you can use any scripting engine to write your applications. Your files must be created with the "hta" and not "htm" extension to avoid security messages when creating LabTab2 objects in script code.

With Vbscript, you can use Notepad to write your program but other more convenient HTML editors may be used

(VBA Excel is also possible but common instructions to VBA and VBScript must be used).

You can used also ASP in version "Personal Server" or "Internet Information Server ".

The keyword " CreateObject " enables you to declare the LabTab2 classes of Iox2c.dll.

You will notice that LabTab2, enables to migrate easily towards VBScript, if some rules are respected in code:

An example of code for Test is :

Sub Test(pAdr,pO,pD,pE, optional pIoxX)

Dim Iox : Set Iox=CreateObject(" Iox2c.Iox_ ")

Iox.Define pIoxX

Iox.Configure

Iox.Output pAdr,pO

Iox.Wait pD

Iox.Enter pAdr,PE

Iox.Unconfigure

End Sub

  

Compilation of LabTab2 modules in C, C++ and Visual Basic

To compile and distribute your pilots, Visual basic and Visual C++ may be used.

 

Visual Basic

With Visual Basic, the creation of COM DLL using LabTab2 is straightforward as soon as the LabTab2 objects have been declared from the LabTab2 classes by "new" or "CreateObject".

It even exists an "Implements" keyword to derive your classes from the LabTab2 classes ( please see VB manuals).

Most conveniently, you can declare a reference and use the keyword "New" to benefit statement completion or use "CreateObject".

An example of code for Test is :

Sub Test(pAdr,pO,pD,pE, optional pIoxX)

Dim Iox : Set Iox=CreateObject(" Iox2c.a_Iox ")

Iox.Define pIoxX

Iox.Configure

Iox.Output pAdr,pO

Iox.Delay pD

Iox.Enter pAdr,PE

Iox.Unconfigure

End Sub

 

Visual C++ version 6.0

You can access the LabTab2 classes as a Windows component from a Visual C++ program. The procedure is described in the file " C:\LabTab\2c\VC6\Test_C.cpp ", the listing of which is below:

 

Listing C++

#include "c:\LabTab\2c\m_Iox2c.h"

 

int __stdcall Test(VARIANT * pAdr, VARIANT * pO, VARIANT * pD, VARIANT * pE, VARIANT * pIoxX) // pIoxX can be sent as optional argument

{             

                r=Iox_Define(pIoxX); // N.B.:The last optional arguments of this prototype MAY BE OMITTED

                r=Iox_Configure();                             

                r=Iox_Output(pAdr,pO);  

                r=Iox_Wait(pD);                                

                r=Iox_Enter(pAdr,pE); // N.B.:The last optional argument of this prototype MAY BE OMITTED   

                r=Iox_Unconfigure();                        

                return 1;

}

It is only needed to add a new path to "include" files for compilation and add the "Iox2c.lib" for linking.

The whole set of "Iox2c.dll" is then available with this method.

 

Visual C++ version 6.0 used with COM

You can use the "#import" directive of the compiler to access to the labTab2 classes of "Iox2c.dll" as a COM component for your Visual C++ program.

The procedure is described in the file " C:\LabTab\2c\VC6\Test_COM.cpp ", the listing of which is below:

 

Listing C++

#import "c:\LabTab\2c\Iox2c.dll" no_namespace

 

int __stdcall Test(VARIANT * pAdr, VARIANT * pO, VARIANT * pD, VARIANT * pE, VARIANT * pIoxX) // pIoxX can be sent as optional argument

{

                IIox_Ptr Iox (__uuidof(Iox_ ));                                                         // Iox

                              

                Iox->Define(pIoxX); // N.B.:The last optional arguments of this prototype MAY BE OMITTED

                Iox->Configure();               

                Iox->Output(pAdr,pO);     

                Iox->Delay(pD);                                 

                Iox->Enter(pAdr,pE); // N.B.:The last optional argument of this prototype MAY BE OMITTED     

                Iox->Unconfigure();                          

                return 1;

}

 

 

Listing for call from Excel

The calling code from Excel-VBA for your DLL created with the COM interface of LabTab2 is

Declare Function Test Lib "c:\LabTab\2c\VC6\TestX.dll " (pAdr, pO, pD, pE, Optional pIoxX) As Long

Sub TestXL()

IoxX= "  "

Test 22, " *idn ? ", 0.3, a , pIoxX

End Sub

For this use with Excel, the workbook " C:\LabTab\2c\VC6\TestX.xls " is provided with LabTab2.

To make a COM DLL from this DLL report to the example provided or to the compiler documentation.

 

 

COMPATIBILITY ISSUES

If you do not have LabTab1 applications, you can skip this section

Using LabTab1 applications

LabTab 1and 2 are independent, you can therefore use them jointly in new or modified developments. You only need to ensure efficient access to hardware.

Using LabTab1 code outside Excel/VBA

Using with LabTab2, code developped with prior versions of LabTab running in the Excel-VBA environment can take different forms depending on the environment used with LabTab2.

Excel-VBA

To use LabTab2 with LabTab 1 programs, you only need to suppress in your developments, the reference to the LabTab version 1 workbook and establish a new reference to the workbook of LabTab2, named:

" c:\LabTab\2c\Excel\LabTab2c.xls "

Your code should run with no change in the Excel-VBA environment. Your developments are preserved as a whole.

In this environment and with the workbook LabTab2.xls, the " DoEvents " instruction of Excel-VBA and " DelayWithEvents " of LabTab can be used to enable the modification of the Excel worksheets and the graphics update during the execution of LabTab2 programs.

Microsoft Office - VBA

To use in VBA VBA (Access,Word, Powerpoint, FrontPage,Excel, etc. …) and LabTab2 programs written with Excel-VBA and LabTab 1, you need to:

Proceeding this way, your LabTab1 code works, as a whole. without syntax change, in VBA environment. Your developments are preserved as a whole. Changing the program may occur however, to take into account the fact that "DelayWithEvents" of Vbx, do not yield the control while waiting, in LabTab2. If your environment supports the "DoEvents" instruction, you will be able to use the "Seconds" function of LabTab2 to re-create a " DelayWithEvents" function identical to the one of LabTab1. Refer to the document topic below:

"Multitasking behaviour under VBA - DoEvents"

Visual Basic and Internet Explorer-VBScript

Code written in Excel-VBA with LabTab1 can be used as such with LabTab2 in Visual Basic, submitted to the conditions of using VBA instructions present in VB. Declaring LabTab1 objects in VB, is performed the same as in the previous section. InVBScript, you need to use the "CreateObject" keyword.

LabVIEW and Visual C++, …

LabTab2 can be used in various environments. Prior code written with LabTab version 1must be then translated. However, the syntax of I/O operations remains the same and porting the code is simplified.

The compilation of a program written for LabTab version 1 as a LabVIEW "vi" or a Windows DLL is so possible. Please refer to the section " programming with other langages than VBA" in this manual to perform such operations.

 

Toolbar use

The LabTab2 toolbar is obtained outside Excel in version 2, you can obtain this toolbar by running the file " c:\LabTab\2c\LabTab2c.exe " or by clicking on its shortcut on your desktop if you have created one. You can then choose the "Config" button" of the startup screen in order to obtain a configuration environment identical to the one of LabTab version 1.

The names of the buttons of " LabTab2c.exe " are corresponding to the ones of the LabTab1 toolbar: " Copyright " " Config " and " Help ". In addition, a new "Test " button enables you to dialog directly via the "Iox" path with your instrument.

 

 

ADVANCED TOPICS

Choosing among LabTab2 objects for programming

LabTab2 has " Gpib , Ser,Par ,Gpib1,Gpib2,Ser1,Ser2,Par1 et Par2 " objects, which have the same properties and methods as the "Iox" port.

"Gpib" and "Ser" ports also have functions specific to the port type they represent. If you miss functions in "Iox", you can directly program with these objects, for instance, the low level functions for controlling the GPIB bus and RS-232 ports are include in "Gpib" and "Ser" ports respectively.

Programming with several ports of the same type is also possible by programming different objects: Gpib1 to Gpib4,Ser1 to Ser2, Par1 to Par2.

It is also possible to change the protocol used for the "Iox" object via the optional arguments of "Define". Giving the IoxX argument the value "Gpib" , "Ser" or "Par" , it is possible to use the "Iox" object to program all types of LabTab2 ports. As a general rule, the options chosen with the LabTab2 configuration utility can all be set via the optional arguments of "Define" of the objects ("Iox","Gpib", etc. …).

Programming with "Iox" enables only one at time I/O path to be active but it can be redefined thanks to the "Define" instructions and their optional arguments. This way, one can say that the I/O paths are defined sequentially.

With the other objects, several I/O path can be defined "simultaneously". Depending on the cases, both methods may have to be used. The first one is the more universal, since it makes the code sequences for ports independent.

It is the one recommended with LabTab2.

 

Using several ports sequentially

The utility configuration determines normally, the protocol used by "Iox" or the port used by the " Gpib ",  " Ser " or  " Par " objects.

You can however choose in programs the protocol used by "Iox" by adding to the "Define "instruction an optional argument named IoxX which can receive the " Gpib,Ser ou Par " values.

This instruction chages then, for the program, up to the next "Define", the configuration parameters and the next "Configure" instruction will take this into account up to the next "Unconfigure". This enables to commute from a protocol to another by program.

This possibility extends to any LabTab2 object.

For instance, to switch from "Gpib1" to "Ser1" port , one can write the code:

With iox

Define ioxX := " Gpib ", GpibX := " Gpib1 "

Configure

Unconfigure

End with

With Iox

Define ioxX := " Ser ", SerX := " Ser1 "

Configure

Unconfigure

End with

 

Using several ports simutaneously

To use several ports simultaneously, you can open the protocols or ports silutaneously. For instance:

Ser1.Configure

Ser2.Configure

Ser1.output 15 , " xxx "

Ser2.output 15 , " xxx "

Ser1.Unconfigure

Ser2.Unconfigure

This technique can be used if you wish to save the execution time of Unconfigure and Configure between the "Output" instructions. Otherwise, you will have to write:

Ser1.Configure

Ser1.output 15 , " xxx "

Ser1.Unconfigure

Ser2.Configure

Ser2.output 15 , " xxx "

Ser2.Unconfigure

  

 ***

 

Handling optional arguments

 The Define function is an example of function of Iox2c.dll with optional arguments( always of variant type).

The LabTab2 functons accepts in any langage, the omission of the totality or of trailing optional parameters and the transmission of a null pointer (NULL ) as indication of a missing optional parameter.

Only these techniques can be used when translating code. You can for instnace, transmit a null pointer in VB by &0.

In the VBA,VB and VBScript, the LabTab2 functions support also the omission of intermediate optional arguments and named arguments.

 

Synthesis and measure of logical signals

With low level programmed access of serial and parallel port, as well as the functions Seconds and Delay, it is possible to enview the creation and acquisition of logical signals up to 500 kHz , simply with a serial or parallel port.

Pulse emission

The delay function halts execution during a delay of microsecond range accuracy.

By switching the state of a hardware line before and after the "Delay" function, it is so easy to send an electrical pulse on a line of a serial or parallel port. In addition, the delay function returns a value equal to 1+n where n is the error of realization in microseconds on the target delay. It is so easy to know the width value of the actual pulse emitted with 1 microseconds precision.

 

Measuring a pulse width

The function "Seconds" may be used for applications demanding the measurement of a pulse width. It can be performed by continuously polling the value of an input line of a serial port and measuring the time when transitions occur with Seconds.

Multitasking with VBA - DoEvents

There is no way to yield control to the user while waiting during the "Delay" instruction.

If your programming environment is VBA, you can nevertheless obtain this effect with "inline" code using the "Seconds" instruction of Clk and the VBA instruction "DoEvents"

 

Do Events - Program interruption

The DoEvents instruction of VBA enables to wait during a time interval without loosing the focus in the parent application.

It can be used to:

The "DoEvents " instruction is very important in applications purely in VBA to stop a running program, for instance by pressing on the "Ctrl" and "Esc" keys. It can be used, in Excel, also to watch for the content of a cell and stop the program if a given value is entered during program execution. To use such a feature, access is needed to the Excel cells during execution thus insertion of at least one "DoEvents" instruction in the program flow and especially non-critical loops.

Outside VBA, Windows ensures a multitask operation of the applications and the "DoEvents" instruction is useless and de facto missing in the other langages. Nonetheless, this instruction is precious for an aplication entirely written in VBA.

Being specific to VBA, the "DoEvents" instruction cannot neither be used with other langages nor compiled. You will have to insert "DoEvents" instruction, manually, in repetitive part of your code to authorize your application to work in parallel with your VBA program. You will also have to think of excluding it from the parts of the code that you would like to compile in the future or export to other langages.

Programming non blocking delays

Except the disclaimer on "DoEvents" use, programming a non-blocking delay with Excel can be nevertheless done easily and effectively, by using the "Seconds" instruction in Vbx with the "DoEvents" keyword.

The corresponding "inline" code in VBA for a delay dt is:

t=Cdbl(0):t1=Cdbl(t1):Clk.Seconds t: t = t + dt: Do: Clk.Seconds t1:DoEvents : Loop While (t1 < t) 

Please notice that the "DoEvents" presence prevents this code from being exported outside VBA and that the time uncertainty is about 50ms.

During I/O operatins, the "DoEvents" instruction is not recommended since it brings about a time uncertainty in delay execution and reduces the portability of I/O sequences..

 

SAMPLE DRIVER

The following code corresponds to the one of the "Test" utility provided with the LabTab2 toolbar.

With a national Instruments GPIB board with a VISA name Gpib0, if you want to output the "*idn?" string to an instrument at address 15, then transform the answer in string, the code is shown below:

Select each time with "ok", then "Gpib" then "Gpib1", then " National Instruments" then "ATGPIBTNT " (a Generic board) and finally "GPIB0".

Close the configuration utility.

Write the following code in Excel/VBA and run it with "F5" function key or whatsoever mean to run the test macro.

Sub test

Dim Iox: Set Iox=CreateObject ("Iox2c.a_Iox") ‘ or dim Iox as new a_Iox ' to benefit statement completion

Dim s: s=""

With iox

.define

.Configure

.output 15 , " *idn ? "

.Wait 1

.enter 15 , s

.Unconfigure

End with

Msgbox s

End test

The test must display the response of your instrument. This program will work on any valid configuration of LabTab2, on another machine, another GPIB board or a serial port with an instrument answering to "*idn?"

 

 

INTERNET AND INTRANET USE OF LABTAB

LabTab can be used to realize experiments on GPIB,RS-232 or parallel ports via Internet or an Intranet.

This feature is obtained in:

- Starting a LabTab IP server , from the toolbar "IPLab" button, on a remote machine used as a server. This server listens to the LabTab port (3129) and to any IP address of the server.

The whole objects of labTab, said local, having an "Output" function, have a corresponding IP object with the same functions. These are Iox_IP, Gpib_IP, Gpib1_IP, Gpib2_IP, Gpib3_IP, Gpib4_IP, Ser_IP, Ser1_IP, Ser2_IP, Ser3_IP, Par_IP, Par1_IP, Par2_IP.

All the objects having a "LabTab" function have an IP object with this function only.

The prototype of any IP function can be deduced from the one of the local function having the same name in adding three additional initial parameters:

A new object "IP" having a unique function "Lab" is available, which enables to send the command string to the serveur for execution and to receive in the same string the server response.

The prototype of this function includes 5 parameters:

For instance, to execute the command set

Iox_Output(22,"*idn?")

Iox_Delay(0.3)

Iox_Enter(22,a)

On a server at address 127.0.0.1 on the LabTab port (fixed at 3129), the VBA code is the following:

Dim Iox_IP as new Iox_IP_

Cmd=""

' Formation of batch program

Sense=1

Iox_IP.Output(Sense,cmd,r,22,"*idn?")

Iox_IP.Delay (Sense,cmd,r,0.3)

Iox_IP.Enter (Sense,cmd,r,22,a)

'Emission of batch program

IP.Lab("127.0.0.1","3129" , Cmd, 1, 25)

' reception of results

Sense=-1

Iox_IP.Output(Sense,cmd,r,22,"*idn?")

Iox_IP.Delay (Sense,cmd,r,0.3)

Iox_IP.Enter (Sense,cmd,r,22,a)

On output of this program, the variable "a" contains the result of distant execution. To add commands, it is sufficient to add them on emission (before the IP.Lab call) as well as in reception ( after this call ).

If there are arguments for the IP functions, they just have to be mentioned on emission and reception and they are translated and restituted automatically.

This method enables to submit as one batch , at the time of the IP.Lab call, a command set for data input/output operations, to the server, preserving at best, the time sequence of these operations, independently of the IP network unpredictible delay for transmitting commands.

 

CONCLUSIONS 

The information and samples provided show that LabTab2 enables:

The LabTab2 drivers are so largely independent of the hardware they used and of the software that calls them.

An instrument manufacturer can also integrate a driver inside the LabTab2 library to give to the user the possibility to use this driver with an OEM version of LabTab2 with no need to buy a key for LabTab2.

Hence, LabTab2 appears to be able to be an open and general instrumentation library for Windows.

 

END OF THE MANUAL