LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read All Available Samples Property

When I use this property to do a finite sample before the sample process complete,why do I get 0 samples?

0 Kudos
Message 1 of 11
(4,082 Views)

Your VI works for me, I get data, but note that, I only tested it with a simulated DAQmx hardware.

I do not understand the reason, why do you use that flat sequence structure, and that 1 second wait??? Just get rid of them. Below the original, and the modified VI, test the modified one.

 

Actually could you explain, why you want to use this property node? What is your goal? I would just skip this special setting, and let DAQmx read all samples when the buffer gets full. And do not interfere with DAQmx using flat sequence and extra timing. The DAQmx timing does it properly without extra timing...

 

Also, did you read the help of the property node? Here it is: "Specifies whether subsequent read operations read all samples currently available in the buffer or wait for the buffer to become full before reading. NI-DAQmx uses this setting for finite acquisitions and only when the number of samples to read is -1. For continuous acquisitions when the number of samples to read is -1, a read operation always reads all samples currently available in the buffer."

 

Yours:
Read All Available Samples Property_BD.png

Fixed:

Read All Available Samples Property_BD_fixed.png

0 Kudos
Message 2 of 11
(4,068 Views)

Yes, I also can get data in a simulated card, but not in an actual card.

My purpose to use this property is because I don't know the exact samples I need collect. By this property as well as a delay, I can wait till the DAQ complete, then get the total samples in the buffer.

Maybe you can try my vi in an actual card again. 

Thank you.

0 Kudos
Message 3 of 11
(4,015 Views)

@穆易 wrote:

My purpose to use this property is because I don't know the exact samples I need collect. By this property as well as a delay, I can wait till the DAQ complete, then get the total samples in the buffer.


DAQmx will do this for you automatically. It will wait until the buffer is full, then will give you the requested number of samples. I do not understand what you mean about "I do not know the exact samples I need to collect". You know the sampling rate what you set, you know how long time interval you want to sample. For example, you want to sample data for 2 seconds, with 10 kHz rate. This will tell you how many samples per channel you need to set for the DAQmx Timing VI: 2 X 10 kHz = 20 k samples!

And let the DAQmx driver do the timing for you! You try to affect the DAQmx driver by setting a 1000 msec Wait. But you forgot that this Wait is timed by the Windows OS! The timing accuracy/jitter is usually much worse compared to your DAQmx hardware internal timing! So just use my modified VI in such case, and let the DAQmx driver do the timing for you.

 

By the way, could you share us what DAQmx hardware do you use?

 

Edit: and if your goal to use variable timed DAQmx Read, do not use Finite samples, but Continuous mode!

0 Kudos
Message 4 of 11
(4,009 Views)

I tried usb-6001 and usb-6351, both not work.

Maybe I should ask this question in another way. In my VI, I start a 2-seconds DAQ task, then delay 1000ms, I check the buffer samples. Why I can get the samples in an simulated card, but can not in an actual card. In my opinion, there should be about 1-second samples in the buffer, but I can get nothing in it with an actual card.

0 Kudos
Message 5 of 11
(4,000 Views)

@穆易 wrote:

I tried usb-6001 and usb-6351, both not work.

Maybe I should ask this question in another way. In my VI, I start a 2-seconds DAQ task, then delay 1000ms, I check the buffer samples. Why I can get the samples in an simulated card, but can not in an actual card. In my opinion, there should be about 1-second samples in the buffer, but I can get nothing in it with an actual card.


I cannot tell you why. But I can tell you how you can get properly data. Why you need that delay at all? Just create a producer/consumer structure, setup a continuous DAQmx Read with the required rate. That is all, your device will sample all the time, and you can access live data at ANY desired time interval!

0 Kudos
Message 6 of 11
(3,997 Views)

I am just doing a test with this VI. In my actual case, I must collect signals with an external clock. But the external clock will stop at any time, and I dont know the exact time. I dont know how to stop DAQ without a timeout errror. So I want to use a delay (during the delaytime, external clock might stop, so does the DAQ process)and collect all the available samples in the buffer before a timeout occurs.

0 Kudos
Message 7 of 11
(3,994 Views)

I do not understand, sorry, it does not make any sense to me. If you want to stop (or either start/stop) an ongoing DAQmx Task, use the triggering options. Much better then messing with software timing and available samples.

You should explain how you want to setup your hardware (what is this "external clock", how do you wire it up to your NI hardware)? Also, show your actual VI, which will do the start and stop. I do not see anything in your VI which is related to this "external clock"...

 

Here is some doc which explains how to do triggered acquisition, if this is what you are looking for: http://www.ni.com/tutorial/4329/en/

0 Kudos
Message 8 of 11
(3,991 Views)

http://www.ni.com/documentation/en/ni-daqmx/latest/daqmx-node-ref/daqmx-read-analog-2d-dbl-nchan-nsa...

 

the link above show the use of this property, I just wanna the same way.

number of samples per channel

If the task acquires a finite number of samples and you set this input to -1, the node waits for the task to acquire all requested samples, then reads those samples. If you set the Read All Available Samples property to TRUE, the node reads the samples currently available in the buffer and does not wait for the task to acquire all requested samples.

 

 

 

 

 

0 Kudos
Message 9 of 11
(3,988 Views)

Actually that link shows NXG function, not LabVIEW, but anyway, same logic 🙂

 

Still, i do not understand why you want to do it this way. For your actual question, i am afraid to say i cannot tell you why you do not get samples. But i would never try to interfere with DAQmx timing with an extra software Wait.

But i did not understand your explanation, so it is not clear to me what is your goal, and why you want to do it in this way?

Sorry i could not help more, maybe someone more experienced will come and help you out...

0 Kudos
Message 10 of 11
(3,981 Views)