LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Producer-Consumer very basic help and advise

Dear All.

 

As said before I am learning LabVIEW and only did the basic 1 level please take it easy on me.

I am working on a small application that sends a CAN message out and receive 2 Messages back the cycle time is 10mSec both ways.

I my limited knowledge I managed to find the information regarding using a Producer Consumer pattern to pass the data between the 3 loops( 1 main loop ,2 timed loops),I found in LabVIEW the template however there as few sub Vi's and shift registers with virtually no comments or an description how it works,I also do understand that the template is actually for people that has the background knowledge(which I am missing) ,My request is for a pointer to some material very basic that can help me understand how to pass 4 bytes from the main loop to the CAN send loop and pass 4 bytes of data from the CAN receive loop back to the main loop.

All help is very highly appreciated

Regards QMESAR

1.jpg

---------------------------------------------------------------------------------------
Learning is an endless process but needs to start some where
0 Kudos
Message 1 of 12
(1,549 Views)

How about using Queue?

You can find Examples in "NI Example Finder"

Pazhanivel Thiruvenkadam,
CertifiedLabVIEWArchitect|| CertifiedTestStandDeveloper,
Currently able to Access LV2015&LV2017
Message 2 of 12
(1,543 Views)

Hi 

Thank you very much for the advice I will go look in the Examples for Queue ,

much appreciated.

 

Regards.

QMESAR

---------------------------------------------------------------------------------------
Learning is an endless process but needs to start some where
0 Kudos
Message 3 of 12
(1,532 Views)

When I did a Web Search for "LabVIEW Producer Consumer", the first "hit" was an NI White Paper called "Application Design Patterns:  Producer/Consumer".  I recommend you find this, read it, think about it, perhaps write some simple test routines based on it, and see if it begins to make sense.

 

Bob Schor

Message 4 of 12
(1,507 Views)

Hi Bob 

 

Thank you very much for your help much appreciated this is a very helpful document, however putting the in the same search string as you yields no results when doing that from Russia ,However I then went to the Ni web and did a search and found the document

 

Have good time

QMESAR 

---------------------------------------------------------------------------------------
Learning is an endless process but needs to start some where
0 Kudos
Message 5 of 12
(1,498 Views)

Hi All,

I am digging into all of these synchronization topics ,I have worked through a few examples of Notifiers and Queues,

One issue that I am having and would appreciate if someone can help me understand I found a simple example of passing a Queue to a parallel loop  the wire color for the Queue in the example are orange and green when I do the same in my own VI then my Queue wire color is the same blue as in the case of a Notifier .

Am I doing something wrong ? 

The wire color of the example

2.jpg

My wire Color for the Queue

3.jpg

Secondly so far I have learned that the execution of the consumer loop is dependant on the availability of the Notifier or the Queue meaning that the Consumer loop only execute when data is there practicaly the consumer loop execute at the same rate as the Producer if the producer execute every 100mSec then the Conumer execute every 100mSec's the only difference between the Notifier and the Queue is the buffered data by the Queue thus if the consumer executes a bit slower that the Producer loop no data is lost as the consumer reads from the buffer However in my case I would like the Consumer to execute every 10mSec and the producer deliver new data every 100mSec ,Still trying to find the correct information.

 

Also using a Timed loop as the Consumer loop so far did not work for me as once I use the Queue method the Timed loop execute at the rate of the producer loop and not at the Timed loop preset Time is it actually doable using a Timed loop with Queue's

I appreciate any help or advise 

 

Regards 

QMESAR

 

 

---------------------------------------------------------------------------------------
Learning is an endless process but needs to start some where
0 Kudos
Message 6 of 12
(1,469 Views)

Nothing to worry on the color part as it depends on "Data Type"

 

Consumer Loop will wait idle till it gets the data from the producer and process once it receives data.You have to architect in such a way that it gets syncronized.

 

Pazhanivel Thiruvenkadam,
CertifiedLabVIEWArchitect|| CertifiedTestStandDeveloper,
Currently able to Access LV2015&LV2017
Message 7 of 12
(1,465 Views)

Hi

 

1. As mentioned by Palanivel, the color of the wires is based on the data type wired to the Obtain Queue function.

 

If you look at the example, it has a DBL data type, while you are using an Array of integers. Play with changing the data types to a Boolean, cluster, etc and see how the wire changes color.

 

2. What do you want the consumer loop to do when there is no data from the Producer? If your consumer is running at 10msec, it would get new value only in every 10th iteration. What should it do in the other 9 iterations?

 

 

Regards
Freelance_LV
TestAutomation Consultant
Message 8 of 12
(1,462 Views)

@QMESAR wrote:

Secondly so far I have learned that the execution of the consumer loop is dependant on the availability of the Notifier or the Queue meaning that the Consumer loop only execute when data is there practicaly the consumer loop execute at the same rate as the Producer if the producer execute every 100mSec then the Conumer execute every 100mSec's the only difference between the Notifier and the Queue is the buffered data by the Queue thus if the consumer executes a bit slower that the Producer loop no data is lost as the consumer reads from the buffer However in my case I would like the Consumer to execute every 10mSec and the producer deliver new data every 100mSec ,Still trying to find the correct information.

 

Regards 

QMESAR 


You can have several producers, that's one of the key design ideas of a queue, Many-to-one. In your case, if you want to read/sample something every 10ms, make that a loop of its own, and send/enqueue it to the consumer, which'll then handle/keep track of things, like saving to file or displaying a graph.

 

As for the wire color, i think it's always a green outline surrounding the data type. In your integer array the thick blue should have a green border, but i might be misremembering.

 

/Y

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
Message 9 of 12
(1,459 Views)

@Freelance_LV 

@Freelance_LV wrote:

Hi

 

1. As mentioned by Palanivel, the color of the wires is based on the data type wired to the

 

2. What do you want the consumer loop to do when there is no data from the Producer? If your consumer is running at 10msec, it would get new value only in every 10th iteration. What should it do in the other 9 iterations?

 

 This loop sends a CAN message to a machine that needs to see the CAN message every 10mSec or it will time out and Shutdown ,The user input for example the speed or the motor updating this user value every 100mSec is fine however the Machine still needs to have the CAN message coming in every 10mSec this is the problem I am having.I can live with consumer loop executing at the same time/interval as the Producer loop however Machine CAN messaging can not

 

Guys Thank you your replies appreciated

OMESAR

 

 

 


 

 


 

---------------------------------------------------------------------------------------
Learning is an endless process but needs to start some where
0 Kudos
Message 10 of 12
(1,457 Views)