Producer consumer loop

I'm constantly trying to read data from a file every 30 seconds, for example. Then use the data read to update all my indicators and LEDs on my front. Producer consumer architecture that is suitable for use?  someone at - it an example to follow?


Tags: NI Software

Similar Questions

  • producer consumer loop run only once?

    Hello here

    In my VI, the loop of the producer seems to operate continuously, but the loop of consumer only run once.

    I did not use producer/consumer patterns before, could someone give me some ideas why this is happening?

    My code is attached.

    Thank you in advance.

    Faouzi

    It would be the wrong choice to use a structure of the event into the loop of the consumer.  As it is configured, you must generate a leave mouse or mouse event enter on the graph of waveform for the loop of consumer to complete its first iteration.

    Remove the structure of the event.  you don't need to update a chart.

  • export to spreadsheet - data 2 channels appear in alternation with loop of producer/consumer

    Hello

    I'm having trouble with the function "Export the waveform to the worksheet" - but it is not clear to me if the problem is with how I use the export feature or if I am wrong concatenating two waveforms of different modules of the series prior to export, or if my queue is wired incorrectly for producer-consumer loops.

    I use a hunts SMU-1073 with SMU-6361 and 4330 modules (tension and strain). I tried to change the example of the "entry analog cross synch" for use with a structure of producer-consumer (see VI below).

    The output of the worksheet contains a large part of the data in the string tension, followed by a smaller piece of data (with timestamp) strain, after which the alternate output data between data of tension and strain.

    Can anyone suggest where I could go wrong, or how I could solve this?

    Attachments do not work, so I'll try to post in an empty message directly after this post.

    Thank you

    Claire.

    That's what I thought.

    A number of wire.  -1 gives all the samples available in the buffer (which can be zero for some reason any).  A number will expect that there are many examples.  If the two readings can wait until they have both the amount of data requested.  This way, they will also have the same number of samples and be better aligned in the text file.

    Your loop will continue to run until you press stop or get an error.

  • Convert single while loop with variable Timing literal to the producer consumer

    I have a controller for a biological system that updates every n minutes or every minute 2n, under certain conditions. My app has a synchronization controller calculates if the current iteration is n or 2n and feeds the output of this calculation in a loop of "Timing" VI in my all. If I understand correctly, this is similar to the issuance of an order of sleep() in a language similar to C and should be avoided. I'm refactoring my code and I heard that they are well suited for this kind of things. Here's how it should work:

    1. Loop begins at the time T, T is saved.
    2. Schedule controller runs and calculates if loop will get minutes 2n or n minutes. This controller will take a number of milliseconds to complete, so we are is more to time T.
    3. Now that the update interval (n or 2n, let's call it u) is known, the loop must until T +u fill.
    4. The PDC is executed, but a number of milliseconds to execute.
    5. The rest of the time until the next iteration of loop should produce the CPU for other processes.

    It sounds to me like it's the kind of a real-time system, although as long as we are in the minute of the original deadline, there will be nothing wrong.

    What the producer-consumer loop would look like? Assumed that the synchronization and the main order controller are separate from the VI.


  • Producer consumer

    How the attached VI may make use of the producer consumer loop?

    The operation will be done in a single loop and get the data which is write in the .csv file, how can it be done?

    Have you read how a consumer product model can work for you?

    http://www.NI.com/white-paper/3023/en

  • Producer / consumer set loop of dynamic data item type

    Hey all,.

    I do a simple exercise of producer / consumer in a loop. In my loop of producer I audio Aqcuerir and in the loop of consumer I'm projecting on a chart

    Everything works as I had in mind, the only thing that bothers me is the way that I had to set the type of the element to the block "Get the tail" at the beginning.

    I knew no better way to get the kind of data that I used to just take an another "acquire its" Express VI and which hang. But that may not be the only way to get there, right?

    Note: I know that I might not need to use a producer / consumer design tend to do, but I need to get hold of technology for school work so I came with this exercise just to get a hang of it.

    Thanks in advance,

    Al.

    Al,

    You just need to feed the correct data type in this entry, which you did by getting the output of a second acquire its Express VI.

    You can also use the "Convert to Dynamic Data" function to do this.  When you drop to the bottom of the function, you will be asked to give the input type.  Tests I've done, it seems not to matter, but for example if you chose the entry to a single scalar type, you need to feed a digital constant (change to double type) in the entrance and use the output of dynamic data such as line item data.

    I don't like the dynamic data type because it is not very clear as to what it is.  Another thing you could do would be to use the "Convert from Dynamic Data" function to change the output of the VI of its acquisition to a different data type for more or less to avoid the original problem all together.

  • Timed loop in loop of producer/consumer

    Hello!

    I have a loop of producer/consumer LabVIEW program configuration to allow me to properly capture the images that are large enough (8MP) at about 14 frames per second (FPS). The program works very well when the consumer loop is a while 'loop' (recorded at 14fps without problem), but I wanted to do a loop timed, so that I can vary the FPS as requires it. A curiosity arises when I do that. Anywhere under 12 fps, the loop works very well and the data is saved correctly. However, when I bump it up to 13fps, the calculated consumer FPS goes haywire and starts to jump between 9 ~ and ~ 13fps (processing of data gets bogged down?). When I set the FPS at 14, the loop runs at a constant maximum 7 fps. Is there something I can do to remedy this situation?

    I have attached my .VI

    Thanks in advance!

    Palanski,

    Are you using LabVIEW Real-time? Loops clocked to a windows OS do really increase determinism more than a while loop with a wait until the next timer multiple. Before you change the loop of producer-consumer in order to include a while loop was programming works correctly? You can also vUtiliser the VI analyizer to see how long things take to run. I let the loop of consumer to the producer in the traditional game upward and change the FPS by controlling the timer to wait, after benchmarking your code, it should be done in the same way as you did for the timed loop

  • Producer consumer with the third loop model

    Hello everyone and thank you for looking at this.

    I have a problem that I thought for a while now on the execution of a third loop in a design model of producer consumer (with events).

    I use this type of model for a UI and am happy with how it works. However if I want to add a continuis loop model to test for example how can I control the loop?

    In my example (see table), I use a local variable to run them (or stop) the test and the same to close the application.

    I don't know why, but this feels wrong to me. Is there a better way?

    Thanks in advance

    Chuck

    Nickelback says:

    Is the problem with the consumer loop only runs when it receives a message from producer loops event.

    Nothing says that you can't have a consumer loop enqueue States to itself.  Of course, this is more in a State Machine in queue with the possibility for another loop to the States of the queue.

  • Producer/consumer problem: several loops/queues

    Hello

    Please refer to my previous post ... http://forums.ni.com/t5/LabVIEW/What-is-the-best-way-to-switch-between-multiple-image-buffers/td-p/1 > for more on the subject. I was told to try a producer/consumer architecture, so I decided to go and do it.

    After doing much research, I come back to ask for help.  I decided to try to implement three loops. The reason for this is because I thought that the length of each loop synchronization can be controlled independently as it should. A single loop treats all user interactions.  A single loop treats data acquisition.  A single loop about the transformation.  I hope that this would help, but obviously made things much more complex.  I created a queue for each loop.  I didn't get the full project, but it seems that everything has run very well where I stopped.  However, one of my States I did not queue receive queue and I have no idea why or where coming.  There is an error in the variant data that says

    'status'-> TRUE
    'code'->-6
    'source'-> ' error: Invalid Args.

    However there is no error in wiring.  Also when this error is displayed, the random State fell through.

    The other weird thing is the number of items in the queue jumps very quickly when I do almost anything.  I don't know if it's common.

    Before I post pictures or whatever it is, I would have an idea about this error.

    Also, I think I saw this in a previous post about the BAU, but I would like to ask a question.  Attached are two photos.  Queue 1 is the way I put things in place.  Queue 2 is the way I saw things in place.  Can someone tell me if the queue 1 is the wrong approach and why?

    I realized what happened.  The other loop was not handled properly and sent the random State of the main loop.

  • Cannot terminate everything in a loop to the producer/consumer

    I have attached a simple vi which was built from the producer/consumer (events) model.  In vi I set up a counter.  I want to be able to complete the meter when you press the stop button.  This does not work as expected.  The meter goes to its full count before the program stops.  The vi works as expected when run in execution to highlight mode.  Cannot understand it.

    Thanks in advance.

    Race condition.  No matter what time something behaves differently with that highlight run it at full speed, and suspect it is a problem of synchronization due to a race condition.

    As soon as your producer loop has the command queued up, she is ready to handle the next event.  If you press the stop button, it is ready to deal quickly and the stem while the ends of the loop and Stop immediately gets back to false.  This probably happens before the loop of consumer has the opportunity to read the local variable of the button stop in the moment, it's true.  Have your consumer while loop redefine the Stop button to false instead ensuring consumer loop has a chance to see if it is true.

  • Master/slave producer/consumer Feeback?

    We know that in the models of master/slave and producer/consumer can send information of the master loop or a producer to the loop of the slave or the consumer.  But what to get information of the loop of the slave/consumer back to the master/producer loop?  I think it may return some sort of output or a message saying something like "I finished my work successfully.  This can be done with local variables, but is it really a good idea?  Is there another better way?   In addition, in this case can I just use a sub - vi?    I don't know that I always get the PARALLEL treatment offerred by master/slave and producer/consumer with a sub - vi.

    You can use a notifier to send a return message.  You can use a local variable, but unless you know what you are doing, you might encounter problems with race conditions.

    Sub - VI have nothing to do with producer/consumer architectures.  You can do a p/c with or without sub - VI.  Sub - VI is a way to break the code in significant functional blocks.

  • First try the producer consumer Architecture: continuous play and dynamically update settings.

    Hello

    I am currently working with two instruments; an Agilent E3646A and a NI 6212 BNC. My goal is to have the 6212 continuously take measures according to predefined parameters while the E3646A parameters can be continuously updated. This combination simple instrument aims to help me learn the manual architecture; continuous measurement, output dynamic controls and instruments more will be added in the future.

    I've already posted on a similar, but more complicated configuration (http://forums.ni.com/t5/Instrument-Control-GPIB-Serial/Split-second-lag-when-controlling-two-instrum... and was advised to try the producer consumer Architecture.) I found the documentation on the website (http://www.ni.com/white-paper/3023/en/, https://decibel.ni.com/content/docs/DOC-2431), searched the forums and built my own VI. While my first attempt at a producer consumer Architecture has solved some of the problems I had when I posted on the subject, however, new questions have been raised regarding the reading and adoption of the VI.

    I am currently able to run the VI and update the settings on the device. Previously, I'd get a freeze while the instrument has been updated and could not switch settings until it was done. This has been resolved, although that reading updates only when a parameter has been updated, although it is outside the structure of the event. In addition, the Stop button does not in any context. I also got occasional mistakes on the part of Deqeue, but the major part of the sentence is error-200279 'A tried to read samples that are no longer available' to DAQmx Read. I realize that there is a problem in my loop of producer but have not been able to find a way to solve it.

    This is my first attempt at a producer consumer Architecture and already I can see that it is a powerful tool. I read as much as I could and looked at examples, but should have some problems at the beginning. Would be very grateful of any advice so I can take full advantage of the architecture.

    Hope to hear from you,

    Yusif Nurizade

    You're going to overflow this buffer, unless the events are generated faster than "sample rate/number of samples.   Period.  Nothing could be simpler.

    You don't need a local to stop your curls.

    Try something like this attachment.  I simply moved the structure of the event in its own loop dedicated since it had nothing to do with acquiring data at all.

    Data acquisition loop stops very well when you destroy the task and destrying the stops of power queue (sending the default values of the queue for the power control) for EXAMPLE, to ADD a group of setting 'Safe shutdown' to a 'package' and it wire to the Center terminal (Prototype).

  • Architecture feature producer consumer

    I was wondering if the loop of consumer in a producer consumer architecture works only when the loop of producer send him something, or he still works, even if it receives nothing from the loop of the producer?

    It depends on how you put in place. If you do not have a timeout on the dequeue, he'll sleep until he gets a message. If you have a time-out, it will run if the value of timeout is reached.

  • IMAQ Vision: Is not an Image error when using producer/consumer

    Hi any person

    I used the Vision Express to solve the problem of Patern Machine.

    I want to put Assistant and Aquistion in 2 loop parallel. So I used the producer/consumer to transfer data

    After running VI, I pressed the Stop button and I encountered this error

    I think that getting the queue has a problem. I changed Image to Contant control and connect it to the data type of element. I think that this path is correct.

    So, in case of error, it addressed to Coppy IMAQ in Assistant. So I think that I used the Comunication of the queue is not correct.

    How can I solve this problem

    Thank you

    You can see more detail in the following video: https://www.youtube.com/watch?v=i6FOQ2jypXc&feature=youtu.be

    Try this:

    You should put the image process in the loop of the consumer and release it properly.

  • Programmatically change the number of producers in an architecture of producer/consumer

    Hi all

    I've got 3 momo SoMat I am streaming of data to 10 Hz. I plan on 3 producer loops and loop a consumer to treat.

    I am pretty sure when I show my customer that they want to increase the number of devices. This scuppers then the producer/consumer model unless I change by programming the number of producers and the rest of the architecture associated.

    Is there a way to do this or a better architecture?

    Phil

    As long as there is an ID any in your command of the queue, I do not see why your consumer cannot handle the producers as much as you need.  I would turn the producer code in a Subvi.  Make sure reentrant Subvi.  Then, you can call dynamically that VI as many times as you need, one for each instrument.

Maybe you are looking for