LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Code running after while loop finishes

Hi all, I'm pretty new to Labview, we've been learning it in my freshman engineering class to be able to code the Lego Mindstorm EV3 robot. I'm currently trying to have a portion of code execute after the while loop finishes but the part of the code just executes the second I start it. How do I avoid this? The while loop stops on condition that the robot gets within 10 cm and then I want the next portion to execute which will power the secondary motor. Just whenever I start it, the secondary motor goes first and then doesnt execute the while loop at all. Thank you.

0 Kudos
Message 1 of 6
(2,330 Views)

If you don't show your code, all we can do is guess. 

 

LabVIEW is based on data flow, and execution order is determined by data dependency, not by arrangement on the diagram.

 

Please show us your code so we can give specific advice.

0 Kudos
Message 2 of 6
(2,283 Views)

One of the first things you should have learned about LabVIEW is the Principle of Data Flow -- a Structure (which can be anything on the Structures Palette, a LabVIEW function, or a VI/sub-VI) cannot start to run until all of its Inputs have data (which it gets from an attached Control or from another Structure), and nothing appears on its outputs (to go to another Structure or to an Indicator) until whatever code is inside the Structure finishes executing.  

 

If you haven't learned this, go back to the Tutorials.  Don't try to write any more LabVIEW code until you know about Data Flow (and the importance of Wires].

 

Bob Schor

0 Kudos
Message 3 of 6
(2,227 Views)

Hi thank you for the response. I got it working after I ran it a few times. I didn’t change anything it just didn’t run right the first 2 times but now it is

0 Kudos
Message 4 of 6
(2,223 Views)

@yaypa wrote:

Hi thank you for the response. I got it working after I ran it a few times. I didn’t change anything it just didn’t run right the first 2 times but now it is


That sounds really sketchy, like race conditions, uninitialized shift registers, etc. Code should run the same all the time. You should post your code.

 

mcduff

0 Kudos
Message 5 of 6
(2,213 Views)

@yaypa wrote:

Hi thank you for the response. I got it working after I ran it a few times. I didn’t change anything it just didn’t run right the first 2 times but now it is


I'm totally frightened by that comment.  What makes you think it didn't just work by accident?  If you tried to start your car 3 times and it started once, don't you think there might be something wrong?

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.
0 Kudos
Message 6 of 6
(2,205 Views)