06-14-2010 01:48 PM
I am new to Labview and I am attempting to use an angular encoder as a type of switch.
I want to take continuous measurements of the encoder angle and turn on an analog output signal whenever a certain angle is reached. When the encoder drops below that angle, I need the signal to be turned off.
To do this I am attempting to run two parallel while loops. One measures the angle of the encoder while the second creates the output signal. What I want to do is put a logical statement in the measuring loop that will register 'true' if the maximum angle is reached. I am attempting to pass this 'true' statement to the signal generation loop as a kind of trigger to turn on (using an case structure and 'DAQmx Start Task.vi') the output. The issue I am having is that the 'true' statement can't leave the measuring loop until the loop is complete. But since I am running this continuously, the loop never ends. Thanks.
Solved! Go to Solution.
06-14-2010 02:04 PM
Create a local variable of the boolean in concern. Right click on the local and select Change to Read. Put this local inside the other loop. So you have one loop that writes to the boolean and one loop that reads from the local. Now you can remove the wire that comes from one loop and feeds the other. Then your loops will run in parallel (if there are no other data dependencies between the two loops).
As alternatives to local variables, you can use a queue to pass data from one loop to another. One loop (the producer) will write to the queue. The other loop (the consumer) will read from the queue. See examples on Producer-Consumer architecture for more info.
06-14-2010 03:42 PM