3 setting limit model, Setting limit model -11 – KEPCO KLR Series Developers Guide User Manual
Page 33

KLR-DEV 060713
3-11
3.3.3
SETTING LIMIT MODEL
This example is a series of files found on the CD in the
ivi\drivers\kepcodcpwr\example\cviVirtual directory.
In CVI you just need to open the .prj file to access the entire project
Note:
This project file establishes a link to the kepcodcpwr.fp file by using the Edit menu ->
project -> Function panel file. To create another project this step is critical to proper
operation of the driver under the CVI environment.
In CVI each C file in the project needs to invoke the various include files.
#include "KpDCPwr.h"
#include
#include
#include
#include "KpDCPwrErrorHandler.h"
#include "KpDCPwrExample.h"
The CVI environment is aware of the IVI directory structure and will automatically locate the
directories containing the files without adding any path statements. It is an advantage of using
CVI over other C environments as it is IVI aware.
When the resource string is entered and the user clicks the appropriate button, the driver is
invoked and the password is established with the following code.
sprintf(initOptions, "QueryInstrStatus=1, Simulate=%d", simulate);
// Initialize the driver
checkErr(KpDCPwr_InitWithOptions(resourceName, VI_TRUE, VI_TRUE,
initOptions, &vi));
// Enable the password state
checkErr(KpDCPwr_EnablePasswordState(vi, “7532”));
The user is then provided another form. When the data is entered, the standard CVI logic is
invoked and the variables are read from the form, then sent to the KLR.
The setting the KLR’s voltage is performed by two lines of code. The first line is the standard
CVI method of getting a variable from the form and the second line is the function in the IVI
driver that sets an attribute to a specific value.
// Get the desired voltage limit from the UI
GetCtrlVal(panelHandle, PANEL_VOLTAGE_LIMIT, &voltageLimit);
// Set the voltage limit
checkErr(KpDCPwr_SetAttributeViReal64(vi, VI_NULL,
KPDCPWR_ATTR_POSITIVE_VOLTAGE_RATED_LIMIT, voltageLimit));
The setting of a maximum current level for the limit model is performed using the same two
functions but the attribute is changed on the set function.
// Get the desired current limit from the UI
GetCtrlVal(panelHandle, PANEL_CURRENT_LIMIT, ¤tLimit);
// Set the current limit
checkErr(KpDCPwr_SetAttributeViReal64(vi, VI_NULL, //