LabVIEW for LEGO MINDSTORMS and LabVIEW for Education

Showing results for 
Search instead for 
Did you mean: 

Yet another bluetooth PC/NXT

Hey tnz,


The way you have your while loops set up in the second screen shot, with False constants wired into the stop terminal means that neither while loop will ever exit. The outerloop will enter its first iteration and start executing the inner while loop which will continuously execute. So you have a situation where your outer while loop is stuck on its first iteration and the inner loop is running forever.

Because of this, the case structure will never execute because it requires that blue wire which coming from the while loops that never exit.


Are you familiar with shift registers? They are used to pass data from one interation of a while loop to the next. You may consider using shift registers to pass references to your mailboxes to the following iterations of the while loop. Here is an article about Passing Data Between Loop Iterations in LabVIEW 


0 Kudos
Message 11 of 23

Thanks samazing,


Really helpfull, now I understand loops in LV a bit better, but I think the problem is in passing data to and out of case structure. I've tried Shift Registers, but still no data to case structure which is defing for robot behavior. Mb my approach with two parallel infinite loops not possible in LV, but why compiler allow me then)


0 Kudos
Message 12 of 23



LabVIEW does allow for parallel infinite loops - the problem with your code is that you are never actually entering (or starting) your second (lower) loop. This is due to the data-flow nature of LabVIEW. Your lower while loop will not begin to execute until it has received all of its inputs. At this point, you are running into the same problem you had in the last peice of code. The second while loop depends on that blue wire (integer) that is coming from the top while loop. Because the top while loop never exits, that peice of data (the blue wire) never gets to the second while loop, and the second while loop never begins.

0 Kudos
Message 13 of 23

Ok, now I see.. Thanks samazing!


I was thinking that shift register can pass a data outside running loop.. No it's clear, however may you or somebody, patient enough to read this, suggest a proper approach to deal with logic?

The problem is that If I use case structure inside the loop - it breaks data exchange. If I try to put case structure outside - I never enter )

0 Kudos
Message 14 of 23

Using a case structure inside a loop shouldn't effect your data exchange. Unfortunetly I am not very familiar with the MindStorms API; after you you wire the pink reference wire into the case structure, should you also wire it into the node that is taking in 'mailbox 1'?

0 Kudos
Message 15 of 23

Me too.. This is the first time I ever try LabView. Keep diging, but some obvious things are not obvious to me at the moment. I know that pink wires used to define logic (or oreder of execution), but I don't understand their meaning inside a loop. Ok if I have few nodes executed one after another inside it's clear. But should I pass pink wire from outside of the loop? Whats about parallel lines of nodes inside the loop?

0 Kudos
Message 16 of 23

Can you elaborate on what you mean by when you use a case structure it 'breaks data exchange'?

I think you should pass the pink wire into the case structure. I do not understand your last question about parallel lines of notes inside the loop however.


0 Kudos
Message 17 of 23




I've tried to connect pink wire everywhere..) In this example when case structure gets "1" and start to execute I got "-1" in both mailbox 1 and 2. Mb it's bacause I'm using Wait for Time node inside?

0 Kudos
Message 18 of 23

Can you place a probe on the pink wire to see what data is there? You can do that by right clicking the wire and seleting probe.


Have you tried running this code without the case structure? Such that you always enter mailbox 1 and 2

0 Kudos
Message 19 of 23

Trying to troubleshoot code from a picture is very difficult.  It's a lot like knowing your car isn't turning the way you think it should and taking the steering wheel into the mechanic.  They might look at it and it may appear perfect.  But, they can't really provide any insight into what you're seeing.  You'll help everyone out by posting the VI itself.


You're showing us the case for '1' but not explaining why you're sure it's running this case or what you'd expect in other cases.  Do you have any cases where the input is -1 and it's possible those are running?


The pink wire is a "cluster."  It's very important to what you're doing.  If you don't pass it to everything you want to run, you're not sending information about your NXT to the VIs so they can't act the way you'd want them to. 


I'd try what samazing suggested and try to run this code without the case structure.  It looks like we're pulling the first byte off the I2C communication and trusting it's a 1.


The wait for time doesn't change the data that's on the wire going into the Mailbox.  It'll have nothing to do with the question you're asking.  We want to ensure we're running this case.  We also probably want to take a look at the data coming off the I2C piece.  You can do this with probes or by creating indicators to view the data.  I don't see where you're writing to Port 2 anywhere.  You're reading that value and sending it to Mailbox 2.  I can't provide any insight into why that would be whatever value it is.  Where are you intending to write this value?

0 Kudos
Message 20 of 23