1) We can also utilize Microsoft Visual C++ and debug our drivers

TYX Corporation

Productivity Enhancement Systems

Reference

TYX_0051_20

Revision

1.4

Document

IVI in PAWS Demo.doc

Date

January 10, 2007

 

 

 

IVI-COM in PAWS Studio Demo


Applications used:

TYX PAWS Studio 1.34.6

 

Agilent IO Libraries Suite 14.2.msi (IVI Shared Components v. 1.2.1)

 

Instrument driver 34401 IVI-COM 1.1.0.11

 

Microsoft Visual Studio C++ 6.0

 

Operating System Windows XP Pro SP2

 

Introduction:

This document will help to create a WCEM driver that will help interface the ATLAS code with an IVI-COM instrument driver using the TYX Paws Developer Studio.

As an example we use the IVI-COM driver for Agilent 34401A DMM.   

 

The assumption will be made that the user is familiar with the Paws Developer Studio.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


1         List of requirements

In the PAWS Project example presented in this document we set a goal to implement the following functionality related to the IVI-COM driver:

·        During the initialization, set the following:

o       Resource Name to GPIB address 23

o       IDQuery to false

o       Reset to true

o       Simulate to true

·        Configure the DCVoltage to a range of 1.5 with a resolution of 0.001.

·        Set the Delay property to 0.01.

·        Take a reading with a timeout of 1000.

·        Close the driver session. 

2         Creating the environment:

2.1           Creating PAWS Project

 

  • Open PAWS Studio application and navigate to File\New Project… You should see the following images:

 

Figure 1

 

Figure 2

 

  • You will need to enter the project name and the directory for your project. In this case, we can call the project IVI_COM_DMM. The directory can be anywhere that is convenient for you on your system.

 

Figure 3

 

  • At this point, you can click on OK.

 

  • Now you need to add and ATLAS file to your project and a device database description. The ATLAS file will be part of an ATLAS project module and the device database will be part of the device database project module. After creating a new PAWS project, you are given an ATLAS project module. You just need to add a new file to that module. You will then have to manually add a device database project module before adding a device database file to it.

2.2           Adding Paws Files to the project

 

  • Adding the ATLAS file to the ATLAS project module: We will chose to call this file atlas.atl. From the toolbar, you need to select File\New File…:

 

Figure 4

 

  • This will yield to the following window:

 

Figure 5

 

  • Check the option to add the file to the project
  • And enter the following File Name: atlas as shown below:

 

Figure 6

 

·        Copy the following source code and paste it into the atlas.atl file:

 

 

 001000 BEGIN, ATLAS PROGRAM 'IVI-COM DMM'                   $

 001010 REQUIRE, 'DMM-DC-VOLTS', SENSOR(VOLTAGE), DC SIGNAL,

            CONTROL, VOLTAGE RANGE -300 V TO 300 V,

            MAX-TIME RANGE 1 SEC TO 5 SEC,

            CNX HI LO                                       $

C$

 001110 DECLARE, VARIABLE, 'MEASURED' IS DECIMAL            $

C$

E02000 OUTPUT, C'\LF\ATLAS PROGRAM STARTS HERE\LF\'         $

C$

 002200 VERIFY, (VOLTAGE INTO 'MEASURED'),

                DC SIGNAL USING 'DMM-DC-VOLTS',

            NOM 0 V UL 0.5 V LL -0.5 V,

            VOLTAGE RANGE -0.5 V TO 0.5 V,

                MAX-TIME 5 SEC,

                CNX HI X20-2 LO X20-3                       $

 002300 OUTPUT, C'DC VOLT MEASUREMENT 1 = ', 'MEASURED', C' VDC'  $

C$

 999000 OUTPUT, C'\LF\ATLAS PROGRAM ENDS HERE\LF\'           $

C$

 999999 TERMINATE, ATLAS PROGRAM 'IVI-COM DMM'              $

 

 

 

 


·        This is what it will look like in your Paws Studio:

 

Figure 7

 

·        Now we are ready to add a device database module.

·        Go to File\New Module… Click on DEVICEDB and accept the selection with OK.

 

Figure 8

 

·        Then navigate to File\New File… and choose DEVICE file. Click OK.


·        You will see the following window:

 

Figure 9

 

  • You can now add the file to the project by checking Add to project:.
  • You also need to add the file name dmm to File Name:.

 

Figure 10

 

·        You can now click on OK.


·        You project environment now should look like this:

 

Figure 11

 

·        In the dmm device database file called dmm.ddb, copy the following source code and paste it into it:

 

 

begin dev DMM;

 

      cnx hi DMM-Hi, lo DMM-Lo;

 

      begin FNC = 101; ** DC Voltage Measurement

            sensor(voltage)dc signal;

            control

            {

                  voltage range -300 v to 300 v continuous;

           }

      end; ** DC Voltage Measurement

        

