10-06-2014 03:27 AM
Hi all!
I m new to labview and hence I have put up a messy code. My intention is to generate values using a sine wave and feed that to a stepper motor. I have put the sine wave in a while loop and the stepper motor control in a timed loop and used a local variable to share the data. The main issue I faced was that the local variable data wasnt displaying properly. After reading through many posts I guess it has something to do with the race condition. I tried indexing it through wiriring but I couldnt do so. It would be great if someone could help me find a way to share the data in the while loop to the timed loop without any loss.
Cheers!
10-06-2014 04:07 AM
Put it all in the timed loop.
Remove the Stop Locals and wire directly from the Stop control.
Remove the WEQ "x1"
/Y
10-06-2014 04:24 AM
Thanks a lot! If I the while loop contents into the timed loop do I need to remove the local variable "Element" also? That is the one that is giving me the issues.
10-06-2014 04:28 AM
*move the while loop contents
10-06-2014 04:33 AM
10-06-2014 04:34 AM
I tried doing it but the timing of the loop gets affected. I guess its because of the fact that the sine wave controls the execution timing of the timed loop, so moving the while loop contents didnt solve the problem. I want the while loop to be controlling the execution timing of the timed loop, so moving there wouldnt be ideal. Could there be any other possibility of operating the timer loop from a different loop without facing race conditions?
10-06-2014 04:44 AM
Since you only use 2 values from the sin-signal it shouldn't be a problem unless you've configured that express vi in some strange manner.
Otherwise you'll need some way to synch your loops, as sending events or Notifiers. However, if the waveform loop is slower than the timed loop you'll always run into problems.
/Y
10-06-2014 04:59 AM
Now I get it! While probing I always get values inside the while loop but for some odd reason the local variable always remains in the unexecuted state. So are you suggesting that I should try to increase the while loop speed? if so how do i do that? Or would it be okay if queues are used? Wont the while loop timing affect the queues?
10-06-2014 05:15 AM
Are both loops running, or has an earlier read of Stop made one loop stop after 1st loop? Check in highlight mode.
/Y
10-06-2014 06:51 AM
Can you post your actual VI and project? When dealing with Express VIs, we need to be able to see the settings in order to help troubleshoot your problems.