From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
08-28-2020 07:56 AM
Hi,
I have made a simple user interface with several buttons, arrays, numeric input fields etc...
I wanted to make one if the buttons a start button, meaning only after being pressed the rest of the code can be executed.
For that matter i connected a button to a conditional structure and inserted the rest of the code into a while loop (separate from the if structure). then i connected the output of the button to the top condition of the while loop.
The code does what i want, except for the fact that when i change the button's state during run it does not respond, so if i start with the button on the code goes into the while loop, if i click on it while running it shuts the function half way through (as i want at the moment), but if i click on it again it indicates that it is on, however it does not execute the code again.
same goes if i start with the button off - if i turn it on while running it will not respond.
Any idea what could be the reason? is it the code? is something crooked in the way LV works on my computer?
Thanks in advance.
p.s.
1) I use conditional with the button cause i want to open a session in the future when the button is pressed
2) i have no access to my code until sunday, and i hope for help before i arrive to work, so i will send a picture of the code as soon as i can.
08-28-2020 08:41 AM
The reason is that you coded it incorrectly. Just do it right, and it will work fine. I didn't try to reconstruct your code from your description; and neither will anyone else. Post your VI if you want anyone to help fix it.
08-28-2020 10:22 AM
@Aqua- wrote:
I wanted to make one if the buttons a start button, meaning only after being pressed the rest of the code can be executed.
Yes, we cannot troubleshoot verbal descriptions. The correct way is to use a state machine architecture where the initial idle condition is just one of the possible states.
@Aqua- wrote:
2) i have no access to my code until sunday, and i hope for help before i arrive to work, so i will send a picture of the code as soon as i can.
We actually strongly prefer if you could attach the actual VI (or a simplified version). Pictures are hard to debug and often too ambiguous.
08-28-2020 06:38 PM
Yes, we cannot troubleshoot verbal descriptions.
We actually strongly prefer if you could attach the actual VI (or a simplified version). Pictures are hard to debug and often too ambiguous.
Yeah i understand really... I will send here the VI as soon as i can, thanks
08-30-2020 03:13 AM
hi. so i am attaching my VI. I have improved my code, yet it still all depends on whether the "initialize" button is pressed before i start the program. if it is then the relative move works, if it is not pressed then no matter what i do the relative mode doesnt work
08-30-2020 11:12 AM
Hi Aqua,
@Aqua- wrote:
it still all depends on whether the "initialize" button is pressed before i start the program. if it is then the relative move works, if it is not pressed then no matter what i do the relative mode doesnt work
This is one the "other problems" in your VI as mentioned in your other thread!
What will happen to the big WHILE loop when "initialize" is not TRUE when you run your VI?
The VI does exactly what YOU have programmed to do!
09-01-2020 01:51 PM
@GerdW wrote:
Hi Aqua,
@Aqua- wrote:
it still all depends on whether the "initialize" button is pressed before i start the program. if it is then the relative move works, if it is not pressed then no matter what i do the relative mode doesnt work
This is one the "other problems" in your VI as mentioned in your other thread!
What will happen to the big WHILE loop when "initialize" is not TRUE when you run your VI?
The VI does exactly what YOU have programmed to do!
i get your point here, and when i follow the flow of my code with a breakpoint it is indeed in an infinite loop, however i dont get it.
The LV documentation states that the continue if true clause executes as long as 'True' is being sent to the loop.
Now:
1) if i start the program with a 'True' everything works well. if during run i change the button to 'False' the loop exits, but if i try to press it again to 'True' it will not work.
2) if i start the program with 'False' the program wont go into the loop, and then if i press the button again it still won't go inside.
What i conclude is that outside the loop, even on continuous run the change of the button outside the loop does not work and im not sure why
09-01-2020 01:59 PM - edited 09-01-2020 02:02 PM
Hi Aqua,
you still don't understand the basic THINK DATAFLOW principle of LabVIEW…
This is the core problem in the VI:
@Aqua- wrote:
The LV documentation states that the continue if true clause executes as long as 'True' is being sent to the loop.
Now:
1) if i start the program with a 'True' everything works well. if during run i change the button to 'False' the loop exits, but if i try to press it again to 'True' it will not work.
2) if i start the program with 'False' the program wont go into the loop, and then if i press the button again it still won't go inside.
What i conclude is that outside the loop, even on continuous run the change of the button outside the loop does not work and im not sure why
Your conclusion is wrong…
When the button is TRUE before the loop is started then the loop will run forever.
When the button is FALSE before the loop is started then the loop will iterate just once (it's a while loop!).
All this is dictated by THINK DATAFLOW!
Your case 1) cannot happen: the value of the button is only read once before the loop. No matter how often you switch the button it will NOT affect the iterations of the loop anymore!
09-01-2020 03:27 PM - edited 09-01-2020 03:31 PM
To add what GerdW stated, you should...
Beyond that, it looks like you have is a Simple State Machine. Look into that once you have this working the way you want.
09-01-2020 03:34 PM - edited 09-01-2020 03:35 PM
I also wired across the Initialize and Home button because you didn't need those Boolean constants. The button is the Boolean constant. Remember, DATAFLOW.