ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

ReadSingleSampleSingleLine execution speed

It seems so straight forward and yet I can't figure out why the last statement in this example is taking over 100 ms to execute.  The first 4 statements execute in under 5 ms.  If I put a loop around the value statement and execute is 10 times, it still takes around 70 ms each.  Any suggestions on how to do a single digital input on a single channel faster?

 

Address = "NIDigitalIOMod1/Port0/Line0"
digitalReadTask = New Task
digitalReadTask.DIChannels.CreateChannel(Address, "DigRead", ChannelLineGrouping.OneChannelForEachLine)
Dim Reader As New DigitalSingleChannelReader(digitalReadTask.Stream)
value = Not Reader.ReadSingleSampleSingleLine()

0 Kudos
Message 1 of 2
(1,413 Views)

Theoretically speaking, any type of hardware interface that does a "ReadSingleSample" isn't meant for iterative speeds. In my opinion 70ms is pretty fast for a Single read on a Digital Input.

 

If you want speed, then change your TaskThread and Channel Type to handle Continuous reading and use a Callback, and then when you want the data (probably in some other thread), then you'll need to fetch it from wherever you collect data to (according to your Callback's design). I recommend looking at some of NI's Continuous Read examples. 

0 Kudos
Message 2 of 2
(1,286 Views)