Is there a document that describes the sample order when transferring data from the Windows buffer to an array?
My VB6 application appears to work correctly when using a single channel. However, when I select two channels, I do not know the sample alignment in the VB array.
Private Sub cmd_StartBgnd_Click()
'NOTE: Must call MCCReset prior to starting measurements
Dim CBCount As Long
Dim Options As Long
Dim CurCount As Long, CurIndex As Long
Dim Status As Integer
Dim Offset As Long
Dim i As Integer
Dim EngUnits As Single
Dim indexMem As Integer
Dim sTemp As String
CBCount = TotalPoints 'samples collected per channel is equal to CBCount / (HighChan – LowChan + 1).
'collect data in BACKGROUND continuously
Options = BACKGROUND + CONTINUOUS + CONVERTDATA '+ SCALEDATA
ULStat = cbAInScan(MCC.BoardNum, LowChan, HighChan, CBCount, CBRate, CBRange, MemHandle, Options)
If ULStat <> 0 Then Stop
bRun = True
indexMem = 0
Offset = 0 'CurIndex start of latest channel scan in MemHandle buffer
Do
ULStat = cbGetStatus(MCC.BoardNum, Status, CurCount, CurIndex, AIFUNCTION)
If ULStat <> 0 Then Exit Do
'curindex increments by PacketSize (64 samples)
If ((CurIndex > HighChan) And (CurIndex <> indexMem)) Then
indexMem = CurIndex
'transfer samples from the buffer to the array starting with offset in the buffer
ULStat = cbWinBufToArray(MemHandle&, ADData(Offset), Offset, PacketSize)
If ULStat <> 0 Then Exit Do
'update textbox for diagnostic purposes
Select Case Offset
Case 0
sTemp = "" 'clear the text
End Select
sTemp = sTemp & "Index: " & CurIndex & " Offset: " & Offset & vbCrLf
sTemp = sTemp & "Start: " & Offset & " Stop: " & Offset + (PacketSize - 1) & vbCrLf
For i = Offset To (Offset + PacketSize - 4) Step 4
sTemp = sTemp & i & " " & ADData(i) & " " & ADData(i + 1) & " " & ADData(i + 2) & " " & ADData(i + 3) & vbCrLf
Next i
Me.txt_ScanData(0).Text = sTemp
sTemp = sTemp & vbCrLf
'keep track of the pointer
Offset = Offset + PacketSize
If Offset > (TotalPoints - 1) Then Offset = 0
End If
DoEvents
If (Not bRun) And (Offset = 0) Then Exit Do 'exit polling loop if stop button pressed and all packets reported
Loop
ULStat = cbStopBackground(MCC.BoardNum, AIFUNCTION) 'stop the measurement
Question
TekLord
Is there a document that describes the sample order when transferring data from the Windows buffer to an array?
My VB6 application appears to work correctly when using a single channel. However, when I select two channels, I do not know the sample alignment in the VB array.
Private Sub cmd_StartBgnd_Click()
'NOTE: Must call MCCReset prior to starting measurements
Dim CBCount As Long
Dim Options As Long
Dim CurCount As Long, CurIndex As Long
Dim Status As Integer
Dim Offset As Long
Dim i As Integer
Dim EngUnits As Single
Dim indexMem As Integer
Dim sTemp As String
Me.cmd_StartBgnd.Enabled = False
Me.cmd_StartBgnd.Visible = False
Me.cmd_StopConvert.Enabled = True
Me.cmd_StopConvert.Visible = True
Me.lbl_ShowStat.Caption = "Running"
CBCount = TotalPoints 'samples collected per channel is equal to CBCount / (HighChan – LowChan + 1).
'collect data in BACKGROUND continuously
Options = BACKGROUND + CONTINUOUS + CONVERTDATA '+ SCALEDATA
ULStat = cbAInScan(MCC.BoardNum, LowChan, HighChan, CBCount, CBRate, CBRange, MemHandle, Options)
If ULStat <> 0 Then Stop
bRun = True
indexMem = 0
Offset = 0 'CurIndex start of latest channel scan in MemHandle buffer
Do
ULStat = cbGetStatus(MCC.BoardNum, Status, CurCount, CurIndex, AIFUNCTION)
If ULStat <> 0 Then Exit Do
'curindex increments by PacketSize (64 samples)
If ((CurIndex > HighChan) And (CurIndex <> indexMem)) Then
indexMem = CurIndex
'transfer samples from the buffer to the array starting with offset in the buffer
ULStat = cbWinBufToArray(MemHandle&, ADData(Offset), Offset, PacketSize)
If ULStat <> 0 Then Exit Do
'update textbox for diagnostic purposes
Select Case Offset
Case 0
sTemp = "" 'clear the text
End Select
sTemp = sTemp & "Index: " & CurIndex & " Offset: " & Offset & vbCrLf
sTemp = sTemp & "Start: " & Offset & " Stop: " & Offset + (PacketSize - 1) & vbCrLf
For i = Offset To (Offset + PacketSize - 4) Step 4
sTemp = sTemp & i & " " & ADData(i) & " " & ADData(i + 1) & " " & ADData(i + 2) & " " & ADData(i + 3) & vbCrLf
Next i
Me.txt_ScanData(0).Text = sTemp
sTemp = sTemp & vbCrLf
'keep track of the pointer
Offset = Offset + PacketSize
If Offset > (TotalPoints - 1) Then Offset = 0
End If
DoEvents
If (Not bRun) And (Offset = 0) Then Exit Do 'exit polling loop if stop button pressed and all packets reported
Loop
ULStat = cbStopBackground(MCC.BoardNum, AIFUNCTION) 'stop the measurement
If ULStat <> 0 Then Stop
End Sub
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now