LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

calling producer/consumer subvi using main vi for image grab acquire

Solved!
Go to solution

Hi everyone,

 

I am not sure if I get the producer/consumer concept wrong. I tried to write a producer/consumer subvi that simulate continuously grab acquire image. When I call the subvi from the main while loop with a main vi, it seems to run into a infinite loop. I am wondering does anyone know how else can I activate a producer/consumer subvi using main vi? Thanks in advance.

 

Kind regards,

Han Yen

Download All
0 Kudos
Message 1 of 14
(4,271 Views)

I was working on something similar a few days ago.  And I stumbled upon this example:

 

http://zone.ni.com/devzone/cda/epd/p/id/5859

 

Probably kind of similar to your code.  Hope this helps a bit.

http://www.medicollector.com
0 Kudos
Message 2 of 14
(4,264 Views)

thanks a lot, josborne..I'll look through the the example and see how it works. 🙂

0 Kudos
Message 3 of 14
(4,255 Views)

Actually, it seems that the button in the subvi does not respond to the one in the main vi. Perhaps I did not pass the data from the main vi into the subvi properly.

0 Kudos
Message 4 of 14
(4,250 Views)

Hi Han Yen,

 

a few remarks :

 

- your Top VI has no function what so ever.  So skip that.

- your image queue has no name, so that gives problems from the minute you're going to use more queues.

- It does not matter which command you send to the queue, it will start the bottom loop anyway

- You don't have a check whether "live trial" is true yes or no, so everytime you switch it from T=>F or F=>T is will activate the command.

 

I've tweeked your producer-consumer.  Maybe this will give you an idea.  I put some remarks in some places

Kind regards,

- Bjorn -

Have fun using LabVIEW... and if you like my answer, please pay me back in Kudo's 😉
LabVIEW 5.1 - LabVIEW 2012
0 Kudos
Message 5 of 14
(4,241 Views)

 


@Han Yen wrote:

Actually, it seems that the button in the subvi does not respond to the one in the main vi. Perhaps I did not pass the data from the main vi into the subvi properly.


of course it does not respond.  This will never work that way.  In this case, your top level VI has NO use.  Don't make it too hard on yourself.  Why do you want to use a top level VI if it's not needed.

 

Kind regards,

- Bjorn -

Have fun using LabVIEW... and if you like my answer, please pay me back in Kudo's 😉
LabVIEW 5.1 - LabVIEW 2012
0 Kudos
Message 6 of 14
(4,240 Views)

Dear Bjorn,

 

Thank you very much for the feedback and comments. They are very helpful. Actually, at the top level I have other functions too. But I haven't implement them yet. The other functions I plan to implement is snap image, save image, monitor camera temperature, adjust camera gain and update, adjust stage control.., etc.

 

The current subvi "ProducerConsumerGrab" is to try to get most recent image from my Andor high speed camera with while loop. It's like the Grab function in IMAQ. I can't use the some IMAQ grab acquire functions because my camera is incompatible with NI. The basic Andor library do have basic functionality. So, I thought if I am able to pass the signal from button at the top level, into the subvi "ProducerConsumerGrab", I can also do so for the other functions I mentioned earlier.

 

Do you think is a good approach?

 

With thanks,

Han Yen

 

 

 

0 Kudos
Message 7 of 14
(4,233 Views)

Hi Han Yen,

 

I don't think you totally understand the idea behind producer-consumer loops.

Consumer-producer is normally ment to have a user-interface loop and another loop (like you camera loop) without having the UI to wait for the cam loop.

You don't have to create a new prod-cons structure for every VI if you can do all the actions in one.

 

I've changed the prod-cons loop to show you how it's done.  It's really easy once you get the hang of it.

 

If you have any questions, don't hesitate to ask.

Kind regards,

- Bjorn -

Have fun using LabVIEW... and if you like my answer, please pay me back in Kudo's 😉
LabVIEW 5.1 - LabVIEW 2012
0 Kudos
Message 8 of 14
(4,227 Views)
Solution
Accepted by topic author Han Yen

Bettter use this one.  The one above had a "small" error Smiley Tongue

Kind regards,

- Bjorn -

Have fun using LabVIEW... and if you like my answer, please pay me back in Kudo's 😉
LabVIEW 5.1 - LabVIEW 2012
Message 9 of 14
(4,223 Views)

Hi Bjorn,

 

Thank you very much for your comments and guidance. It works great. I think I sort of understand much better on how to use the producer/consumer architecture. 🙂

 

Kind regards,

Han Yen

0 Kudos
Message 10 of 14
(4,186 Views)