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: 

Application control methods to prevent jerky graph refresh rate

Hi all,
 
In the simplest terms, what I am trying to achieve is a VI with a button on. When the user presses the button, a subVI is executed which acquires some data which is displayed on 2 graphs. The first graph has cursors which can be moved by the user to define the limits of the data plotted on the second graph.
 
I created a VI that did the 2 graphs with the limits and they updated fine (see attached file Stiffness and Damping.vi). However, this was when loading some data from a text file (attached as LabTestData.txt).
 
When I replaced the loading bit with the DAQ subVI, when the user changed the cursors on the first graph, the range of data on the second graph remained unchanged (see attached file FIND SAD v1.vi).
 
I then changed the structure so the data acquisition was in a different loop to the analysis and this works to a certain extent, apart from the fact that the second graph has a very jerky refresh rate (see attached file FIND SAD.vi).
 
If someone has a suggestion on a better way to structure the VI to solve these problems then that would be a great help.
 
The second version also has the problem that the VI doesnt stop when the 'Back to main menu' button is pressed, and I can't figure out why this is.
 
Many thanks,
 
Ian
0 Kudos
Message 1 of 9
(2,920 Views)
"Back to Main Menu" button does not work because it is outside the while loops.  That means it's value only gets passed in before the loops execute first iteration.  You need to put this control inside one of the two control loops and then pass its value to the other loop.
Message 2 of 9
(2,910 Views)

Thanks for that - I feel a bit silly for missing that one. I'm glad you pointed it out as I need to bring my input controls inside the event structure to enable different values to be passed to the subVI - I'd just been testing it using the defaults so hadnt even noticed that bit didnt work either.

Any ideas on the first bit anyone? Any help is always appreciated Smiley Happy

Cheers,

Ian

0 Kudos
Message 3 of 9
(2,902 Views)

Hello Ian,

To run your code I will need you to post your 'Data from Rig V2' VI.

Cheers

Tom
NIUK

0 Kudos
Message 4 of 9
(2,881 Views)

Thanks Tom,

I've attached it along with the subVI it uses as well

Cheers,

Ian

Download All
0 Kudos
Message 5 of 9
(2,878 Views)
Hello Ian,
 
It looks to me like the event structure is causing you problems because until an event is registered the rest of the while loop (which has a data dependancy on the event structure) will not execute. It would be an idea to create an event for the Mobility vs Frequency graph, so when that is clicked on, the cusor properties can then be handled without the data being reacquired. This will mean you will have to change your code to handle this, but it will be relatively simple.
 
Hope this helps!

Tom
NIUK
Message 6 of 9
(2,875 Views)
Hi Tom,
 
I've had a go at the way you suggested (or at least what I think you were getting at) but it's still got the jerky refresh rate. Would you have done it differently to the version I've attached?
 
Thanks again for your help,
 
Ian
0 Kudos
Message 7 of 9
(2,873 Views)

Hello Ian,

It is generally a bad idea to have two event structures within the same while loop so use one event structure and create different event cases in that one structure. Also you may want to put a timeout by wiring a millisecond constant into the top right hand corner of the event structure named 'Event Timeout.' The graph appears jerky because it will only plot a point when the while loop iterates, which at the moment is being held up by the event structure. If you wire a 200 constant to the Event Timeout terminal the while loop will be held up for 200 ms before passing through the 'Timeout' case and then executing the remainder of its code.

Let me know if this helps.

Tom
NIUK

Message 8 of 9
(2,869 Views)
Your help was brilliant - thanks a lot Smiley Very Happy
 
Here is how I implemented it in the end - having 2 stop buttons was a bit of a botch, but it works well with the additional loop for if the user wants to acquire data again with different input parameters.
 
Cheers again,
 
Ian
0 Kudos
Message 9 of 9
(2,848 Views)