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: 

How to reduce execution time in order to save data in a text file every second?

Solved!
Go to solution

I want to monitorize 7 parameters with a step time of 1 second. The data are read and registered in a text file after the execution of the loop.

 

The problem is that the execution time of the loop exceeds the time period set in the timed loop structurre, so data are saved with an step time of 2 seconds.

 

Tiempo_VI_DUSST.JPG

I think the problem is in the code. Could anyone help me with this issue? 

 

PD: I'm using the drivers associated with the datalogger Agilent 34970

 

Thanks

0 Kudos
Message 1 of 2
(1,924 Views)
Solution
Accepted by topic author afsolas

1. Set up a scan on the 34970 before the loop.  Then you can do all of the reads at once and then do the math needed on each channel.  This would eliminate most of your communications (which are slow) inside of the loop.  You can look at the example at <LabVIEW>\instr.lib\Agilent 34970\Examples\Agilent 34970 Advanced Scan.vi to see how this works.

2. Do NOT use a timed loop.  It is adding overhead you do not need and eliminates a lot of possible optimizations very little gain.  Just use a simple While loop and use a Wait anywhere in the loop to set your loop rate.

3. You might want to consider using a Producer/Consumer for your logging.  The idea here is to use a Queue to send your data to another loop that logs the data on the fly.  This would eliminate the building of a potentially large array for logging at the end.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 2
(1,905 Views)