02-08-2010 08:58 PM
Hi, guys,
I try to use producer/consumer queue to control my vision loop and motion control loop. Check out the following screenshot.
The top is consumer, which will control motor using position getting from vision loop. the bottom is producer, which get position of a point by vision loop.
I use green rectangle to mark queue I made. I follow the link:http://zone.ni.com/devzone/cda/tut/p/id/3023.
I didn't let it work. Please help me see where is wrong. Thank you in advance.
02-09-2010 10:02 AM
Hello,
What are you trying to achieve with this architecture? I see that you have the enqueue and dequeue element functions in the two loops but you don't have anything wired other than the queue reference. This means that you will get default values elsewhere. The timeout of the queue will be set to -1 and will never timeout when waiting for an element. Since you did not wire any new elements to enqueue, it will just wait there and halt your execution. What behavior do you see with highlight execution on?
-Zach
02-09-2010 11:52 AM
Hi, iZACHdx
Thank you for replying!
I want to get position from Vision loop, which is on the bottom. Esepicially, I want to use the position x to compare to reference/setpoint.
The position x and y will be writeen to file.
And I will let motor run by certain speed. motion loop is on the top. And i want to write the velocity of motor to the same file as above.
these operations are in real time. That means I get position first and then take this position to motion loop. When motion loop finish, vision loop will take position again and ...
I don't know how to use the queue. Please give me some clues. Thank you very much!
Regards!
Guangli
02-09-2010 12:12 PM
Hello,
Are you trying to share data between loops? That is really what queues are for. If you want to use them like this, you need to wire an input to the element input of the enqueue element function. Since you never place data into the queue, your program is not executing subsequent iterations of the loop.
-Zach
02-09-2010 01:00 PM
02-09-2010 02:51 PM
Hello,
I would take a look at the design templates in LabVIEW by selecting File»New... and then navigating to VI»From Template»FrameworksDesign Patterns»Producer/Consumer Design Pattern (Data) and use that as your core. Below is a simple example with some explanations:
-Zach
02-09-2010 02:53 PM
Hello,
Also to note, in the picture on the top, you have you x position wired to the output of the bottom loop and then into the top loop. Because of the data flow paradigm, these loops are not operating in parallel becuase of this. Remember that all inputs of a structure must be satisfied before it will start executing. The only way for that input to be met is for the bottom loop to finish executing.
-Zach
02-09-2010 08:18 PM
02-10-2010 09:28 AM
Hello,
As referenced in my last post, you are not following the data flow paradigm. If you connect wires between two loops, they will not run in parallel. I have circled the wires in the picture below. Since it seems you are trying to share the x position data between the loops, that is what you need to dequeue in the top loop. This is circled and a question mark is placed by it. From what I can gather, it seems as though this output should be wired to your greater than? function.
-Zach
02-10-2010 11:41 AM - edited 02-10-2010 11:42 AM
hey, iZACHdx,
you means it looks like the following screenshot marked by red rectangle? I don't connect posion x between two loops and just let queue commands to communicate to each other, rihgt? But the data type may be not similar. You see the figure, they don't let me wire some data on the top loop.
Thks!