Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

"Invalid procedure call or argument" error - after having already worked before. Requires reset to work again.

I am setting up a system using the Keithley 7065 Hall Effect card and am using the Keithley 2400 Sourcemeter, 2000 Multimeter, 6514 Electrometer, and 7001 Switch System. I have a program in VB6 that is attempting to measure the resistivity of a sample by measuring voltages and currents. The program works successfully (it measures the resistivity), but if I try to run it again (even after exiting the program), it returns an error "Run-time error '5': Invalid procedure call or argument"

The line it is crashing on is
current = 5 * (1 / Sqr(200 * ur))

I don't understand why it works and then doesn't. Sometimes (but rarely) if I keep trying to run it again it works without that error. Most of the time, though, I have to restart the computer before it works again.

This code is being written in VB6. I had to communicate with the instruments using device-level code (e.g., ibrd, ibwrt).

Below is the subroutine with the line that causes the error:

Private Sub testCurrent()
Dim current, ur, uvolt, ucurr, sumr, sumvolt, sumcurr As Double

Dim meas_volt As String
Dim meas_curr As String
numaverages = 25
Dim data() As Double

'using a test current of 1 milliampere to determine cross point resistance for power consumption limitation
Call send(sm, ":SOUR:CURR:LEV " + Str(0.001), status)
Call send(sm, ":SENS:FUNC 'CURR'", status)
Call send(sm, ":FORM:ELEM CURR", status)


'apply current to I13 and measure V13 determine R
Call send(ss, ":CLOS (@" + getCrossPointsInit + ")", status)
Call send(sm, ":OUTP:STAT ON", status)

ReDim data(2, numaverages)

For I = 0 To UBound(data, 2)
DoEvents
Call send(mm, ":MEAS:VOLT?", status)
Call GetReply(meas_volt, CInt(255), CInt(1), mm, status)
Call send(sm, ":MEAS:CURR?", status)
Call GetReply(meas_curr, CInt(255), CInt(1), sm, status)
DoEvents
data(0, I) = val(meas_volt)
data(1, I) = val(meas_curr)
data(2, I) = data(0, I) / data(1, I)
Next I

Call send(sm, ":OUTP:STAT OFF", status)
Call send(ss, ":OPEN ALL", status)

sumvolt = 0: sumcurr = 0: sumr = 0

For I = 0 To UBound(data, 2)
sumvolt = sumvolt + data(0, I)
sumcurr = sumcurr + data(1, I)
sumr = sumr + data(2, I)
Next I

'calculate average mu (u)

uvolt = sumvolt / (numaverages)
ucurr = sumcurr / (numaverages)
ur = sumr / (numsamples + 1)


current = 5 * (1 / Sqr(200 * ur)) 'Power dissipated should be less than 5 mw. ERROR HERE

Call send(sm, ":SOUR:CURR:LEV " + Str(current), status)
End Sub
0 Kudos
Message 1 of 3
(10,098 Views)
Here are the subroutines I use to communicate with the instrument:
---------------beginning of code-----------
Public Sub GetReply(r As String, Maxlen As Integer, l As Integer, addr As Integer, status As Integer)
Dim stl As Long
Dim ll As Long
Dim myStr As String * 1024
r = ilrd(addr, myStr$, Len(myStr$))
l = ll
r = myStr
status = stl
End Sub

Sub send(addr As Integer, myCom As String, mtStat As Integer)
Call ilwrt(addr, myCom, Len(myCom))
End Sub

Private Sub MDIForm_Load()
mma = 16
ssa = 7
sma = 24
ema = 14
gba = 21
sm = ConvertLongToInt(ibdev32(0, sma, 0, 13, 1, 0))
mm = ConvertLongToInt(ibdev32(0, mma, 0, 13, 1, 0))
em = ConvertLongToInt(ibdev32(0, ema, 0, 13, 1, 0))
gb = ConvertLongToInt(ibdev32(0, g
ba, 0, 13, 1, 0))
ss = ConvertLongToInt(ibdev32(0, ssa, 0, 13, 1, 0))

addToLog "Welcome to the Vander Pauw Resistivity/ Hall Effect Measurent system."
addToLog "Please choose a menu option to get started:"

LoadSettings
End Sub

---------------end of code-----------
btw, how do you edit posts?
0 Kudos
Message 2 of 3
(10,098 Views)
Hi Kirin,
What is the value for ur in the expression current = 5 * (1 / Sqr(200 * ur)) ?
In VB you can sometimes get this error ,if a mathematical expression cannot be calculated, because it has invalid values...
for example
dNumber = 0
dResult = Log(dNumber)
will give you the same error, since log of 0 is undefined...
If you could do a debug print before you calculate current, that may help...
Nandan Dharwadker
Staff Software Engineer
Measurement Studio Hardware Team
0 Kudos
Message 3 of 3
(10,098 Views)