04-30-2018 12:04 AM
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
04-30-2018 12:27 AM
How about using Queue?
You can find Examples in "NI Example Finder"
04-30-2018 12:48 AM
Hi
Thank you very much for the advice I will go look in the Examples for Queue ,
much appreciated.
Regards.
QMESAR
04-30-2018 06:31 AM
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
04-30-2018 07:46 AM - edited 04-30-2018 07:47 AM
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
05-02-2018 05:20 AM
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
My wire Color for the Queue
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
05-02-2018 05:51 AM - edited 05-02-2018 05:52 AM
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.
05-02-2018 05:59 AM
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?
05-02-2018 06:07 AM - edited 05-02-2018 06:09 AM
@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
05-02-2018 06:10 AM - edited 05-02-2018 06:13 AM
@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