11-03-2012 01:20 PM
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.
Solved! Go to Solution.
11-03-2012 01:29 PM
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.
11-04-2012 11:16 AM
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.
11-05-2012 02:23 PM
Thank you very much, I will try to have a version of my code uploaded after I finish it.