Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

where am I wrong using queue to control vision loop and motion control loop?

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.

 

queue.jpg

0 Kudos
Message 1 of 17
(4,340 Views)

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

Message 2 of 17
(4,330 Views)

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

0 Kudos
Message 3 of 17
(4,325 Views)

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

0 Kudos
Message 4 of 17
(4,322 Views)
iZACHdx , yes, I try to share data between loops. I don't know how to wire them. You may take a look in my screenshot. If I want to share position x on the bottom loop, should I wire position x to the element input of the enqueue element fun? How about dequeue element function? Moition loop end at output velocity. how can I wire it? The queue won't effect other operations, will it? The operation write all datas to a file in real time. Thank you! Guangli
0 Kudos
Message 5 of 17
(4,319 Views)

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:

 Queue.png

-Zach

Message 6 of 17
(4,306 Views)

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

0 Kudos
Message 7 of 17
(4,306 Views)

hey, iZACHdx,

I kind of confused by this. Do you mean like the following screenshot? I don't  wire out my x position now. I write my data first and then wire out to motion loop. Is this correct?

THKS!

queue.jpg 

0 Kudos
Message 8 of 17
(4,302 Views)

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.

Queues.jpg-Zach

0 Kudos
Message 9 of 17
(4,283 Views)

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! 

 

queue.jpg

Message Edited by guangli on 02-10-2010 11:42 AM
0 Kudos
Message 10 of 17
(4,277 Views)