03-22-2017 03:59 PM - edited 03-22-2017 03:59 PM
Hello,
I tried using a horizontal indictor as a progress bar for a while loop execution. I've tried different scenarios and checked how the progress bar is behaving as I change things. It was displaying the progress of one iteration only then stopping while the loop is still working.
The image you see is after I took it out of the loop and added a constant (referring to the same wait time on the original loop (2000ms)). Now it still runs after the loop stops with a single iteration each time.
Would anyone help pointing me in the right direction please,
I was thinking about viewing as a percentage indicator, how would I approach a display in percentage?
Thank you,
03-22-2017 04:02 PM
DATA FLOW:
Your For Loop won't run until the while loop stops since it has wires running from the while loop to the for loop.
The progress indicator belongs in the while loopo.
One tricky think with percentages is that you need to know how many times the while loop is supposed to run so you know how far along you are. It looks like your while loop should also be a for loop since you can determine before it runs how many steps there will be.
03-22-2017 04:11 PM - edited 03-22-2017 04:13 PM
Look at you block diagram and use the highlight execution. Run your vi. This shows the data flow of your Vi.
03-22-2017 08:33 PM
Thanks to you both, definitely the way I constructed the 4-loop for the progress bar is wrong. I placed it inside the while loop and changed the time constant (2000) to just a property node (value). The motor now moves one iteration only and stops (and not just the progress bar) which is not ok.
Highlighting the execution shows me the freezing of the vi. Getting the 4-loop out of the while loop solves the freezing but the progress bar condition is the same.
03-22-2017 09:37 PM - edited 03-22-2017 09:37 PM
If you know the number of steps, you should use a FOR loop. Then my trick is to set the Scale->Range->Maximum property of the progress bar to be the number of steps-1. I then wire the terminal straight to the i terminal for the loop.
03-22-2017 09:57 PM
@AnnaDM wrote:
Thanks to you both, definitely the way I constructed the 4-loop for the progress bar is wrong. I placed it inside the while loop and changed the time constant (2000) to just a property node (value). The motor now moves one iteration only and stops (and not just the progress bar) which is not ok.
Highlighting the execution shows me the freezing of the vi. Getting the 4-loop out of the while loop solves the freezing but the progress bar condition is the same.
I didn't say to put the For Loop into the while loop. I said put the progress indicator part in the while loop. That means get rid of the For Loop completely.
(But I also said your while loop should probably also be a For Loop instead because you know how many steps you are going to have before you start the while loop.)