3 setting virtual model, Setting virtual model -18, Setting virtual model, written in visual basic -18 – KEPCO KLP Series Developers Guide, Rev 3 User Manual
Page 40

3-18
KLP-DEV 041213
3.4.3
SETTING VIRTUAL MODEL
The filename for this example is VBvirtual model Example.txt, located in the ivi\driv-
ers\kepco\examples folder (see Figure 3-5 for complete code). This example is very similar to
the other examples in this section. The difference is that functions in the driver are used to per-
form the operation instead of setting the value to a specific state. Access to the functions is
identical to the method used to access the open and close of the driver. The functions used are:
KpDCPwr_EnablePasswordState to send the string to the unit to enable the ability to set the vir-
tual model.
KpDCPwr_SetAttributeViReal64 which sets the various attributes to a specific value.
FIGURE 3-5. SETTING VIRTUAL MODEL, WRITTEN IN VISUAL BASIC
'/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This program demonstrates how to set the virtual model
' using the IVI-COM driver.
'/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Option Explicit
Public driver As KepcoDCPwr
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdStart_Click()
 
 Set driver = New KepcoDCPwr
 
 On Error GoTo ErrorHandler
 
 
 ' initialize the driver - note ID device is true
 driver.Initialize "GPIB0::6::INSTR", _
 True, _
 True, _
 "Cache=true,InterchangeCheck=false,QueryInstrStatus=true,Simu-
late=false"
 
 Dim result As Boolean
 result = driver.Initialized
' to set the password enable state we have to send a password.
' remember the password is different for all kepco models and can be changed by he user from the
front panel or other interfaces
driver.KpDCPwr_EnablePasswordState "7533"
' This will now set the virtual model to a 36-33 unit.
driver.KpDCPwr_SetAttributeViReal64 KPDCPWR_ATTR_POSITIVE_VOLTAGE_RATED_LIMIT, 36
driver.KpDCPwr_SetAttributeViReal64 KPDCPWR_ATTR_POSITIVE_CURRENT_RATED_LIMIT, 33
 
 driver.Close
 
 StatusTextBox.Text = StatusTextBox.Text & "Driver closed." & vbCrLf
 StatusTextBox.Refresh
Exit Sub
ErrorHandler:
 MsgBox Err.Description
 driver.Close
 Exit Sub
End Sub
' Wait the specified number of seconds
Private Sub Delay(DelayTime As Single)
 Dim Finish As Single
 Finish = Timer() + DelayTime
 Do
 Loop Until Finish <= Timer()
End Sub
