LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Queue with while loop executed depending times

Solved!
Go to solution

Hello,

 

My problem is that second while loop is executed so many times, depending on the data lengt passed through queue. So dequeue element wont't work outside while loop, but if dequeue element is in while loop, each time while loop is suppose to executed  (let sey 6 times) data from a new queue is used ( while loop execute once), so I am processing only one part of the data each time not the wholle "message". First while loop is time besed. It is important to me that while loop is executed multiple times and not time based. How can I sole this.

Thank You.

0 Kudos
Message 1 of 10
(3,451 Views)

https://forums.ni.com/t5/Community-Documents/Unofficial-Forum-Rules-and-Guidelines/ta-p/3536495

please read this


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 2 of 10
(3,446 Views)

the dequeue has to be inside a loop, otherwise you will only get elements once.

 


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 3 of 10
(3,444 Views)

I understand that queue is not working outside the loop, but how can I make my program work without queue, simply as posible. Sorry if it has been aswerewd but i didn't find solution.

Thank you.

 

Here is whole program, please ignore error wiring an lack of subVI's.

0 Kudos
Message 4 of 10
(3,437 Views)

sorry can't open .. am still on 2016

if you'd like you could back save "File"->"Save for Previous Version"

 

regards


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 5 of 10
(3,433 Views)

sorry, here is 2015 version.

0 Kudos
Message 6 of 10
(3,426 Views)
Solution
Accepted by topic author jef12

from the looks of it you could do this all as a state machine in the first loop.

put all the logic from loop2 and 3 in the timeout case and wire some timeout value to the event structure.

the VISA write should be only triggered when you push one of your buttons, so wrap it with a case structure and wire a boolean coming from the event cases where you want to write.

 

you should find a way to get rid of the "Bytes at Port" and make use of a termination character instead.

 

 


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 7 of 10
(3,408 Views)
Solution
Accepted by topic author jef12

First, dequeue in a while loop.  Use a for loop auto indexed on the queue data array inside the while loop.  

 

Alternately, this sounds like a great place to use a "Channel Wire"


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 10
(3,405 Views)

Thank you for your help.

0 Kudos
Message 9 of 10
(3,378 Views)

you are welcome :cheers:


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 10 of 10
(3,374 Views)