LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

for loop won't iterate for data aquisition

Hello LabView Community.

 

I am rewriting a program that once worked to operate with new hardware.  The program simply:

1. opens  a spreadsheet file and prints initial information

2. Takes one sample per second (from several channels) for 60 seconds (inside while loop)

3. finds the average or max value of the 60 for each channel (inside a for loop)

4. Writes processed value into spread sheet file (one value per channel per minute)

 

The program also does some control tasks (but that is not the problem right now).

 

My issue is that the program runs well,  gets the data and prints it to the spreadsheet file in the propper format.  However, it does this only once then stops regardles of the "N" input to the for loop.  Then the program shuts down.

 

This program has worked in the past before significant alterations so the problem is  likely something minor.  Any help would be greatly appreciated. 

0 Kudos
Message 1 of 5
(3,044 Views)

Don't stop and clear tasks inside your For Loop.

 

Are you sure the For Loop is supposed to run more than once?  Have you put a probe on the orange wire going into the N terminal of the For Loop to see what it says?  I don't see anything else that would control how many times the For Loop runs.

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

There are several curious things in this program.

  • The index to the FOR loop is a float, while the For loop takes integers.  In particular, if the index gets rounded down to 0, the loop won't run at all.
  • You create, start, acquire, and dispose/kill the acquisition task each time through the FOR loop.  Did you want to restart the tasks?
  • Your clocks are set up to acquire 100,000 samples at a time, yet when you actually acquire NChan NSamp, you acquire only 1 sample!  More than curious!!  If you are really taking a single sample, leave the buffer size (on the Timer function) at its unwired default of 1000 (which is still three orders of magnitude larger than you need).
  • If you have set your acquisition rate to 1 Hz, you don't need to time your inner While loop, the DAQ hardware will do it more accurately and precisely than Windows.  Similarly, you don't need timing functions to decide when you've taken 60 samples -- you can just count them.  You could even use a FOR loop ...

Bob Schor

0 Kudos
Message 3 of 5
(3,010 Views)

Not sure why,  but the program was assuming 1 as the number of iterations.   Fixed!

 

Thanks,

 

Jo

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

Thank you Bob. Although none of your suggestions woked on what was were causing my problem fixing these things has improved the program.  

 

 

Jo

 

 

0 Kudos
Message 5 of 5
(2,984 Views)