LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running a loop without waiting on all readings

Hello,

 

I have been struggling to create a vi that does exactly what I want.  I want to take multiple measurements from multiple sources at the same time with a time stamp.  I have been getting all of the measurements accurately.  My problem is that I need a very high sample rate for my data, and the instrument connected to my VISA serial read only samples at a rate of one measurement per 1.6 seconds.  This is acceptable for this measurement, but my other measurements need to have hundreds of readings per second.  However, it appears that my loop will only iterate once every 1.6 seconds, which I assume means that it is waiting for the next reading from my VISA device.  Is there a way to tell Labview to check for a reading or obtain a new reading only when one is available, instead of holding all of the other readings to a 1.6 second sample rate?

 

The vi I am working with is attached.  I originally used a WHILE loop but in an effort to speed up the iterations I switched to a TIMED loop.  This did not help.  I need all of the measurements to be sampled as fast as possible.

 

Thanks

0 Kudos
Message 1 of 6
(2,547 Views)

Dataflow dictates that the loop cannot proceed to the next iteration until all code in it has completed. The slowest part will determine the loop rate.

 

There are many possible solutions. Maybe you should run the various parts in their own loop at their own pace.

 

At what rate do you want to save the data? If you save at the fastest rate, what should it do with the slower data points? (e.g. repeat the last seen value or something else)

0 Kudos
Message 2 of 6
(2,543 Views)

I apologize for not replying sooner, I missed the email that this post had been updated.

 

I have tried running a different version of the code with 2 while loops, but I was told that should be avoided.

 

I want to collect and record the data as fast as I can read the DAQpad, which could be as much as 1000Hz or more.  I am not too picky about what happens to the slower data points.  Repeating the last seen value between updates would be perfectly fine, as would leaving the field blank between measurements.

 

In fact, I believe that sort of thing is exactly what I have been trying to do.  If I could have the entire process run as fast as possible and then just skip the slow read or have the slow read give the last seen value for all of the points that it doesn't have a new measurement, my problem would be solved.  I can't figure out how to do this though.  Could you suggest a way?

 

Thanks

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

Separate your code and use multiple loops. There is nothing wrong about using multiple loops. You want to avoid splitting your DAQ collection across multiple loops. But separating other types of processing is how you can improve performance. Have one loop do nothing but collect the data. This loop would post that data to a queue for further processing. You could also separate logging the data into it's own loop too. Again, data to be logged would be posted to a queue for processing. Writing data to a file in the same loop as you are collecting the data will decrease your performance. File access is slow.

 

Also, learn how to use data flow and avoid all of the stacked sequence structures. Most of the stuff in teh sequence structures already has data flow which will control the execution order. Deep stacked sequences are difficult to maintain and modify. You should also take some time to learn about state machines.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 6
(2,455 Views)

Ok, I will look into that.  Could you give me some pointers on using queues?  Or tell me what the appropriate search terms in Labview would be for those creating one?

 

Thanks

0 Kudos
Message 5 of 6
(2,446 Views)

@sdwndr521 wrote:

Ok, I will look into that.  Could you give me some pointers on using queues?  Or tell me what the appropriate search terms in Labview would be for those creating one?

 

Thanks


Search for "queues" in the example finder.

 



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 6 of 6
(2,441 Views)