LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why is the first Waypoint being skipped, even though the code written codes conditions for incrementing the waypoint are not being met?

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:-

0 Kudos
Message 1 of 3
(2,069 Views)

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.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 2 of 3
(2,064 Views)

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

0 Kudos
Message 3 of 3
(2,055 Views)