LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing data between timed loops

Using LV2009 on Win_XP.  PCI 6229 for analog DAQ and PCI 6518 for Digital I/O.

 

Have a MAIN.VI that has a 10ms timed loop triggered by a Digital Edge counter. The analog channels are sampled inside this timed loop.

 

I have another VI called AUTO that runs a software Timed loop also set for 10ms. MAIN has a priority of 100 and AUTO has a priority of 99.

 

AUTO gets the analog values from the MAIN through a Functional Global Variable. Digital I/O are directly read inside of AUTO.

 

The setup works fine except for a very occassional  error " Analog samples previously available have been overwritten and unavailable ...." and all indicators in AUTO read zero. Once I quit and restart things are fine. The AUTO timed loop is set to Discard missed loops and NOT maintain original phase.

 

Is there is anything basically wrong in my setup for acquiring analog samples ? I am enclsoing the AI_Setup used in main to get the trigger pulses for the Timed loop.

 

 

Message Edited by Raghunathan on 09-27-2009 11:34 AM
Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 5
(3,068 Views)

Your setup looks fine. What we can't see is how the Sample Mode is setup and the rate (on the Sample Clock).

 

Let's assume Sample Mode is Continuous Samples and a buffer size of 1000 (the default).

 

Some things that can cause that error are:

  • Reading samples too slow. Your read loop needs to run faster than the "rate" of your sample clock. In other words, you have to "read out" the samples before the 1000 sample buffer fills.
  • Some programmatic event causes the read to be interrupted.

 

A while back, I had the same error happen due to a modal dialog box which was ill-placed. Make sure the Read Loop doesn't have things in it which can slow down the rate of the loop. Your digital triggering, if it were late, might cause it. In your case (using timed loops) you can look at "Iteration Duration" or "Finished Late?" when the error occurs as a troubleshooting tool.

 

Another troubleshooting device is the DAQmx Read Property Node "CurrReadPos" and "AvailSampPerChan". Monitor those in your read loop. As "AvailSampPerChan" nears the buffer size (1000), you're getting close to an error. Ideally, it should never creep up.

Message Edited by Broken Arrow on 09-29-2009 09:18 AM
Richard






0 Kudos
Message 2 of 5
(3,011 Views)

Never knew about that "DAQMX read property node". Looks like it IS the thing that I need to monitor. Will do that and keep you posted.

 

As to the sample clock rate and samples it is 2Khz and 200 samples. Which yields a sample time of 10ms.

 

Thanks.

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 3 of 5
(2,987 Views)

Keep in mind (from help):

 

samples per channel specifies the number of samples to acquire or generate for each channel in the task if sample mode is Finite Samples. If sample mode is Continuous Samples, NI-DAQmx uses this value to determine the buffer size.

 

So if you're set to Continuous, setting Samples/S to "200" just means the buffer size is 10k.

 At any rate, if you're sure you're clocked at 10mS, and you are reading at 10mS, that leaves no room for error.   As another troubleshooting tool, read faster, and/or change the timed loops to normal loops, and read at 5mS rather than 10mS.
Message Edited by Broken Arrow on 09-29-2009 11:34 AM
Richard






0 Kudos
Message 4 of 5
(2,978 Views)

The DAQMX Read property node did give a clue to the issue :

 

- I do not understand what is meant by "Curr Read Pos"? It just keeps increasing and reaches big values like  52 x 10^6.

 

- The "AvailSampPerChan" reads Zero if I set to acquire all available samples and if I set it to 20, then it also reads 20. But the problem is this : If I move the mouse, then this value rapidly increases and once it reaches 10K, the DAQMX error 200279 occurs.

 

- I tried invoking "Overwrite UnreadSamples" and at the point of the buffer rolling over to zero, the error occured. WHen I set the "Do not overwrite unread samples " , the AvailSampPerChan" value freezes close to 10K , analog value update also freezesbut no error is shown.

 

In my last post I had mentioned the samples as 200. It is actually 20 / ch. and the rate is 2kHz.

 

It is now clear that front panel activity by user triggeres the fault. But what would be the solution ??

Thanks.

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 5 of 5
(2,947 Views)