From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Simple, buffered, samples acquisition with NI9234

Solved!
Go to solution

Hi all.

 

I'm trying to read data from a NI9234 hosted inside a cDAQ9174, but this is not my usual working context so I'm having an hard time doing exactly what I want/need.I'm developing the applications with Visual Studio and C#, I've got the driver installed, and generally speaking I'm already able to interact with the hardware and acquire some data.

 

Now, basically what I want is to the command the hardware to start reading samples at a given frequency, and then from the software I'll just ask for the last N samples acquired. I don't want to wait for it to read them, I want to get already acquired data, and if they are not or they are less than N just give me what it has (like an empty array if there is no data since my last request)

 

Is this doable? If so, how? I've tried many of the samples, but those that looks like they could do something like this...simply do not run.

 

Thx all 🙂

0 Kudos
Message 1 of 3
(2,767 Views)
Solution
Accepted by topic author motoDrizzt

Hi,

so, if I understood correctly, you need to perform a continuous acquisition at a specified rate and continuously read N samples that are available in the buffer. If N samples are not immediately available, you would like to read less samples, what is available in the buffer. Am I correct?

Generally speaking, using DAQmx driver, you can specify the number of samples to read from the device at each iteration of a continuous acquisition. But if this number of samples is not available, the DAQmx read function will wait until a configurable timeput period expires and in case it returns a timeout error (see also here).

The document shows examples for LabVIEW but DAQmx C# functions are totally equivalent and provide the same parameters.

You can configure to read all available samples in the buffer, as explained here. Otherwise, you can get the number of samples that are available in the buffer and pass this number to the DAQmx Read function: this is the property in the Help for C#.

I hope this helps!

Bye!

 

Licia

 

0 Kudos
Message 2 of 3
(2,727 Views)

Hi,

 

what I want to do is to decouple the hardware from the software, just that, I don't need a continuous acquisition per se, but just to be able to ask for a sample and not have the application to hang. And I think the answer and the links you gave me are more than enough to solve my doubts, so yeah...this helped!

 

Thanks a lot 🙂

0 Kudos
Message 3 of 3
(2,725 Views)