Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQ problem

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/
0 Kudos
Message 1 of 2
(3,337 Views)

Hello

If you are going to using the E-series device alot in .NET, I would suggest using the DAQmx .NET api that provides you with native .NET functions . So you will no longer have to use an activex wrapper for doing DAQ. The api is available with NI-DAQ 7.0. This only works with .NET 2003 though. But its really simple to use with an E-series devices.

It seems that you have a finite aquisition setup. This this case, you dont need to call a stop after the read.

You also might want to set the acquired data enabled property to false. Refer to the CWDAQ documentation for more information about these functions.

I hope this helps

Bilal Durrani

NI

Bilal Durrani
NI
0 Kudos
Message 2 of 2
(3,337 Views)