02-05-2013 09:57 AM
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.
02-05-2013 10:03 AM
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.
02-06-2013 02:59 AM
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
02-08-2013 02:29 AM
Thank you. I combined two loops together but still doesen' t work.It always shows:
02-08-2013 02:36 AM
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
02-08-2013 02:48 AM
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.
02-08-2013 02:57 AM
I already uploaded it. you can find it upstairs.
02-08-2013 03:09 AM
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.
02-08-2013 03:41 AM
this is the combined Program
02-08-2013 09:31 AM
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?