LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Producer Consumer loop

Solved!
Go to solution

I'm trying  to constantly read data from a file every 30 seconds for example. then use the data being read to update all of my indicators  and LEDs  on my front panel. Is Producer Consumer architecture the best one to use?  does anyone have an example to follow?

0 Kudos
Message 1 of 26
(5,105 Views)

THe Producer/Consumer design pattern is definitely one way to do what you are attempting. Depending on which version of LabVIEW you are using (I only have 2011 installed here to look at) if you start LabVIEW and select "file", "New..." it should display a list of design pattern templates. The one for Producer/Consumer should give you a starting point.

 

Doing searches of these forums, and the NI site as a whole, will give more insight into the producer/consumer concept.

 

 

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 26
(5,097 Views)

Thanks for your reply.

0 Kudos
Message 3 of 26
(5,093 Views)

Greetings,

 

If your goal is to read a file every 30 seconds then update your FP LEDs maybe a state machine is the way to go. That is of course if what I interpretted from your statement is true. You pretty much outlined the necessary states in your post.

 

State 1: Wait 30 seconds

State 2: Read in File

State 3: Update FP Indicators


I agree with previous post though, a producer/consumer architecture will work. This forum should supply plenty of information regarding them.

 

Best of luck!

 

Chazzzmd

0 Kudos
Message 4 of 26
(5,081 Views)

Thanks also for your reply!

0 Kudos
Message 5 of 26
(5,077 Views)

One more question i was looking at the producer consumer loop and they are a few different options. With the Producer loop there are while loop with event structure loop, while loop with a case structure, and  a while loop by itself. Do I use the option of the while loop by itself to read the data from the excel file or would the case structure option work better in this case?

0 Kudos
Message 6 of 26
(5,070 Views)

Without looking at the actual examples it is hard to say, but it sounds like the "case structure" version of the producer may be a simple state machine. If that is the case, it would probably be the way to go, having a set of "states" : open, file for reading, read data from file, update consumer, wait, repeat ad nauseum until the UI (consumer loop) sends the signal that the process is to stop, then an exit case (state) to nicely close the file and anything else. The file close can also be after exiting the loops, but make sure that upstream errors don't prevent the file close (I'm assuming that the error cluster is being used)

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 7 of 26
(5,064 Views)

Ok Thanks again LV_Pro!

0 Kudos
Message 8 of 26
(5,061 Views)

Here is an example i tried. Can anyone help? I needed the producer aquire the data from the file and the consumer loop process the data and do the calculations

0 Kudos
Message 9 of 26
(5,017 Views)
0 Kudos
Message 10 of 26
(5,016 Views)