AnsweredAssumed Answered

66332A VB6 .enter command takes too long

Question asked by Chris_tx on Aug 30, 2011
Latest reply on Sep 7, 2011 by MattC
When assigning Fetch Array data to an array variable the enter command is taking a huge amount of time.  I am pulling 1000 readings from the buffer and it is taking 9 seconds to assign the values.

When I take 4,000 readings it takes 19 seconds.

I have to take 60 seconds of data at 1msec intervals and save it to a file.  The buffer will only hold 4096 readings, so I have to create a loop and keep re-reading the buffer, but losing 19 seconds between each loop is killing me. 

Option Explicit
Private Sub cmdError_Click()
    Agt3494A1.Connect Me.txtAddress.Text
    InstrumentError Agt3494A1
End Sub

Private Sub cmdGetPulse_Click()
    Dim strDatFileName As String
    Dim strBackSlash As String
    Dim intDatFileNbr As Integer
    Dim strDatName As String
    Dim intDeptNbr As Integer
    Dim currentArray(999) As Double '0 to 4095 is 4096 points
    Dim Data() As Variant
    Dim i As Long
    Dim cnt As Long
    Dim d As Long
    Dim iter As Integer
    Dim startTime As String

    strBackSlash = IIf(Right$(App.Path, 1) = "\", "", "\")
    strDatFileName = App.Path & strBackSlash & "POWERUP.dat"
    intDatFileNbr = FreeFile
    cnt = 1
    d = 0
    iter = 0
    cmdGetPulse.Enabled = False
    Agt3494A1.Connect Me.txtAddress.Text
    If isconnected(Agt3494A1) = False Then Exit Sub
' If the file we want to open for output already exists, delete it ...
    If Dir$(strDatFileName) <> "" Then
        Kill strDatFileName
    End If
    Open strDatFileName For Append As #intDatFileNbr

    setupDCSource Agt3494A1
    With Agt3494A1
        .Output "Output  On"
        .Output "Volt 4.2"         ' Set output to 4.2 volts  For some reason this is set in the Module then reset here?
        .timeOut = 50000           ' set timout to 50 sec
        .Output "init:Name ACQ"
        .Output "Fetch:Array:curr?"
        .Enter currentArray
        ReDim Data(UBound(currentArray) + 1)
            For i = 1 To UBound(currentArray) + 1
               Data(d) = currentArray(i - 1)
               Write #intDatFileNbr, cnt, d, Data(d), Time
               d = d + 1
            Next i
    End With
    With Agt3494A1
        cnt = cnt + 1
        Do Until cnt > iter
        startTime = Time
            .Output "Sense:Current:Det ACDC"         ' Set meter to ACDC
            .Output "Sense:Current:Range Max"           ' High current range
            .Output "Sense:Func ""Curr"""              ' Acquire current reading"
            .Output "Sense:SWE:Tint .001"            ' Sample time interval to 1ms"
            .Output "Sense:SWE:Points 1000"             ' Number of measurement samples in sweep"
            .Output "Sense:SWE:Offset:Points 0"      ' Number sample points before trigger"
            .Output "Measure:Array:curr?"
             startTime = Time
            .Enter currentArray
                ReDim Data((UBound(currentArray) + 1) * iter)
                    For i = 1 To UBound(currentArray) + 1
                        Data(d) = currentArray(i - 1)
                        Write #intDatFileNbr, cnt, d, Data(d), Time
                        d = d + 1
                    Next i
                cnt = cnt + 1
            .Output "Volt 0"          ' Set output to 0 volts
            .Output "Output  Off"
            Close #intDatFileNbr
    End With

    cmdGetPulse.Enabled = True
End Sub