end; *end dmm

 

 

 

Note: To understand the content of this file, please refer to the Paws Studio online help.

 


·        The content of this file will look like this in the Paws Studio:

 

Figure 12

 

 


2.3           Adding the C++ WCEM interface and C++ files to the Paws project:

 

  • At this point you have the basic components for the project in place. You can now build the project by selecting Build\Rebuild All:

 

Figure 13

 

 

  • The next step would be to add the WCEM interface C++ functions invoked by the ATLAS code. Those C++ functions will include the IVI-COM calls to control the instrument. First we will need to add a WCEM project module. Then we will need to create a mapping between the ATLAS and the C++ functions. Finally, we will need to populate those C++ functions with the IVI-COM function calls.

 


  • In order to accomplish that we will take the following action:
    • Go to File\New Module… and click on CEM.
    • Then enter WCEM in Module Name:

 

Figure 14

 

·        You can now click on OK.

 

·        Now, in order to create the mapping between the ATLAS code and the C++ functions, go to View\CEM Wizard… You should see the following images:

 

Figure 15

 

  • In order to create the mapping between the ATLAS code and the C++ function calls, please follow the steps below:
    • This will lead to the following window:

 

Figure 16

 

o       Click on the Advanced tab and you will see the following window:

 

Figure 17

 

o       In order to deal with some of the environmental operations that are needed to connect to the IVI-COM driver, check Load, Unload and Disable CEM Logging check boxes.

 

Figure 18

 

    • You can now click on OK.

o       Back to the previous widow, right click on DMM label and click on Add Interface Function:

 

Figure 19

 

    • This will lead to the following window.

 

Figure 20

 

    • For a series of ATLAS actions, you will need to enter the C++ function name that you wish to invoke. For the Setup Action, please enter DMM_Setup for the User Function Name(s).

 

Figure 21

 

    • Press OK.

 

Note: To obtain more details on how to use CEM Wizard you can refer to the PAWS Studio Help System.

 

    • For Fetch, Init, and Reset, you need to enter the following names: DMM_Fetch, DMM_Init and DMM_Reset.
    • Once you have added the four function names, you can click on OK.
    • This will add several files to your WCEM module:
      • Ctrl.cpp
      • DMM.cpp
      • Error.cpp
      • Wrapper.cpp
      • Key.h

 

    • Ctrl.cpp will include the doOpen and doUnload functions. DMM.cpp will include the four DMM_ functions.
    • The paws project environment should look like this:

 

Figure 22

 

You are also required to add a new *.h file to the project to include some necessary code that we will see later in this tutorial.

In this example we will call this file DMM.h.

    • In order to do this, you will need to right-click on the WCEM module and select Add New File to Module…
    • This will give you the following window:

 

Figure 23

 

o       You need to check Add to project and, select CEM header file and enter DMM in File Name:

 

Figure 24

 

o       You can now press OK.

 


3         Connecting to the IVI-COM instrument driver

3.1           Connecting to the IVI-COM environment:

 

  • You will need to add the following code in your DMM.h file:

 

 

#ifndef __DMM_h__

#define __DMM_h__

 

#include <atlbase.h>

 

#include "Visacom_i.c"

#import "IviDriverTypeLib.dll" named_guids, raw_interfaces_only, raw_native_types no_namespace

#import "IviDmmTypeLib.dll" named_guids, raw_interfaces_only, raw_native_types no_namespace

#import "Agilent34401.dll" named_guids, raw_interfaces_only, raw_native_types no_namespace

 

#endif

 

 

  • Your DMM.h file in your PAWS project will look as follows:

 

Figure 25

 

Note: This header file allows to access to the COM environment, the IVI specific environment and the environment specific to the device, which is in our case an HP34401A instrument.

 

·        Summarizing the effort of adding the WCEM Interface functions you should have the following files generated in your WCEM module:

o       Key.h

o       DMM.h (manually added)

o       Ctlr.cpp with the doUnload() and doOpen() functions

o       DMM.cpp with the DMM_Setup(), DMM_Fetch(), DMM_Init() and DMM_Reset() functions

o       Error.cpp

o       Wrapper.cpp

 


·        The Paws Studio should now look like this:

 

Figure 26

 

·        Let us start with including all the declarations to the ctrl.cpp and DMM.cpp files.

 

·        In ctrl.cpp we need to add the following code:

 

#include "DMM.h"

 

extern CComPtr<IAgilent34401> driver;

extern CComPtr<IAgilent34401DCVoltage> pDMMDCVolt;

extern CComPtr<IAgilent34401Trigger> pDMMTrig;

extern CComPtr<IAgilent34401Measurement> pDMMData;

 

extern HRESULT hr;

 

 

 


  • The code will appear as follows in your Paws project:

 

Figure 27