|
TYX Corporation Productivity Enhancement Systems
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 requirementsIn 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
Figure 2
Figure 3
2.2 Adding Paws Files to the project
Figure 4
Figure 5
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
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:
Figure 13
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
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
o Back to the previous widow, right click on DMM label and click on Add Interface Function:
Figure 19
Figure 20
Figure 21
Note: To obtain more details on how to use CEM Wizard you
can refer to the PAWS Studio Help System.
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.
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 driver3.1 Connecting to the IVI-COM environment:
#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
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;
Figure 27 |