I am having a problem acquiring data from a 6036 card from VB.NET.
I am using some digital lines to make some LEDs flash, and am reading values
in from various channels. I am not overlapping writes to the digital lines
with reads from the analogue channels as far as I am aware- they are
consecutive and in the same thread.
Relevant code from the bottom level is below.
The code works fine for a few tens of measurements and then hangs at the
"Stop" following the "Read". The Read does appear to complete- the hang is
inside the "Stop" function. If I replace "Stop" with "Reset" I get identical
behaviour, except now the hang is inside "Reset". If I remove the "Stop"
entirely and leave the card running until the next measurement, again I
eventually get a hang but this time inside the first "Reset". If I remove
that "Reset", the hang occurs inside the "Configure"
I'm now at a loss as to what to do next and how to fix this.
------
The following is how I do each reading.
Public Function AI_Measure(Optional ByVal samples As Long = 20000) As Single
' Reads n samples from the active channel and returns
' the average value.
Dim retArray() As Single
Dim sumArray As Single
Static numcall As Long
numcall += 1
'Debug.WriteLine("AI Call " & numcall)
With ni_AI
.Reset()
.NScans = samples
.Configure()
.Start()
.Read(samples, retArray)
.Stop()
End With
sumArray = CWArray.SumArray(retArray)
Return sumArray / samples
End Function
----------------------
The following is how I am setting channels up.
Public Sub AI_SetChannel(ByVal Values() As AnalogueInputChannel)
' Sets an array of multiple channel
Dim i As Long, j As Long
ni_AI.Channels.RemoveAll()
If Values Is Nothing Then Exit Sub
i = UBound(Values)
ReDim intAIChannel(i)
ni_AI.ScanClock.Frequency = 100000 / i
For j = 0 To i
AI_AddChannel(Values(j))
intAIChannel(j) = Values(j)
Next
End Sub
Private Sub AI_AddChannel(ByVal value As AnalogueInputChannel)
' Adds a single channel to the analogue input channel list
Select Case value
Case AnalogueInputChannel.AI_BondCurrent
ni_AI.Channels.Add("1")
Case AnalogueInputChannel.AI_BondVolts
ni_AI.Channels.Add("0")
Case AnalogueInputChannel.AI_ProbeADetect
ni_AI.Channels.Add("2")
Case AnalogueInputChannel.AI_ProbeBDetect
ni_AI.Channels.Add("3")
Case AnalogueInputChannel.AI_TestAccept
ni_AI.Channels.Add("4")
End Select
End Sub
--
Dr. Craig Graham, Software Engineer
Advanced Analysis and Integration Limited, UK. http://www.aail.co.uk/