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.
Put it all in the timed loop.
Remove the Stop Locals and wire directly from the Stop control.
Remove the WEQ "x1"
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.
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?
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.
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?
Are both loops running, or has an earlier read of Stop made one loop stop after 1st loop? Check in highlight mode.
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.