Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Acquiring scaled values NI-DAQmx VB

I'm trying to find out how to get the scaled data values using VB.
DAQmxReadAnalogScalarF64 appears to only work for a single channel value.
 
What I want to do is use my task, created in MAX, which holds 121 channels and get the scaled values for each channel.
 
Any clues ?
 
TIA
0 Kudos
Message 1 of 3
(7,098 Views)
Hello,

   The DAQmx ReadAnalogScalarF64 will only read a single value as it only contains the read floating point 64 bit parameter. This means that the function can only read and store one value at a time.

     The function you will need to use to read multiple samples is
DAQmxReadAnalogF64. This contains the floating point read array parameter to allow you to read multiple samples and store them in an array.

Let me know how you get on with this.

LeeM
NIUK

0 Kudos
Message 2 of 3
(7,078 Views)

Thanks for that.

I'm now using the correct function call but data retrieval is very slow - taking 0.45 seconds to get the data for a task holding 121 channels.

Here's my code, any ideas?

 

Private Sub tmrSample_Timer()
   
    Dim sampsPerChanRead As Long
    Dim numBytesPerSample As Long
    Dim arraySizeInBytes As Long
    Dim i As Integer
   
    On Error GoTo ErrorHandler
   
    If Not taskIsRunning Then
        Exit Sub
    End If
   
    NumSamps = NumSamps + 1
   
    DAQmxErrChk DAQmxReadAnalogF64(taskHandleAI, numSampsPerChannel, 10#, _
                    fillMode, data(0), arraySizeInSamps, sampsPerChanRead, ByVal 0&)
   
   
    DAQmxErrChk DAQmxReadDigitalLines(taskHandleDI, 1, 10#, _
        DAQmx_Val_GroupByChannel, arrayDI(0), numDI, _
        sampsPerChanRead, numBytesPerSample, ByVal 0&)

   
    'Populate the listView
    PopulateListView numChannels, fillMode, sampsPerChanRead
    
    For i = 1 To lvDI.ListItems.count
        If i < UBound(arrayDI) Then
            lvDI.ListItems(i).SubItems(1) = IIf(arrayDI(i) <> 0, "ON", "OFF")
        End If
    Next
   
    lblPerformance.Caption = perf.ElapsedTime
Exit Sub
   
ErrorHandler:
   
    tmrSample.Enabled = False
    acquiringLabel.Visible = False
    startCommandButton.Enabled = False
    StopCommandButton.Enabled = False
   
    MsgBox "Error: " & Err.Number & " " & Err.Description, , "Error"
End Sub

 

Thanks,

Snelly

0 Kudos
Message 3 of 3
(7,045 Views)