LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Arrays on front panel being overridden each loop so can't manually input new values

Hey,

I'm a bit stumped and hoping someone out there can help. I'm simply trying to make it possible to allow the user to update an array on the front panel manually at any point during a while loop without the new values being overriden.  I made a small example which is attached.  Right now an array is initialized, placed into a while loop, and then if the user wants the array is multiplied by 2, then the array on the front panel is updated with the values that are now multiplied by 2.  If you want to manually change one of these numbers on the front panel however, the array immediatley resets to the previous value and it can't be done.  In example 2 I found that if I put a delay on the write to array section, I was able to get my manually inputted value to stay most of the time because the loop had a chance to "catch" it I think.  Unfortunately at work we don't have a package that has an event structure.  I'm pretty sure with an event structure I could have simply set it to update the array when a value is changed.  I hope that explanation made some sense.  Any ideas appreciated, thanks in advance for any help!

Download All
0 Kudos
Message 1 of 6
(2,792 Views)

Here's just a pic of example 2 that works intermittenly.  

0 Kudos
Message 2 of 6
(2,790 Views)

I've pretty much decided that what I was asking for is probably not actually even possible. As a workaround I have decided to build my main array using other arrays on the front panel that send data to the main array.  This way the main array is not responsible for input from the user and constantly being udpated with new calculation data, the two functions are separate.  I'd still be curious if anyone knew of a way to make both happen simultaneously though!

0 Kudos
Message 3 of 6
(2,785 Views)

Correct.  It's not possible.  You've basically created a race condition where you are trying to get the data you entered to stick in the very slight interval of time where the local variable has been written to, but the control has not been read yet in the next loop iteration.  The reason the second one works intermittently is that you've put in a 1 second delay which will effectively happen after the local variable has been updated, giving you a 1 second window to sneak in your updates.

 

Having a separate input is what you need.  You might also find event structures useful.

Message 4 of 6
(2,773 Views)

I agree, its impossible but for a good reason! It's too bad my work didn't buy the more expensive edition of labview with event structures but I'm making due.  Seperate inputs worked perfectly.

0 Kudos
Message 5 of 6
(2,749 Views)

> I've pretty much decided that what I was asking for is probably not actually even possible.

 

This is an old thread, but I highly object against statements such as "impossible". 😄

 

LabVIEW is a full featured programming language. Yes, an event structure would make things easier, but even without it, you could for example try something like in the attached example. Seems to work just fine. Modify as needed.

Message 6 of 6
(2,716 Views)