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.
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.
05-13-2014 09:58 AM
Hello.
I want to execute a block of code with the push of a button but I cannot find the solution.
Attached is my vi. Any help is welcomed.
Thank you.
Solved! Go to Solution.
05-13-2014 10:09 AM
05-13-2014 10:12 AM
Hello and thank you for the quick reply.
I do not understand what you mean.
I do have both cases of the case structure covered, yet, it is not working.
Thanks again.
Vasilis.
05-13-2014 10:13 AM
05-13-2014 10:16 AM
Hello again!
It is attached in my first post, but I am attaching it again in case there is a problem.
Thanks.
Vasilis.
05-13-2014 10:19 AM
05-13-2014 10:22 AM - edited 05-13-2014 10:27 AM
Hello vakost;
A few points:
- The mechanical action of your Boolean is set to "Latch when Released". This means it will reset to False after being read once.
- You have no software control timing in your loop, this is what's known as a "greedy loop" and will execute as fast as it possibly can
Due to this, your True case will execute, but only once when you release the button, and the button will be reset to False before you likely see it because the loop is probably running many thousands of times per second. If you turn on execution highlighting to slow down the VI's execution to something you can observe, you should see the Boolean indicator turn on briefly before resetting. You should still place a wait function inside your loop to slow things down to a reasonable speed, however.
A few other tips:
- You don't need to place the Boolean indicator inside the case structure if you want to update it in either case (you're using a value property node in the other case) - just place it outside the structure and wire the value you want to set out of the case
- You've created a while loop with no stop condition, and the VI has to be aborted to stop it. Generally you'll want to give the user a stop button to exit the VI, aborting is almost never a good idea.
Regards,
- You don't really need the case structure in this circumstance, you could just wire the Boolean OK button directly to the indicator. My impression is that this is just a demonstrative example or experiment in how case structures work, though, so that's probably alright.
Hope that helps!
05-13-2014 10:24 AM
!!
I am so sorry! I didn't even notice! I don't have an earliest edition but I am attaching the pictures.
Thanks.
05-13-2014 10:24 AM - edited 05-13-2014 10:25 AM
Do you have a while loop around the case structure so that execution continues to run, checking the boolean for a new value?
EDIT: picture attached now.
I can't open VI either.
05-13-2014 10:25 AM
Your VI is in LabVIEW 2013, in case you don't know.
I would recommend to start here. There are way too many things wrong with your code, mostly misconceptions.
(Why do you think you need a value property node? Simply connect the LED to the switch. Why do you think you need to poll that switch as fast as the computer allows, millions of times per second, consuming all CPU? How do you stop the VI? You don't see anything because your button is latch action, meaning the LED only goes on for a nanosecond when you press it. Change the machanical action!, slow down the loop with a small wait statement, etc.!)