04-08-2013 04:49 PM
This is meant to be an imitation of an aircraft navigation system. I have set the first waypoint (with x,y values) and this appears as waypoint 0, as the initailizer sets it as such. However, when the programme is run and then navigation power turned on, the waypoint value seems to ignore the written code in the formula node and move straight onto the next waypoint...CONFUSED!
Here is the VI:-
04-08-2013 05:10 PM
Probably because you have about a zillion potential race conditions. Please read up on LabVIEW dataflow. You can start here, but google "LabVIEW Dataflow" for more info. Basically, most of your code can execute in any order it wants to.
04-08-2013 05:32 PM
To add some specifics to Bill's comment about race conditions, consider position_x. You set the value to zero outside the loop. However, it is conceivable, if unlikely, that the loop could start executing before the value is set by the outside the loop constant. Inside the loop the value is read at three places (or more) and written once. The write could occur before or after any of the reads except that the read at the Add input will definitely occur before the write due to the data dependency there.
Most likely all the reads occur almost immediately after an iteration starts. The write cannot occur until the left and middle formula nodes have completed, again due to data dependency.
The right formula node has no data dependency to the rest of the code in the loop and probably starts running early in each iteration. I doubt that is what you intended.
Also, it is not considered polite to post code with infinite loops. It is generally not a good idea to write or run code that way. As one contributor to the Forums has commented: "Stopping a VI with the Abort button is like using a tree to stop a car. It works but may have unintended consequences!"
My suggestion: Try to rewrite this VI without local variables and without formula nodes - use only LabVIEW math and logic functions and wires. There is nothing in there that cannot be done this way. It will show you how to use dataflow and probably solve the issues you are having.
Lynn