LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Producer with multiple consumers

Hello to all.

 

First of all thanks a lot for reading this post and being able to help.

 

I have a application where I have problem with times.

I need to take 4 images and process them in a short time.

 

Now what i do is to take first picture and process it in a iteration, in the next iteration take second image and process them.

The problem is that i have to take the images in a short time.

 

So I have thought to do a producer/consumer.

 

Consumer will be a loop which will take the images and save them in a queue and the consumer another loop which will be process the 4 images.

 

Now I have to communicate with a PLC to say if one of these images is right or wrong.

 

And also to refresh a graph in GUI with datas.

 

the most important thing is to be able to take the four images.

 

So is it a good idea to do 3 whiles?:

-1 producer: This just will take 4 images.

-1 producer/consumer: It will process the four images and it will be produce the PLC variables to send to it.

-1Consumer: it will consume the data from last while to send data to PLC and also o refresh graphs.

 

Is it a good idea?

 

thanks a lot

0 Kudos
Message 1 of 7
(3,321 Views)

I would have a look at the queued message handler. So there is:

- one event loop

- 1 loop taking images

- 1 loop processing images

- 1 loop communicating with the PLC

- 1 loop displaying the data

The images loop communicates with the processing loop and the processing loop sends messages to the PLC loop. All three can produce their data to the displaying loop. 

 

This is just a quick thought how to devide your different processes. Know you can think about how and what communication is needed between the differen processes and make a schematic (like a state transition diagram) how each process should work. This how it mostly works for me. Good luck!

0 Kudos
Message 2 of 7
(3,314 Views)

Hello!

Thanks a lot for replying!

 

"The images loop communicates with the processing loop and the processing loop sends messages to the PLC loop. All three can produce their data to the displaying loop"  

What do you mean?

 

And, I need a event loop? For what?'

 

Again, thanks  lot!

0 Kudos
Message 3 of 7
(3,305 Views)

In most cases the is alway communication between my displaying loop (or UI process), for example if an error occurs at one process it sends a message to the UI process. The UI process then can shut down all the other processes.

But also do you need to display come PLC data, image data and results: all this can done by sending the data to the displaying loop.

You are working on a standard PC? Then controlling the processes where any user interaction is envolved can be done with the event structure (for example shutting down the program, starting a tests, stopping a test). Again this is in general how I work, and what helped to set up some bigger labview applications. But have a look at the queued message handler principle

0 Kudos
Message 4 of 7
(3,289 Views)
From your original post it sounds like you have a situation where you are acquiring images (producer) faster than your analysis process (consumer) can handle them. Something that can help sometimes is to have multiple reentrant consumer loops running in parallel. If you do this, the important thing is to have the producer put its data into a queue. This is important due to the way LabVIEW handles queues. Specifically, you can have multiple receivers attempting to dequeue data and LabVIEW will automatically distribute newly enqueued to all the listeners is round-robin fashion.

Note that this is one of the few use cases where I recommend using a queue. In general, for communication, command and control functions within an application, UDEs (User Defined Events) are a better choice.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 7
(3,286 Views)

Hope you have created two threads with same requirments with difference in Title

 

Its good to maintain single thread and try to post your code to provide valuable suggestions

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 6 of 7
(3,262 Views)

In order to give you any meaningful help, we need to know exactly what you are trying to do.  This means that you need to post your code -- attach the actual VI (no pictures, please), or, if you have multiple VIs organized in a LabVIEW Project (always a good idea!), compress the folder containing them all and attach the resulting .ZIP file.  Otherwise, we are just "guessing" ...

 

Bob Schor

0 Kudos
Message 7 of 7
(3,256 Views)