LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Slow Front Panel

Hi, I am working on a SW for an aerodynamic tunnel in LabView 2012, and I am having problems with the refresh speed of the front panel. It seems that no matter what I do, the max refresh rate of indicators and charts is synchronous at about 2Hz. I am quite new to Labview and I tried to find the answer on the YouTube, NI forums and from Copilot AI. The AI suggested splitting the program into a "producer loop" and "customer loop", so it is possible to set the data acquisition and logic with charts and indicators to a diferent speed with delay function in theirs respective while loops. I am measuring 3 channels with 3 bridge tasks. All I am measuring is DC voltages from 3 bridges of tenzometers. The aero data is calculated from those 3 voltages using basic math. My NI 9219 card is set to 100Hz, as that should be the maximum sample rate, with the number of samples set to 1. The only two things that have any effect on the refresh rate of the front panel are the sample rate, and if I set the wait function inside one of the while loops to more than 10ms. I am attaching the vi. I would be extremely thankful for any kind of advice, and I thank you in advance. Also I am running Intel N95 CPU with 16GB of RAM, so I ruled out HW bottleneck.

0 Kudos
Message 1 of 14
(871 Views)

Not sure IF the VI attached

0 Kudos
Message 2 of 14
(870 Views)

You have a number of weird bits of code so after you resolve this problem there are a number of other things you may want to look at improving as well, by the way... (bad local variable use, the very strange choice to convert your array to a cluster, your use of "Dynamic data"...)

 

To address your actual complaint, in a "While" loop everything has to finish before it loops again, so you're mostly just looking for the slowest thing in the program.  Of all the things in your loops, the only things that really could be slowing you down are:

 

  • The DAQmx read in the small loop
  • The dequeue in the large loop
  • The file saving in the large loop

I'll address these in reverse order.

 

The file saving is unlikely to be the problem unless you're saving to something really slow, like an old USB thumb drive or something on a slow network drive.

 

The dequeue is set with a timeout of 100 ms.  That means that it should be going at least 10 Hz, unless you are timing out.  Have you put an indicator on the "Timeout" output of it to see if that is happening?  If that were the case you would likely get a lot of zeros in your data and notice that.  Have you looked for that?

 

Both of those are in your large loop.  Have you tried adding a loop counter to see how fast it updates?  Just something simple like this:

Kyle97330_0-1745952510374.png

 

Your small loop is more likely to be the problem.  What you have done might work, but when you write code that way, DAQmx is starting and stopping the task for you constantly.  Each stop and start can take quite a while (relatively speaking), maybe around 200 ms each.  So what's probably happening is that each time it runs, it has to do a lot of startup prep for 200 ms, then measures for 10 ms, then runs a shutdown for 200 ms, for a total of around 410 ms per loop, about 2.5 Hz.

 

If that's the case, what you need to do is start it outside the loop, execute it inside the loop, and then stop it outside the loop when done.  Something like this:

Kyle97330_1-1745952718259.png

That image is not mine, it is from here:

https://forums.ni.com/t5/LabVIEW/DAQmx-read-runs-slow-even-after-generating-DAQmx-Code-from/m-p/4107...

 

Before you make changes to your code, you likely want to time it to be sure that this is the cause.  Use this method to check execution time of pieces of your code:

 

https://forums.ni.com/t5/Example-Code/Measuring-Execution-Time-of-a-Code-using-LabVIEW/ta-p/3511278

 

 

Message 3 of 14
(838 Views)

Your main loop shouldn't have any Wait at all, since it's limited by the Dequeue, although that's not why it'd be 2.5Hz. Your Local variables (which is a bad name, it's a local data copy) will cause some race conditions, try to avoid those. The Wire is the variable. 🙂

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 14
(773 Views)

There are plenty of express VIs that have more overhead than explicit code. Also, most of the calculations could probably be done on the array with three elements, avoiding all these formula nodes. Yes, your local variables have obvious race conditions because for each iterations, they get read before their terminal receives new values.

 

The most silly construct is the "array (with 3 elements!) to cluster (with 9 elements!) to unbundle, to 3 scalars" to get the first three elements, a job that can be done with a single index array!

 

altenbach_0-1746031214238.png

 

0 Kudos
Message 5 of 14
(752 Views)

Hi, thank you very much for your answer! I would be extremely thankful for any tips to improve my program. Anyway, back to the speed problem. I have implemented the improvements to the daq data acquisition as well as some other improvements suggested by other users. I also wanted to add that I am using continuous samples. I added the loop counter indicators, ran the program for 10 seconds and the loop cycle was exactly 100/s on both whole loops. I have attached the improved vi. I have created the TEST 1 vi to test the cycle time of smaller while loop, and presuming I have done something correctly, the time was 9,8ms. (see attached test1 VI and picture). Then I did the same for the bigger loop, see TEST2 vi and picture, and the time of the first loop was 859ms, every next is about 9,1ms. I am starting to think that the problem is with Labview itself, either some strong setting, or that's just how Labview is...I have attached a short video to show how exactly the front panel looks when running.

0 Kudos
Message 6 of 14
(732 Views)

@adamtry wrote:

Hi, thank you very much for your answer! I would be extremely thankful for any tips to improve my program. Anyway, back to the speed problem. I have implemented the improvements to the daq data acquisition as well as some other improvements suggested by other users. I also wanted to add that I am using continuous samples. I added the loop counter indicators, ran the program for 10 seconds and the loop cycle was exactly 100/s on both whole loops. I have attached the improved vi. I have created the TEST 1 vi to test the cycle time of smaller while loop, and presuming I have done something correctly, the time was 9,8ms. (see attached test1 VI and picture). Then I did the same for the bigger loop, see TEST2 vi and picture, and the time of the first loop was 859ms, every next is about 9,1ms. I am starting to think that the problem is with Labview itself, either some strong setting, or that's just how Labview is...I have attached a short video to show how exactly the front panel looks when running.


It's always a LabVIEW problem.  Until you find it's actually you.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 14
(712 Views)

No, its not LabVIEW.

 

What's the purpose of that "reserve network device" that runs in parallel to the rest of the code?

What's the purpose of these three hidden indicators that only seem to serve as scaffold for local variables?

Can you translate some of the control labels so we get an idea how they should be used? (e.g."VYNULOVAT" seems to mean RESET is Czech) and why is that set to the rather unusual "switch until released" mechanical action? That seems incorrect and can easily be missed by the code).

Your express VI is set to use the next available file name if the file already exists. Finding that next available name could be slow on the first iteration if there are many files.

Since you stop the big loop after a given number of cycles, it is just a glorified FOR loop (with conditional terminal), so why is it a while loop?

0 Kudos
Message 8 of 14
(680 Views)

@adamtry wrote:

 I am measuring 3 channels with 3 bridge tasks.



Can you show your task timing settings?  You say you're measuring 3 channels with 3 tasks but I only see one. So that makes me think that what you say you're doing is not what you're actually doing, in regards to timing. 

aputman
0 Kudos
Message 9 of 14
(664 Views)

What are reasonable control values for "Úhel Nábìhu a ", "Délka ramena mm", and "NO CYCLES"?

 

Zero does not seem reasonable, so why are they zero by default?

0 Kudos
Message 10 of 14
(625 Views)