LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I update input values while the VI is running?

Solved!
Go to solution

Hi, for a project I'm involved in I am responsible for implementing code for a stepper motor. An issue I'm encountering is how to make an "update button", I have 5 input values that I need but is it possible to change the values without restarting the VI? Basically I'm looking for a way to update my variables and executing the same block of code every time.  

 

At first I thought about using a for loop and having each push of the update button be another iteration of the loop with the updated values but that doesn't seem to work, can someone point me in the right direction?

 

Thanks.

0 Kudos
Message 1 of 4
(5,108 Views)
Solution
Accepted by topic author songs

I believe a simple event structure will get you going. Check out the attached VI. If you need additional help, please post your code. Note this code uses a button (Update) to update all 5 numerical inputs. You can simply right-click the event structure and select 'Edit events handled by this case' to make it so that changing any of the numerical inputs generates the event.

Charles Chickering
Architecture is art with rules.

...and the rules are more like guidelines
0 Kudos
Message 2 of 4
(5,105 Views)

Charles's solution should work just fine, but there are many othere ways.


@songs wrote:

Basically I'm looking for a way to update my variables and executing the same block of code every time.  


They are controls, not variables. Even the simplest toplevel program should have a while loop around the bulk of the code. If your updated controls are not read properly, it could mean that the terminals are outside the while loop, for example.


@songs wrote:

At first I thought about using a for loop and having each push of the update button be another iteration of the loop with the updated values but that doesn't seem to work, can someone point me in the right direction?


If somehing is not working right, you should always attach your VI so we can pinpoint the problem.

 

You should really do a few tutorials. A FOR loop is only appropriate if you know the expected final number of iterations before the loop starts. In all other cases, you need a WHILE loop.

Message 3 of 4
(5,072 Views)

Thank you very much, I will try to have a version of my code uploaded after I finish it. 

0 Kudos
Message 4 of 4
(5,019 Views)