LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I want to create a counter for each time my loop finishes

Solved!
Go to solution

Hi 🙂 My program runs for a given time and writes data to a file. After the time has been reached the program goes into a "pause" loop, where nothing happens, and then begins running again. I want to be able to decide have many times it runs the program. I know I can use a for loop, but I want to try to use some sort of counter as you can see in the attachment file below. After the counter has reached the given value, then the entire program stops.

 

Thanks!

0 Kudos
Message 1 of 5
(2,813 Views)
Solution
Accepted by topic author kristaje

Why don't you do what you are already showing with a shift register, increment, and comparison in the while loop?

 

(You should make those values integers rather than double since you are just counting.  You can run into problems when when comparing floating point numbers (doubles) for equality.)

0 Kudos
Message 2 of 5
(2,808 Views)
Solution
Accepted by topic author kristaje

Your counter belongs in the state machine loop.  You might want to add a state to increment and check to see if you are complete.


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 3 of 5
(2,807 Views)

Hi! Thank you for the tips. I still can't manage to figure out the solution. I added the loop counter as a new state. When we get to "Count", the value should begin at 0 and add 1 for each time it executes. Right now it adds the same value as my "Number of intervals" control is set to. I want it to return back to "Collect data" after adding "1".

 

Thank you

0 Kudos
Message 4 of 5
(2,718 Views)

There is no reason to have the loop inside of the "Count" case.  Your "loop count" should be a shift register on the main 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 5
(2,711 Views)