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: 

Front Panel local variable delays

Hi,

I have a program which runs a few while loops in parallel. One while loop increments a text box integer (1)  on the front panel, whenever it receives a sync pulse via  a DIO card. Another while loop allows the user to move a slide bar (2) using keystrokes 1 and 3. The last while loop saves the integer (1) and the slide bar value (2) on a file, by refering to the local variables i created for (1) and (2).

 Now, I have seen many timing discrepancies between values (1) and (2) in my output file. I suspect that it is because I am using variables which communicate via the front panel. So if the front panel is lagging behing the block diagram, I get old values of  (1) and (2) which are not synchronized.

Is there a more time efficient and reliable way of implementing this? without wiring my while loops together? (I really want my while loops to be as independent as possible)

Thanks for the help,
Aleks.
0 Kudos
Message 1 of 5
(2,456 Views)

You are right, this is typical of a race condition with local variables. The local is read before the control is updated.

Do not use locals. Go to the Data communication subpalette (LV 😎 or Advanced subpalette (LV 7 and before) and have a look at the synchronize functions. Study the corresponding examples shipped with LabVIEW.

Alternatively, consider using the event structure in a single loop.

Chilly Charly    (aka CC)

         E-List Master - Kudos glutton - Press the yellow button on the left...
        
Message 2 of 5
(2,454 Views)
Hi,
Thanks for the reply. I looked at the synchronize functions in Labview 7.1. I'll have to learn more about them.
But as a starter, you say not to use locals... so what form of variables should I use? Or should I wire everything directly in the block diagram from while loop to while loop. How will this effect the execution of the while loops, will one while loop become dependent of the other? That is, if the master while loop stops execution for a second, will the slave also wait a second before executing?
Thanks
Aleks.
0 Kudos
Message 3 of 5
(2,436 Views)
I forgot to mention that the event structure is in a seperate while loop, running in parallel with the others.

The only other thing in the while loop is a local variable for the STOP button. Is this bad? Should I send a wire into the while loop instead of using a local variable within it?

Thanks again

Aleks.
0 Kudos
Message 4 of 5
(2,436 Views)
Locals are allright for a stop button. They are also OK as long as you understand what a race condition is.
You can pass data from one loop to the other using a queue or a notifier (synchronize sub-palette).

Message Edité par chilly charly le 05-31-2006 03:47 AM

Chilly Charly    (aka CC)

         E-List Master - Kudos glutton - Press the yellow button on the left...
        
Message 5 of 5
(2,432 Views)