LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parallel while loops not executing

Solved!
Go to solution

Hello, I'm making a program to run a chamber, and I am running in to some trouble. I have 5 while loops that are supposed to be running in the main VI connected by queues. The first is checking the front panel for events. That drives the next two which are responsible for either issuing commands to run the chamber, or issuing commands to check data gathered. The fourth is running the chamber, and issuing commands to write the data gathered. The writing takes place in the last while loop. After all of the loops fire the first time, it seems like only the first and last still execute. Could someone take a look and tell me where I went wrong?  I'm still very new to labview, so I'm sure it's some little error or another.

 

Thanks,

Simon

0 Kudos
Message 1 of 10
(9,991 Views)

Loop 2-4 wont execute unless there's a new queue item queued up. There's no timeout on the 'Wait for queue' (timeout in ms).

Else the code looks very nice but i can add a couple of tips: There's no reason to wire an erorr (or other wire) both to the case '?' and as a separate wire for internal use, you can continue the wire from the '?'. On the same not i'd personally split the error wire inside the cases to keep it cleaner outside, but that's personal preferrence.

Since you already have an Exit case i'd wire True out from that to Stop Loop but i agree your version is very clear.

In the Chamber loop the sequence can easily be removed.

Very neat code.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 2 of 10
(9,981 Views)

Thanks for the tip about the "?" in the case. I wired the timeout cases of the preview and dequeue elements so that they wouldn't stop loop execution, but I still can't get 2-4 to execute. I need them to loop so they can provide commands to the chamber, even when there isn't an element in the queue. The queues should just control what they do while looping. Am I missing something?

 

Because I forgot to mention it earlier, we are talking about the "Main.vi"

 

Thanks,

Simon

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

So I've been looking at timed loops, would I be better off using these?

 

Thanks,
Simon

0 Kudos
Message 4 of 10
(9,945 Views)

One possibility.   Don't use shift registers for the error wires.  I know there are some people who claim that errors should have shift registers, but it is a bad idea and would cause problems unless you have a special method to handle errors.  Why?  Suppose you have an occasional error.  Something as simple as a timeout error during serial communication.  The error goes out on the wire and hits the shift register.  That puts the error at the beginning of the next loop iteration.  That error would prevent any code in the next loop iteration from executing because most functions are designed to not execute if there is an incoming error.  So one error winds up killing your LabVIEW execution from now until forever until you either stop your program, or do something special in it to handle and clear the error.

 

I don't think timed while loops will give you any better advantages than regular while loops for you application.

0 Kudos
Message 5 of 10
(9,940 Views)

Thanks, I didn't even think about shifting the error values.

 

Do you have any idea why some of the loops aren't executing?

 

Regards,

Simon

0 Kudos
Message 6 of 10
(9,938 Views)

That was my idea.  That the loops were actually executing, but you get an error.  And in your error case, you have a True wired to the stop terminal.

 

So:

1. You get an error.

2.  It gets placed in the shift register.

3.  Loop iterates, there is an error in the shift register.

4.  The error case runs.

5.  A True value is fed to the stop terminal thus stopping the loop.

0 Kudos
Message 7 of 10
(9,934 Views)

What I would probably do is to place an indicator on the while loop i terminal or a probe if it is wired to something. I wish that the i terminal could be directly probed even without a wire connected to it. I think I saw something about that on the idea exchange.

=====================
LabVIEW 2012


0 Kudos
Message 8 of 10
(9,924 Views)
Solution
Accepted by topic author SimonGoodson

I think that I found my problem. I needed to add another identical queue element to the loop if I wanted it to stay in that state. I'm still working through it, but I fixed a couple of loops so far. Thanks for the advice everyone.

 

Regards,
Simon

0 Kudos
Message 9 of 10
(9,917 Views)

As you noticed yourself, a queue isn't a fixed state but a queue of commands. As you Dequeue an item it'll disappear. 🙂

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 10
(9,912 Views)