06-14-2013 02:19 PM
I am going to use KEITHLEY 2700 to read Multiple voltages. The program is designed as While loop -shown as loop (2), and it works fine itself. Now I am going to implement this program into another Routine, which includes While loop (1), Case structure and While loop (3).
The structure is attched.
Now the problem is that: when the case structure is true, loop (3) is supposed to run, but in reality due to the running of While loop (2), while loop (3) is not runing at all.
Is there any advice on this issue?
Thanks
06-14-2013 02:34 PM
Both loop 2 and loop 3 (and any other case in loop 1 need to have some kind of Wait. This allows parallel loops to get the resources to run. If loop 2 has no Wait, it is called a greedy loop and cna consume all available CPU resources so the other loop cannot run.
This kind of parallelism is common in LV and is one of the strengths of the language, but you do need to add the Waits. They are not automatically included because there are times when the programmer may need to get the maximum possible speed from a loop.
Lynn
06-14-2013 03:56 PM
Hi, Lynn. Thank you for your reply.
For While loop 1, it is only for initiation of some property nodes.
For the case structure inside loop 1, there is nothing for the false condition.
For loop 2, there is manual scanning rate control and run independently.
For loop 3, when case situation is true, it will run independently.
Loop 2 will run the same time as or run before loop 3.
How can I apply "Wait".
I am a beginner. Thank you
06-14-2013 04:49 PM
Loop 2 has a Wait Until Next ms Multiple, so it is fine. Put a Wait (ms) inside loop 3 and one inside the false case. The one inside the false case can have a value of 100-200 ms because it is waiting for the user to press the boolean button. The one inside loop 3 should be set according to the time it takes for one iteration of the loop. If loop 3 is reading 100 bytes from a serial port at 9600 baud, ~100 ms is fine. If it is doing something which must be very fast, set the wait value to be zero. A zero wait is not the same as not having a Wait function in the loop. A zero wait will still allow the other loop to execute.
If this does not solve the problem, please attach your VI so that we can see what it is actually doing.
Also, you do not need the sequence structure. They generally are not needed in well-written LV code.
Lynn
06-17-2013 05:59 PM
Hi PCASC
I will highly recommend you to first think how your application should run, draw a flow chart and from there determine what might be for your application, because from might perspective you might be able to do what you want a with a state machine is not recommended to use nested while loops.
Regards
Esteban R.