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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

simultaneous tasks AI, AO, DO, CI

Solved!
Go to solution

Hi,

 

I try to control of the AI, AO, DO, CI of my PXIe-6358 card simultaneously and for that I built the VI attached. If I run the VI it does the job without any problem however if I connect the function generator to the pin of the CI [to the gate of for example ctr0] to measure the signal frequency, within a second I get the error message "Attempted to read samples that are no longer available" [attached image]. Can somebody please advise me what I am doing wrong.

 

Thanks.

Download All
0 Kudos
Message 1 of 6
(3,532 Views)

Hi krivan,

 

Have you tried running the CI task in isolation with the function generator connected? Generally speaking this error occurs because you are not reading samples from the PC buffer quickly enough. A common problem is that the acquisition loop is being slowed down by other operations (e.g. processing or analysis) which is causing the overflow. In this situation it could be that the other tasks are slowing down the loop.

 

Error -200279 is a relatively common error in continuous buffered acquisition applications and as a result there are a number of potential solutions. There is a Knowledge Base article which I have linked below which addresses this error and highlights a number of steps which can be used to overcome this problem.

 

Why Do I Get Error -200279 from my DAQmx Read VI or Property Node?

 

Please work your way through the steps in this documents and let me know if your problems continue.

 

Best Regards,

 

Christian Hartshorne

NIUK

0 Kudos
Message 2 of 6
(3,495 Views)

Hi Christian,

 

yes, if I run the code for the CI like the one attached it runs perfectly and correctly displays the measured frequency.

 

Krivan

0 Kudos
Message 3 of 6
(3,484 Views)
Solution
Accepted by topic author krivan

Hi Krivan,

 

The problem is that you have two input tasks in the same thread that are acquiring data at different rates. 

 

    The AI task is clocked at whatever rate you set.  It will block the loop until the desired number of samples have been acquired.

 

    The CI task is configured to "Implicit" timing, meaning that it will latch in a sample for every period of your input signal.  If the input signal is too fast then the loop (whose rate is regulated by the AI Task) won't be able to keep up.

 

 

In almost all cases, if you want to have two tasks acquiring data in the same loop they should be synchronized to ensure that one task does not acquire data more quickly than the other. 

 

Do you need to acquire a sample from the counter for every period of your input signal?  Depending on the frequency of your input signal, you might want to look at the sample clocked frequency measurement method that is supported on your X Series board.  The most straightforward way to get the program working however would be to run the tasks in parallel, or if you don't need to buffer the samples from your frequency task you could simply remove the timing from the counter task altogether.

 

 

Best Regards,

John Passiak
Message 4 of 6
(3,472 Views)

Hi,

 

basically what I need is I think no fancy. I have to sample the incoming AI data at 1 MHz because the highest frequency of the incoming signal is 250 kHz, or in an extreme case 500 kHz. 

 

DO, AO only sets my device into the right operation point and with CI I simply would like to measure the output frequencies of the four on-chip oscillators so I actually need all four counters to measure the different oscillators.

 

As you suggested I put the CI into another loop and it perfectly works now, thanks!

 

Although I am still a bit unsure about it because for example if I had two or more output tasks on DO or AO it still could be in the same loop however if I have two input tasks I have to input tasks I have to separate them...can you please point out some guidelines for me to read, it is namely not clear when and why I have to put things into a different loop and why it cannot be done in the same loop.

 

 

0 Kudos
Message 5 of 6
(3,458 Views)

Calling a slowly-executing subVI inside a loop will slow the entire loop down.  In your case, the consequences of this are that the loop is running too slow to read data from the counter task before its buffer overflows.  To a certain point you could work around this by increasing the buffer size on the counter task, but I think it's a better idea to run the independent tasks completely in parallel.  In your specific case, the output tasks do not block the loop so they don't cause any problems.  More specifically:

 

 

On your AO task you are writing the data before the task is started and continuously generating the same data repeatedly.  The Is Task Done? VI is just used inside the loop to query for driver errors--it doesn't block for an indefinite amount of time like the read functions (which block until the desired amount of data is available).

 

On the DO task there is no timing configured.  Every loop iteration updates the current status of the DO line, but since the task it not hardware-timed the write function call just sets the state of the line and moves on.  So, it also does not block indefinitely and shouldn't give problems.

 

So... for your particular configuration the output tasks are OK inside the same loop.  However, under other circumstances it would be possible to have problems with output tasks.  For example, If you had timing configured with non-regeneration, DAQmx Write blocks until enough space becomes available in the DAQmx buffer.

 

 

Best Regards,

John Passiak
0 Kudos
Message 6 of 6
(3,451 Views)