LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to programatically set a LabVIEW exe's *Windows* priority?

Solved!
Go to solution

I have a LabVIEW executable which does 10kHz data acquisition on a continuous basis and conditionally dumps this data to a CSV file that is viewable in Excel.  We noticed that if the file gets exceptionally big and somebody attemps to open up this file while DAQ'ing is still going on (but not logging), Excel will hog the processor long enough such that the LabVIEW exe doesn't have enough CPU time to pull data from the DAQ before data in its circular buffer gets overwritten.  I could attempt to just increase the DAQ buffer size but really the solution is to have this LabVIEW executable have "high" priority compared to other non-LabVIEW executables (such as Excel.)    Looking at the VI Properties --> Execution --> Set Priority seems to only set priority between other LabVIEW threads but does not say anything about how a LabVIEW thread is prioritized to other non-LabVIEW exe's.   I've confirmed this by setting the LabVIEW execution property to "time critical" and then went into Task Manager and Windows still reports its priority as "Normal".   How can I set the *Windows* priority of a LabVIEW executable without having to do it manually through Task Manager?

 

Thanks

 

Ninja Edit:

I should mention that the Executable I build is nothing more than a "Master GUI" which spawns four LabVIEW modules into subpanels using Static VI refs and displays important data from those four modules on persistent "dashboard".   The modules do all the grunt work such as DAQ'ing and displaying the data in charts/graphs.  Because I'm compiling my code into a single executable using the "Master GUI" as the Startup VI, does setting the priority in VI Properties flow down to the modules I load in subpanels or will only the Master GUI's priority be changed?  On a related note, should I set the four modules execution system to "Data Aquisition" and then the Master GUI to "User Interface?"


Message 1 of 4
(4,388 Views)

@SiegeX wrote:

I have a LabVIEW executable which does 10kHz data acquisition on a continuous basis and conditionally dumps this data to a CSV file that is viewable in Excel.  We noticed that if the file gets exceptionally big and somebody attemps to open up this file while DAQ'ing is still going on (but not logging), Excel will hog the processor long enough such that the LabVIEW exe doesn't have enough CPU time to pull data from the DAQ before data in its circular buffer gets overwritten.  I could attempt to just increase the DAQ buffer size but really the solution is to have this LabVIEW executable have "high" priority compared to other non-LabVIEW executables (such as Excel.)    Looking at the VI Properties --> Execution --> Set Priority seems to only set priority between other LabVIEW threads but does not say anything about how a LabVIEW thread is prioritized to other non-LabVIEW exe's.   I've confirmed this by setting the LabVIEW execution property to "time critical" and then went into Task Manager and Windows still reports its priority as "Normal".   How can I set the *Windows* priority of a LabVIEW executable without having to do it manually through Task Manager?

 

Thanks


 

I will generally set the buffer size to 5-10 times what I fell is required for Excel to open to avoid the error you are describing.

 

Have you tried setting the LV task (using the Task manager) to TC and repeat the Excel open thing?

 

Usually setting a task to TC will squeeze out all other functions including tracking the mouse.

 

Ben 

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 4
(4,383 Views)

Hi Ben,

 

Yes, I've manually set it to "High" within Task Manager and that cures our problem since Excel is started in "normal" priority.  I have not tried "Real Time (aka Time Critical)" within Task Manager as I've been bitten by that before with it not having enough time to handle mouse and keyboard events as you mentioned.   I was hoping that windows would remember the priority I set on the LabVIEW exe by its process name but alas it doesn't work as it must use the process ID which changes upon each invocation.  For this reason I was really hoping for a non-manual solution to increase my LabVIEW exe's priority within Windows' process tree.


0 Kudos
Message 3 of 4
(4,378 Views)
Solution
Accepted by topic author SeanDonner

You can try calling the following VI. It sets the priority for the current process and worked for me in the past on XP.


___________________
Try to take over the world!
Message 4 of 4
(4,359 Views)