03-01-2019 04:53 AM
Hi,
I would like my stop button to essentially "jump" out of 2 loops and execute the code at the end. I tried a case structure but this only worked to exit one for loop and not both of them.
Additionally, i also read theres a way to run program on startup instead of pressing the run button, how is this done?
Thanks
Solved! Go to Solution.
03-01-2019 05:05 AM
03-01-2019 05:08 AM
So are you looking to end your loop early? If that is the case, then you can right-click on your FOR loop and then enable the Conditional Terminal.
@newman3108 wrote:Additionally, i also read theres a way to run program on startup instead of pressing the run button, how is this done?
Build an executable.
03-01-2019 12:35 PM - edited 03-01-2019 12:37 PM
@newman3108 wrote:Additionally, i also read theres a way to run program on startup instead of pressing the run button, how is this done?
While building an executable is the preferred way (but you need the app builder for that!), there is also a vi option to "run when opened". (This works when opening from windows explorer, but not from within a project)
03-01-2019 01:14 PM - edited 03-04-2019 10:35 AM
A few generic comments for your VI:
03-04-2019 03:52 AM
Thanks for your reply,
Cheers
03-04-2019 10:48 AM - edited 03-04-2019 10:51 AM
@newman3108 wrote:
3. Is switch when pressed not the correct action?
Typically the correct action is "latch when released". This way the button is normally OFF and when pressed will remain TRUE until is is read by the code, at which time it will automatically return to FALSE. (No way for the code to miss it as e.g. with "switch until released" and no need to reset it as e.g. with "switch when pressed")
@newman3108 wrote:4. Ive just read your greedy loops bit, is the solution to just as a wait in?
Yes, that's the "bandaid" solution. A proper state machine is preferred. A greedy loop spins many millions of times per second, consuming 100% of a CPU core, draining your battery, stressing the thermal management of the CPU, and starving all other processes running. Even a 1ms wait would reduce the CPU use to a tiny fraction of a %. Typically you make it longer, e.g. 50ms.
@newman3108 wrote:6. What about +1?