LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Percentage Indicator or Progress bar in a while loop

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,

0 Kudos
Message 1 of 6
(5,122 Views)

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.

0 Kudos
Message 2 of 6
(5,119 Views)

Look at you block diagram and use the highlight execution. Run your vi. This shows the data flow of your Vi. HLE.png

0 Kudos
Message 3 of 6
(5,106 Views)

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.

 

0 Kudos
Message 4 of 6
(5,070 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 6
(5,064 Views)

@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.)

0 Kudos
Message 6 of 6
(5,060 Views)