LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem re-entering inner while loop

I have a While Loop that reads data from the serial port. I then have another While Loop within this that processes the data received from the port one line at a time - an iteration for each line. The inner loop uses the match pattern function and extracts values before passing on the 'after substring' to be processed in the next iteration. The condition of the inner loop is stop when this string length is 0. This works until the first time the string is 0 then I cannot re-enter the inner loop when more data needs processing. I think it must be the loop condition but I am relatively new to labview and am not sure the best way round it! Any suggestions would be great 🙂
 
Thanks, Liz
0 Kudos
Message 1 of 8
(3,206 Views)

Hi Liz,

maybe there are sometimes no bytes on the serial port. I recommend to use a case struture and only run into the loop if you have received data. Instead of using a while loop to split the string you can use the "spreadsheet string to array" function.

Mike

0 Kudos
Message 2 of 8
(3,201 Views)

Hi Mike,

I have run in debug and as I step through I can see that there are bytes at the port but it just seems to miss out the loop which is what makes me thing it is the condition I have set.

I will put a case structure around the loop as suggested for when there is no serial data.

Cheers, Liz

0 Kudos
Message 3 of 8
(3,198 Views)
Looking quickly at your code, did you know that if you right-click a flat sequence structure, you can add frames to that structure? you don't have to have all those structures you have in the inner loop, you could have one, with four frames.  (Although, a lot of that stuff will be sequential on its own due to dataflow, even without the structures).
 
Looking at the functionallity though, the inner while loop will always run at least once, if it doesn't, maybe your outer loop isn't running enough?  Any chance you need to send R with a return/enter afterwards at the end of the outer loop?  I tend to forget to end my lines with them in serial com.  (In hyperterminal for instance, if you hit R <enter>, you will need to also add in the <enter> in labview, if you just hit R and it goes, then I don't know.)


Message Edited by Britoa on 03-06-2008 06:27 AM
0 Kudos
Message 4 of 8
(3,197 Views)
Thanks for the info on frames - I am just getting into labview which is why the code looks a bit messy, but hadn't realised that so thats great 🙂
 
The 'R'  is just a command sent to the infusion pump on completion of the test.
0 Kudos
Message 5 of 8
(3,188 Views)

Hi Liz,

this should make what you want.

Mike

0 Kudos
Message 6 of 8
(3,185 Views)
Thanks Mike, will try that 🙂
0 Kudos
Message 7 of 8
(3,182 Views)
Looking at mikes vi that he gave you, your times will be off.  You're going to want to wire something (anything) from the loops you are timing into the flat structures that are getting the time.  Even if you don't use the value you are passing into it, the structure will not run until all the values are ready. 
 
For instance: wire the string/shift register in the upper right of your block diagram into the sequence in that corner.  Then, the time will only be checked when the loop is complete.
0 Kudos
Message 8 of 8
(3,143 Views)