LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

two while loop can not synchroniclly run

hello guys,

 

as i want to test the forces on both sides of the maschine, i am programming with 2 while loops. First i designed on Loop(Loop1) for the right side of the maschine. Then copied it and set another one as Loop2 for the left side of the maschine. Wenn i run the whole Program, only Loop2 runs and nothing happened by Loop1. I testet with ''start single stepping'', the single stopped just before it entered Loop1, by Loop2 it has ran orderly. What's the problem.

can someone help me? Thank you.

 

 

0 Kudos
Message 1 of 21
(2,806 Views)

You've created a data dependency between the bottom loop and the top so of course the bottom loop runs first and the top will not execute until the bottom finishes. A second loop is not even necessary and if you did manage to get them to run in parallel, you would get a resource reserved error. All that you have to do is add the second channel to one task and acquire both channels in a single loop.

Message 2 of 21
(2,800 Views)

Hi,

 

there is an easy description for this behaviour.

 

A loop acts like any other node in LabVIEW.

All Inputs must be there before the output will be calculated.


Example:

Function "ADD"

First BOTH inputs must be there, then the outputs will be calculated.

 

Your problem:

If a while loop runs, no tunnel will output data.
this will be done after the loop stops.

If the 2nd loop is connected to this output of loop #1, this output is like an input for loop #2

=> That mean, that the loop will wait for this input and will get this input, when loop #1 stops.

 

As attachment you will find two examples
1) you can see the problem

2) NO problem, because no connection between the loops

 

Possible solutions:

You can use the following transfer mechanisms to transfer the data from one loop to another

- local variables, global variables (http://www.ni.com/white-paper/7585/en)

- Notifier

- Queues (http://www.ni.com/white-paper/3023/en)

 

Hope that helps

Best regards

Dippi

0 Kudos
Message 3 of 21
(2,763 Views)

Thank you. I combined two loops together but still doesen' t work.It always shows:

0 Kudos
Message 4 of 21
(2,728 Views)

Thank you for your reply. It seems that date that was read by USB Karte can only be used by one loop, because it always shows calibration.jpg

0 Kudos
Message 5 of 21
(2,724 Views)

You need to show us your modified code if you need our help.

We can't guess on what you are doing.

 

Attach the code and a picture of the block diagram.

0 Kudos
Message 6 of 21
(2,718 Views)

I already uploaded it. you can find it upstairs.Smiley Happy

0 Kudos
Message 7 of 21
(2,711 Views)

Code where you have combind the two loops ?

You are asking about error's comming from a modified code that only you can see.

It is hard to give you any help, if we can't see the how you have combind the two loops.

0 Kudos
Message 8 of 21
(2,707 Views)

this is the combined Program

0 Kudos
Message 9 of 21
(2,699 Views)

I told you that you would get a resources reserved error and I told you how to fix it. Did you bother to confirm what I said or did you search for the error code to see the numerous other new users that have made the same basic mistake?

0 Kudos
Message 10 of 21
(2,659 Views)