07-01-2017 08:03 AM
Hello,
I would like to get help with the following programming case:
There are two loops : while loop and for loop running in parallel.
I would like to start the while loop with start of each iteration of for loop and then
stop the while loop at completion of each for loop iteration. A vi is attached.
Thank you.
07-01-2017 08:33 AM - edited 07-01-2017 08:34 AM
07-01-2017 09:07 AM
Why even have 2 loops? Why can't you just put all of your logic in the FOR loop? What else is happening in your While loop?
07-01-2017 11:11 AM
Your FOR loop iteration will complete in nanoseconds, so the while loop will barely able to do a single iteration during that time. This make your question not reasonable.
Why don't you take a step back and explain what the program is supposed to do? How do you use it? What should happen and what would you like to see when it runs?
The only important thing is what the user sees, now how it is implemented under the hood.
07-01-2017 02:59 PM
Here is what the program is supposed to do:
The for loop: runs scans (iterations) from instr 1 while the while loop collects data from instr 2.
Each scan runs for ~ 45 min.
At end of scan, all the data from the while loop gets dumped into a file whose contents are: scan array from instr1, data array of instr2.
Then a new pair of scan (for loop iteration) of instr1 and data from instr 2 (while loop resets) begins.
When trying notifier I could notify the while loop to stop after a scan but could not reset the notifier after scan got completed to restart while loop. (vi attached).
Thanks for your inputs.
07-01-2017 07:12 PM - edited 07-01-2017 07:19 PM
You cannot solve your problem by stacking more and more loops! Also, your notifier never makes it inside the loop, so it will be read once before the loop starts and then never again. The upper inner while loop will either stop after one iteration or continue forever, depending on the value of the notifier and outer while loop will depend on the initial error condition in the same way.
Your while loop in the FOR loop can be deleted and nothing would change. Why is it there? And please don't maximize the diagram and front panel to the screen. They can be small enough so you can see both.
You really need to start with a few more tutorials about the principles of dataflow. All you probably need is a simple state machine. Keep count of the iterations and switch states as needed for the functionality.