Quantcast
Channel: Measurement Studio for .NET Languages topics
Viewing all articles
Browse latest Browse all 1999

Data acquisition in real time

$
0
0

Hello,

 

I'm trying to read a NI9213 in real time. I can read some value but I have an issue.

 

My code is :

myTask = DaqSystem.Local.LoadTask("TaskNIMAX")

'Verify the Task

myTask.Control(TaskAction.Verify)

analogInReader = NewAnalogMultiChannelReader(myTask.Stream)

' Use SynchronizeCallbacks to specify that the object

' marshals callbacks across threads appropriately.

analogInReader.SynchronizeCallbacks = True

analogInReader.BeginReadWaveform(1, myAsyncCallback, myTask)

 

PrivateSub AnalogInCallback(ByVal ar AsIAsyncResult)

Try

If (Not (runningTask IsNothing)) AndAlso runningTask Is ar.AsyncState Then

data = analogInReader.EndReadWaveform(ar)

analogInReader.BeginMemoryOptimizedReadWaveform(1, myAsyncCallback, myTask, data)

Debug.Print((data(0).Samples(0).Value).ToString)

EndIf

Catch exception AsDaqException

MessageBox.Show(exception.Message)

myTask.Dispose()

EndTry

EndSub

 

The task is configure with continuous sampling (1 sample at 500 Hz). You can see the value read on the file debug.txt.

My question is why I have many time the same value ? What is wrong in my code ?

Thanks

 


Viewing all articles
Browse latest Browse all 1999

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>