10-20-2016 08:40 AM
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!
Solved! Go to Solution.
10-20-2016 08:49 AM
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.)
10-20-2016 08:51 AM
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.
10-24-2016 07:52 AM - edited 10-24-2016 07:53 AM
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
10-24-2016 08:13 AM
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.