LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While loop seems to 'pause' during standby / sleep / no computer activity

Hi,

 

I am fairly new to LabVIEW but managed to edit an existing program with new features. The program logs pressures and temperatures (obtained via fieldpoint controller). Before my adjustments, it merely stored the information in 'Collectors' (up to 10.000 datapoints at a time) and showed the data in graphs, and via a button click these logs could be saved to file. Since this way no more than 10.000 datapoints were ever 'remembered', I tried to build in some automatic logging such that all the data was always logged.

 

The automatic logging program I made consists of a main While loop that waits 400 ms every iteration (this can be adjusted but is not relevant). Each iteration the data is read and sent to a Collector. Every minute, the program follows the following logic:

  1. Use today's date and time to construct a filepath for the logging
    1. The filepath is constructed as "C:\Logging\<date>\<hour>h.txt", so for example "C:\Logging\2012-12-4\11h.txt" for 11 am on 4th december 2012.
  2. If the folder (C:\Logging\<date>) does not exist, create it.
  3. If the file (C:\Logging\<date>\<hour>h.txt) does not exist, create it and write some column headers
  4. Write the data in the Collector to the file
  5. Reset the Collector

This results in one file for each hour, and one folder for each day. When the hour changes (from 10am to 11am for example), a new file is created and logging continues in this new file. Data is written every minute, so that we have the logging up to the last minute in case something goes wrong / pc fails / power failure, etc. 

 

 

This automatic logging VI runs alongside another VI which controls the system that we are logging. Everything works perfectly fine when we are working on the computer or when this other VI is controlling the system (even when running an automated process overnight). However, as soon as the computer is 'idle' (nobody at the computer, no automated process running anymore), it seems like the logging stops. I cannot figure out the exact condition (eg, what do I mean by "idle"), but maybe it's when the computer goes to screensaver, I'm not sure. The power settings are such that it only ever powers down the monitors, it should never go to sleep or standby.

 

When I look at the between yesterday and today, everything after 22:00 is missing (the last logging file is from 22:00). There was no folder for today when I "woke the computer up" from screensaver (it was not in standby), but exactly one minute later, the folder appeared with a new logging file, it started as soon as I awoke the computer.

 

 

At the same time, I also looked at the logging graphs (those that I mentioned at the start, they simply show the last 10.000 datapoints and are only reset when I press a button). Since nothing was happening overnight, the pressure (controlled by a pump) has been slowly decreasing overnight, but it seems like the graph (data collection) had paused somewhere in the night and continued as soon as I awoke the computer: there was a big jump in the pressure. Basically, the last datapoint the graph showed was from somewhere last evening (probably), and this morning the pressure was a lot lower, but it had not updated the graph so there was a big jump as soon as it started collecting data again.

 

 

 

The only explanation I can think of is that the While loop was "paused" somewhere during the night. This must have caused the data collection to stop, but immediately continue as soon as I awoke the computer. This explains why there was a jump in the graphed data, and also why there was no logging between 10pm and 10am this morning.

 

I do not recall this behavior ever happening before, usually the data collected and shown in the graphs (from the old version of the logging program) was up to date immediately in the morning when you awoke the computer, it did not have a jump, the data collection never paused. So I am certain it has something to do with my adjustment to the program. The only thing I can think of is that there is something going wrong with the file/folder operations. Each hour the program has to look if a file exists, if not then create it, and then write data to it. It seems somewhere after 10pm yesterday evening it somehow was not able to do that and the loop execution was stopped until I awoke the computer and it was suddenly able to find the folder/file again. Does that sound logical? The loop timing is done by a 'Wait Until Next' (not a standard Wait), perhaps this has something to do with the problem?

 

 

 

Short summary: I suspect the execution of a While loop is being paused when the program is looking if a file exists (or trying to create a file) while the computer is "idle". I am not sure what "idle" means (screensaver?).

 

We had a similar experience this weekend: the other program (the one controlling the system) was running an automated process, controlling valves and such via the fieldpoint controller, until about 2am saturday night. After 2am, the process was completed, and the logging stopped running, the While loop seems to have been paused until we 'awoke the computer' (read: moved the mouse) and the logging immediately continued again.

 

 

Is this normal behavior? Is there a labview setting I can change maybe? Or a computer setting I need to change? I want my logging to run continuously as long as the computer is on (it should never go in standby or sleep or hibernate or whatever at least not automatically, only screensaver and turning the monitors off is enabled).

 

Thanks for any help.

 

0 Kudos
Message 1 of 8
(3,504 Views)

What is your logging device connected to.  I had a USB device connected to my monitor USB hub which stopped working when the monitor went into power save mode!

 

Ken

0 Kudos
Message 2 of 8
(3,487 Views)

I think the connection is made via a LAN network. However, this cannot be the (direct) cause because the logging program did not pause (ever) before I made my adjustments, this is really something new. Furthermore, if the connection was lost wouldn't it either start throwing errors, crash, or log 'random' values? Can this cause a while loop to pause ('wait for data')?

0 Kudos
Message 3 of 8
(3,483 Views)

Not necessarily.  My application just paused until the device became available again when I switched the monitor on again in the morning but that might be bad programming on my part.  If you are getting your data across the network then this is not the cause - unless the Monitor is a LAN hub 🙂

 

I am not aware of anything in LabVIEW that stops when the monitor goes to sleep.  Can you stop the monitor going to sleep?

 

Ken

0 Kudos
Message 4 of 8
(3,479 Views)

Without seeing the code it will be extremely difficult to find teh issue and give you any advice.



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 5 of 8
(3,458 Views)

Check to be sure that your hard drive is not set to go into a sleep mode.  Otherwise, post the code and maybe we'll see something you're missing.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 6 of 8
(3,447 Views)

The hard drive is not set to go to sleep. 

 

I turned off the screensaver yesterday (but still enabled monitors to shut down after 1 minute). This night nothing seems to have gone wrong, all the logging is there. So either the screensaver was causing it, or I got lucky and it will happen again soon 🙂

 

 

I attached my code. A brief explanation may be useful...

 

The top-left Stacked Sequence is the sequence that retrieves the data from the fieldpoint. For each of the four stacks (each represents one pressure or temperature gauge), the data is stored in two separate Collectors. Collectors 1 to 4 are used for the live display on the UI (these are linked to graphs) while Collectors 5 to 8 continuously collect the signals for auto-logging. The Case structure to the right is for manual saving and is not really relevant since that works fine.

 

The Case structure below (commented "Nick: Auto-save logging") is activated every 60 seconds and performs the steps required for auto-logging:

0. If the current folder 'Log directory' does not exist, then create it.

1. If the current file under 'Log path' does not exist, then create it by writing the column headers.

2. Write the four data columns (along with some horrible logic to get the total number of seconds in the day).

 

Below that finally is the logic to generate the file and folder paths (based on current date/time), and finally the timing (Wait Until control).

0 Kudos
Message 7 of 8
(3,422 Views)

You are overusing local variables for the log file parameters. Why do you Check if File or Folder exists for "Log directory", then use another copy to create the folder? Same with "Log Path". You also have a race condition between those local variables and the code below the case statement that is creating the directory, path and filename. You should make the case statement execution dependent on those indicators being updated with the added benefit of not needing the local variables (example showing "Log Directory"...do the same with the "Log Path"):

 

Logging 5_BD.png

 

And here is a simpler way to get the number of seconds from the current time although someone may have a more elegant way:

 

nowtosecs.png

 

and I'm still thinking about your main issue....Smiley Happy

0 Kudos
Message 8 of 8
(3,381 Views)