KEPCO KLP Series Developers Guide, Rev 3 User Manual
Page 29

KLP-DEV 041213
3-7
FIGURE 3-1. EXAMPLE OF SETTING THE OUTPUT AND TAKING A MEASUREMENT,
WRITTEN IN C++ (SHEET 2 OF 2)
// open the instrument for communication
hr = driverPtr->Initialize(
L"GPIB0::6::INSTR", //Visa address,(not applicable if simulation=true)
VARIANT_TRUE, // ID query
VARIANT_TRUE, // Reset
LPCTSTR("Cache=true, InterchangeCheck=false, QueryInstrStatus=true, Simulate=false"));
//IVI options
if (FAILED(hr))
exit(1);
// Get InstrumentFirmwareRevision property.
BSTR bstrInstrFwRev;
bstrInstrFwRev = driverPtr->Identity->InstrumentFirmwareRevision;
wprintf(L"InstrumentFirmwareRevision: %s\n", bstrInstrFwRev);
// get pointers to the needed interfaces
IKlpOutputPtr outputPtr;
outputPtr = driverPtr->Outputs->GetItem(OLESTR("Output"));
IKlpMeasurementPtr measurementPtr;
measurementPtr = driverPtr->Measurements->GetItem(OLESTR("Measurement"));
// set voltage
hr = outputPtr->VoltageLevel(75.0);
if (FAILED(hr))
exit(1);
// enable OV protection and set the limit.
hr = protectionPtr->ConfigureOVP(10);
if (FAILED(hr))
exit(1);
// set the current limit
hr = outputPtr->CurrentLimit(10);
if (FAILED(hr))
exit(1);
// enable the output
outputPtr->Enabled = true;
Sleep(500);
// measure the voltage
double measVoltage;
measVoltage = measurementPtr->Measure(KepcoDCPwrMeasurementVoltage);
//print out voltage measurement
printf("measured voltage : %f V \n",measVoltage);
}
catch(_com_error err)
{
printf("%s", err.Description());
}
return 0;
}