Pages 1 | 2 | 3
Integrating VXI Plug&Play Drivers with PAWS
Adding Virtual Panels to the WCEM
One of the features of plug&play you may want to take advantage of is a soft panel. This allows you to have a virtual instrument display on the display of your computer showing the current state and/or measurement for an instrument. All plug&play drivers are delivered with a softpanel executable, however this file is not suited to integration with the WCEM. The manufacturer supplied executable is normally a very complex set of panels that controls all the features of an instrument, when what you need to use with the PAWS Run-Time System is indicators. If a soft panel is processing interrupts then the RTS will be in a wait state. So this example will demonstrate the development and integration of an indicator panel for the HPE1412 DMM.
This example will show the use of LabWindowsâ
/CVI to develop the soft panel, and will create a DLL that displays the function panel and provides an interface to update the display.
Softpanels are accessed in PAWS by creating ‘dummy’ instruments in the device database. Using the WCEM Wizard you will create a setup function for the dummy instrument. In the device database You will write a macro that executes a ‘setdevice()’ command for the dummy instrument, and then sends a CIIL string over the GPIB bus. Because the instrument is controlled by WCEM, the RTS will then execute the setup function for the dummy instrument. This setup function will activate the soft panel, and then other functions in the driver can update the panel.
Creating the Soft Panel DLL
For the purposes of this application note it is assumed that the engineer has some experience with LabWindowsâ
/CVI and can create function panels and DLL’s. This example will only present a brief overview of the process.
When you create the soft panel you don’t need to create an exit button as the panel will never be processing interrupts. The panel will be displayed with a call to InitUIForDLL(), and will be removed with the call to DiscardUIObjectsForDLL()when the DLLMain is called for ProcessDetach.
For this indicator three functions were created; hpe1412DispPanel() which calls InitUIForDLL() and displays the panel, hpe1412SetMode() which updates the mode ring control on the panel, and hpe1412DisplayMval() which displays the measured value.
The soft panel that was created for this example is very simple, as shown in figure15.
There are no callbacks associated with this panel. It’s sole purpose is to display the current mode and measured value of the DMM. You can create a panel to suit exactly what your needs are. You may opt for a small indicator only showing the measured value, or you may decide that you need a more complex panel that shows more information about the DMM.
The ‘C’ code generated by CVI, plus the functions added to control the panel take up only about 70 lines. In addition to the default code generated by the UIR editor, the following functions were added.
void hpe1412DispPanel()
{
InitUIForDLL();
}
void hpe1412SetMode(int mode)
{
SetCtrlVal (panelHandle, PANEL_DMM_MODE, mode);
}
void hpe1412DisplayMval(double val)
{
SetCtrlVal (panelHandle, PANEL_MEASUREMENT, val);
}
The following header file was created for the DLL and needs to be included in your ‘C’ file were the soft panel will be controlled:
#define ACV 0
#define DCV 1
#define OHM2 2
#define OHM4 3
#define ACA 4
#define DCA 5
void hpe1412SetMode(int mode);
void hpe1412DisplayMval(double val);
void hpe1412DispPanel(void);
In addition you will also need to include the export library for the DLL functions, hpe1412vpanel.lib, in the WCEM options window.
Setting up the Device Database for Calling Soft Panels
The Device Database is the starting point on the PAWS side when adding a soft panel. A dummy device for the soft panel needs to be added, plus a macro that will be called from the ATLAS program to activate the soft panel. If you want the soft panel loaded automatically, then you can skip this section and add a call to InitUIForDll() in the PROCESS_ATTACH section of the DLLMain(). This will automatically start the panel when the DLL is loaded.
In the Device Database, as a macro is needed to start the soft panel, you will need to include the Built In Function list. The code required to start a soft panel is:
def, mac, StartDmmPanel();
{
Dsp("StartVI..\n");
setdevice(<DMMPANEL>);
Talk("FNC DCS VOLT :CH53\r\n");
}
begin DEV DMMPANEL;
source dc signal;
control voltage -999.0 v;
end;
The macro StartDmmPanel() will be called to display the soft panel if the user wants to see the DMM status and measured values. The macro setdevice(<DMMPANEL>); sets the current device to our dummy instrument. The Talk() statement tries to send the CIIL string "FNC DCS VOLT :CH53\r\" to the DMMPANEL. Because the dummy instrument is controlled by the WCEM as defined in the BusConfi file (discussed later), the RTS makes a call to the setup function for DMMPANEL.
The static description describes a source for dc signal, but this is just to keep the compiler happy. The statement "control voltage –999.0 v" guarantees that no signals will be allocated to this device.
After entering this code into the Device Database, run the build process. After the Device Database compiles run the WCEM Wizard and create a setup function for the dummy instrument DMMPANEL. This is the only function required. In the ‘C’ file that is created, DMMPANEL.C, the only call you need to make in the setup function is to the hpe1412DispPanel() function. I addition you can create a function that returns TRUE if the panel is active.
//DMMPANEL.C
#include "cem.h"
#include "key.h"
#include "hpe1412vpanel.h"
static unsigned short DMM_PANEL_STATE = 0;
//BEGIN{DFW}:DMMPANEL:0:0
int doDMMDisplayPanel (double VOLT)
//END{DFW}
{
hpe1412DispPanel();
DMM_PANEL_STATE = 1;
return (int) 0;
}
unsigned short IsDmmPanelActive()
{
return DMM_PANEL_STATE;
}
In the file DMM.C any function that would update the soft panel, it can first call the function IsDmmPanelActive() which returns non-zero if the panel is active. If the panel is active they can then call one of the two functions to update the mode or the measured value. Don’t forget to add the prototype for this function to a header file or add the line:
extern unsigned short IsDmmPanelActive(void);
to the file DMM.C.
ATLAS Code to activate a Soft Panel
In the ATLAS program all we have to do is write a DEFINE statement for the macro to activate the soft panel, and then write a PERFORM statement if the operator wants to view the panel.
.
.
010000 DEFINE, MACRO, ‘StartDmmPanel’ $
99 END, ‘StartDmmPanel’ $
.
.
101000 OUTPUT, C’DO YOU WANT DMM SOFT PANEL DISPLAYED?’,
C’ENTER YES/NO ‘ $
05 INPUT, GO-NOGO $
10 IF, GO, THEN $
- PERFORM, ‘StartDmmPanel’ $
20 END, IF $
.
.
The DEFINE, MACRO… statement is a PAWS extension to the ATLAS language which allows you to call Device Database macros from the ATLAS code. When using this feature remember the macro name is case sensitive, and must be referenced exactly as it was defined.
Adding WCEM Devices to the BusConfi File
The PAWS Bus Configuration file, BusConfi, identifies all the instruments in the ATE, and identifies which bus they are on, plus the talk and listen addresses for each device. All instruments that are controlled by the WCEM will be assigned to a bus called "Channel".
; IEEE-488 Bus Configuration File -
"IEEE-488 Bus" 1 MLA 30 MTA 30 gpib0
"Channel" 2 MLA 50 MTA 50
DCP BUS 1 MLA 1 MTA 1
ACP BUS 1 MLA 2 MTA 2
AFG BUS 1 MLA 4 MTA 4
DWG BUS 1 MLA 10 MTA 10
DMM BUS 2 MLA 24 MTA 24
DMMPANEL BUS 2 MLA 99 MTA 99
This example has two busses, "IEEE-488 Bus" and the "Channel". The GPIB controller is gpib0 at address 30, and the WCEM is shown with address 50. The instruments DMM and DMMPANEL are shown on BUS 2, which is the WCEM process controller. Add all your WCEM instruments under the "Channel" controller. This tells the RTS that the instrument functions are controlled by WCEM. Remember that the name in BusConfi must be exactly as define in the Device Database.
Building the WCEM
After implementing all the functions in your WCEM interface C files you are ready to build the WCEM.DLL.
Before you can build the WCEM you need to have an ATLAS program in the PAWS project, a switch database, and an ITA database (you already have a device database or you couldn’t created the WCEM files).
You can compile each of the ‘C’ files individually to verify they are syntactically correct. To compile a ‘C’ file, double click on the file in the PAWS project workspace. This will open an edit window with the ‘C’ file. Click on the compile button and the PAWS Developer’s Studio will invoke Microsoft Visual C++ and post the compile results to the error window of the PAWS Studio.
When you click on the ‘Build Project’ all files that are not current will be built in the following order:
Compile, Link, and Flow the ATLAS program
Build the Device Database
Build the Switch Database
Build the ITA Database
Resource Allocate the ATLAS program
Compile all CEM source files
Link CEM files and build WCEM.DLL, WCEM.LIB, and WCEM.EXP
If there are errors in any of the ‘C’ files, or unresolved symbols in the link process the errors will show up in the error window of the PAWS Developers Studio. If you encounter errors in your source code correct them and rebuild the project. If you get ‘file not found’ errors it indicates that Visual C++ can’t find a header file or library file. This means you will have to add a directory to the ‘Include Path’ or ‘Library Path’ fields of the WCEM setup.
A successful build of the WCEM will yield an error report as seen in figure 15.
Once the WCEM has built correctly the only errors you may encounter are run-time errors involving instrument status, bugs in your code, or addressing problems. If you ran the virtual instrument panel executable you would have verified the functionality of the plug&play functions and the device addressing.
Proper evaluation of the return values from the plug&play functions, use of the SetFault() macro to assert interrupts in the Device Database, and logging of errors through the functions in Error.c will allow you trap most of the run-time errors that can occur when using a WCEM. Write a comprehensive ATLAS test program that will exercise all of your driver functions and you will be able to trap the majority of problems in the integration phase.
For more on VXI plug&play…
For more information on VXI plug&play drivers you can try the VXI plug&play consortium website at www.vxipnp.org. All of the specification documents are downloadable as MS Word documents or Adobe Acrobat .PDF files. You can also find tutorials and papers on VXI issues.
|