From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

Save data to file outside of while loop and collect time in sec

Hi, I am new to Labview and working with a project, where I want to collect data from different types of sensors and handle everything from the front panel. 

 

At this point, I already have set up one sensor (Linear potentiometer), which is chosen at the dropdown panel in the top. (see attached file-Sorry for all the Danish words) (At this moment the other ones are empty)

 

My program allows me to choose which port from my DAQ the sensor is connected. Thereafter calibrate the sensor and reset to a starting point. 

The data to save is distance moved, min and max value for this sensor. 

 

1. The problem is, that I want to log the data. But when I write my data inside a  loop to a file. It writes for each iteration. If I move it outside the loop, nothing gets written. How do I solve this, so I can get a continuous log for the collected data? 

 

2. Also, I would like to have a timer going inside my loop, so it is visual for how long time the program has run. This timer shall also be used to show when my value of Min and Max is stored. 

 

Is there a kind soul to explain/show how to solve these problems?

 

If anyone has some good ideas for my project I am interested to hear your suggestions.

 

best regard 

Morten

 

0 Kudos
Message 1 of 2
(2,040 Views)

Hi Pedersen,

 

please learn how to use more shift registers and less local variables!

You get two improvements:

  1. This would eliminate all those race conditions in your code
  2. The code readability and stability will be improved.

 

1. The problem is,

You did something wrong when you tried to move the Write operation outside of the inner loop…

 

2. Also,

There is a whole palette with timing functions. All you need is to get the time before the loop and the time inside the loop to calculate their difference…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 2
(2,031 Views)