The following example demonstrates how to calibrating the GX7400 boards using the GXPS driver and C programming language under Windows, to run, enter the following command line:
To run, Enter the following command line:
GxPsExample <PciSlot> <Channel> <sOperation>
Where:
<PciSlot> |
Pci slot number where the board is installed, e.g.: 3 |
<Channel> |
Channel 1 or 2 |
<sOperation> |
specify whether you want to calibrate the channel or to restore the channel's calibration data. |
Sample User Calibration Program Listing
Sample User Calibration Program Listing
/***************************************************************************
FILE : GxPsExampleUserCal.C
PURPOSE : Using the GxPs driver User Calibration functions.
COPYRIGHT: Copyright 2005 GEOTEST Inc.
COMMENTS :
To compile the Windows 32 bit DLL example:
To compile the example:
1. Microsoft VC++
Load GxPsExampleC.dsp, .vcproj or .mak, depends on
the VC++ version from the Project\File/Open... menu
Select Project/Rebuild all from the menu
2. Borland C++ Builder
Load GxPsExampleC.bpr from the Project/Open
Project... menu
Select Project/Build all from the menu
****************************************************************************/
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "GxPs.h"
//**************************************************************************
// DispMsg
//**************************************************************************
void DispMsg(LPSTR lpszMsg)
{
//if windows use MessageBox
MessageBeep(0);
MessageBox(0, lpszMsg,"GxPs", MB_OK);
return;
}
//**************************************************************************
// DispUsage
//**************************************************************************
void DispUsage(void)
{
DispMsg(
"\r\nThis example shows how to use the GxPs"
"GxPs driver User Calibration functions.\r\n"
"Usage:\r\n"
"GxPsExampleUserCal <SlotNumber> <Channel> <sOperation>"
"\r\n\r\nWhere:\r\n"
"<SlotNumber>"
"\t(example : 1)\r\n"
"<Channel> 1 or 2\r\n"
"<sOperation> specify whether you want to calibrate the channel \
or to\r\n"
"restore the channel's calibration data to the factory \
calibration.\r\n"
"Where Command: CALIBRATE=Calibrate Channel, RESTORE=Voltage\r\n"
"\nExample1 calibrating channel 1 using 1 as slot number\r\n"
"GxPsExampleUserCal 1 1 CALIBRATE\r\n"
"\r\nTo change command line under Windows \r\n"
"Select File/Properties from Program Manager \r\n"
"Menu and change the command line edit box as \r\n"
"shown above."
);
exit(1);
}
//**************************************************************************
// CheckStatus
//**************************************************************************
void CheckStatus(SHORT nStatus)
{
CHAR sz[256];
if (!nStatus) return;
GxPsGetErrorString(nStatus, sz, sizeof sz, &nStatus);
DispMsg(sz);
DispMsg("Aborting the program...");
exit(nStatus);
}
//**************************************************************************
// This main function receives four user command line parameters:
// - GxPs board slot number (e.g. 1)
// - Channel# 1 or 2
// - Command CALIBRATE or RESTORE
//**************************************************************************
int main(int argc, char **argv)
{
SHORT nSlotNumber; // Slot number
SHORT nChannel; // Channel number
FLOAT fVoltage=0.0; // Measured voltage
FLOAT fLoad=0.0; // Measured load
SHORT nHandle; // Board handle
SHORT nStatus; // Returned status
char* sOperation; // Board Command Operation
SHORT nStepNum; // Step number
// ** Check number of arguments rcvd
if (argc < 4) DispUsage();
// ** Parse command line parameters
nSlotNumber=(SHORT)strtol(*(++argv), NULL, 0);
nChannel = (SHORT)strtol(*(++argv), NULL, 0);
sOperation = strupr(*(++argv));
// ** Initialize, and retrieve a handle.
GxPsInitialize (nSlotNumber, &nHandle, &nStatus);
CheckStatus(nStatus);
if (!strcmp(sOperation, "CALIBRATE"))
{ / *
The following provides a step-by-step Calibration example program
Initializing the specified Channel for calibration, detects the
specified Channel Module type (unless Fixed type), and pass the
measured load value (in ohms). See the User's Guide for recommended
loads values.
*/
printf("Enter the measured load value in Ohms\n");
scanf( "%f", &fLoad);
GxPsUserCalSetup(nHandle, nChannel, fLoad, NULL, &nStatus);
CheckStatus(nStatus);
for (nStepNum=GXPS_USER_CAL_STEP1; nStepNum<=GXPS_USER_CAL_STEP9;
nStepNum++)
{
// Set the board for Measurement
GxPsUserCalSetupForMeasurement(nHandle, nStepNum, &nStatus);
CheckStatus(nStatus);
printf("Calibration Step number %i, enter the measured voltage \
value\n", nStepNum);
scanf( "%f", &fVoltage);
GxPsUserCalWriteMeasuredVal(nHandle, nStepNum, fVoltage,
&nStatus);
CheckStatus(nStatus);
}
// Store the Channel's Calibration Data to the on-board EEPROM.
GxPsUserCalStoreCalibrationData(nHandle, &nStatus);
CheckStatus(nStatus);
}
else if (!strcmp(sOperation, "RESTORE"))
{
// Restore the specified channel calibration data back to the
// factory calibration.
GxPsUserCalRestoreFactoryCalibration(nHandle, nChannel, &nStatus);
}
else
DispUsage();
return 0;
}
//**************************************************************************
// End Of File
//**************************************************************************