06-10-2010 12:59 PM
Thanks for all the great information, unfortunately I don't know how to go about making the necessary changes. Do I just pull the initiate and close functions out of the outermost while loop? I also don't know how to place a "wait" command on the while loop so that it doesn't repeat until after an image has been saved.
I looked at the CPU performance while it was running and it was at 80% and that was while I didn't even have a camera hooked to it so that it was actually acquiring an image at the time.
06-10-2010 01:24 PM
Yes. Pull the Init before the while loop. Then reconnect the wires going to the next function so that they create tunnels into the while loop. Put the Close after the while loop. Reconnect the wires from the previous function to the close so that there are tunnels going out of the while loop.
The wait statement is in the timing palette and looks like a wristwatch. Wire a value into it. The value is how long the loop must wait before iterating again in milliseconds. So a 100 means it will wait at least 100 milliseconds before starting again. It will take longer than that if the other code in the loop takes longer. It is a way to throttle the loop so that you don't burn up CPU resources so you don't execute a loop thousands of times per second if the loop isn't doing any real work. For example, a while loop that does nothing but wait for a button to be pressed will run superfast just polling the status of the button over and over again. It can eat up so many CPU cycles that it prevents Windows from doing other work such as redrawing screens, handling mouse movements, stuff like that.
Search for "greedy loop".
Honestly, I haven't seen an issue any more with greedy loops on modern PC's with multiple processors. Back in LV 7.1 days with single core CPU's, one of the first things I learned about loops was the need for the wait statement because without it, the mouse seemed sluggish.