LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Producer/Consumer Architecture

Hello All,
                I am currently working on an application using State Machine Architecture where I have to monitor various parameters (7 temperature values & 3 pressure values), along with this I have to On/Off a Clutch using a digital Output for set time (e.g. On for "X" seconds OFF for "Y" seconds), but as soon as the pressure and temperature values go beyond upper or lower limits or whenever the user presses the Emergency Stop (that means I have to monitor Digital Input as well) so I am moving to different error cases depending on which values go beyond limits or emregency pressed etc..
            But this realisation is not working fine as I have to monitor and control several other things in addition to acquiring data....till now I just have used State Machine Architecture, I have seen Producer/Consumer Template but not quite sure how to realise such kind of application which involves data acquisition along with user interaction and monitoring.
 
Could someone please put some light on giving similar kind of example or what else I can try with this problem.
 
Regards
James
0 Kudos
Message 1 of 21
(14,513 Views)
What I have done in the past when using the producer/consumer with a state machine was to and the consumer loop be a state machine, and only handle events when the queue indicated that there was an event.  This can be accomplished by using the Get Queue Status vi, and checing to see if the there is an element in the queue.  If there is an elemnt in the queue, that means an event occured and you need to handle it somehow.  If there is no elemnt in the queue, then no events have occured and you can contiue with the state machine.

Another option is to have your data acq run in a seperate loop and then have the producer/consumer handle all your events.  This works well (in my opinion) when you need to contue taking data at all times.

Kenny
Kenny

Message 2 of 21
(14,434 Views)

Hello James,

A Producer/Consumer architecture will certainly do the trick for you. I am sending you an example that has the Data Acquisition section in the producer loop. However, you can also put your User Interface in the Producer loop and have the Data Acquisition in the Consumer loop. The Queues are used for sending data from the Producer to the Consumer(s) loop(s) (you can have multiple comsumer loops).

You will just have to design specific cases to react to different user inputs.

By the way, this example is from LabVIEW Basics II training course. If you have never taken LabVIEW Basics I and II, I highly recommend them. You can self-pace the class or take it with an instructor.
LabVIEW Courses

Hope this helps!

Message Edited by Kalin T on 03-23-2007 09:57 AM

Kalin T.
Message 3 of 21
(14,417 Views)

Thanks Kalin and Kenny both for your help and time.

I will get back if I am in problem again.

Regards

James

0 Kudos
Message 4 of 21
(14,353 Views)

Hi!

I like the Implemented producer consumer.zip example. This does acquisition in the producer loop and writes to the file in the consumer loop and the data is queued here.  I was wondering if someone could help me with tweaking this code. I only want the data acquisition to start when I press a start button, however this program starts when someone runs the program directly. I know this may be possible to do with event structure, but am not sure how to tie it up with this program. I would appreciate any help in this regard.

I was also wondering that for data acquisition where some Front panel events may happen, what architecture is good to use. Is it ok to use a producer consumer with events where the events got in a event structure which is the producer, and consumer will be a state machine which will take care of the data acquisition. The data acquisition will be continuous so was not sure how to do the consumer loop with state machine. I would appreciate any help in this regard.

Thanks

0 Kudos
Message 5 of 21
(14,230 Views)
You could use a second Producer Consumer design pattern!

For events have a look at this one:
File->New....->VI->From Template->Framework->Design Patterns->Producer/Consumer Design Pattern (Events)

Wher the consumer is replaced by your current producer!

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 6 of 21
(14,203 Views)
can someone save the zip files in previous post to labview 7.1 and re-send so that I can take a look?

Thanks in advance.
0 Kudos
Message 7 of 21
(13,708 Views)
Hi Jamie,

Attached are the files in 7.1
Warm regards,
Karunya R
National Instruments
Applications Engineer
0 Kudos
Message 8 of 21
(13,675 Views)

Thanks,

 

I am having trouble with my code. Can you take a look at the attached. I keep getting error messages when I try to run. They read "Compile error. Report this problem to National Instruments Tech support. ufppushop err, c=0x21" and also "merge ufp inconsistent state, n=1 x2"

 

0 Kudos
Message 9 of 21
(13,655 Views)
Hi Jamie,

There are a lot of files in the zip file. Can you please specify which is the topmost VI or the one you are experiencing problems with?

Warm regards,
Karunya R
National Instruments
Applications Engineer
0 Kudos
Message 10 of 21
(13,634 Views)