events producer consumer with notifiers

Dear users of LabView,

I would like to ask your advice on my project (see the attachment of files). For the beginning, I did only the "backbone" of my project, that's what you can see in my VI. My project will have the following features:

-Start and stop action possibly (and also plot data to the chart and saving the data to the file)--> here is some time a loop to record data ranging from DAQmx (USB6009) and another while loop with rates of different loop to rise in voltage output amplifier of the magnet.

-During the measurement, or if the system is idle, the user is able to read files of measured data and evaluate the measured data, etc... (so there will be more features...)

I decided to use producer consumer structure with events and the authors of notifications, and I also use the dynamic user event to be able to communicate to the consumer with the producer (where I have my machine of the State as in a shift register).

Please comment on my VI, what do you think? Maybe I should use the state machine (the shift with the pole of the State Register) in the lower loop? I could also use up queues of the notifier, but since I send only orders and the values of the parameters (not streaming broadband data) I guess that the declarant is fine?

Thanks for the tips!

The code you posted looks like a good start.  The architecture is very similar to the measurement sample continuous project comes with LabVIEW 2012.

A few things I noticed:

  1. I would usually use queues instead of filers (unless you want to manage only the last command and not all orders in the order they are received).
  2. You don't need the registry change in the top loop (structure of the event).  You inadvertently send a length of measure and other commands parameter since you replace only the command.  Probably, this is no problem for now but could be a problem later.
  3. I think the user events are a great way to manage cases of judgment where the consumer is able to report to the producer that the application must exit loop (this is how we do in the sample project).
  4. Your case 'Init' confuses me a little.  It is read length control measure and send a user event in the event that, in the structure turn immediately place a measure command. Once I see a control in a loop of consumer as it hurts a bit uncomfortable. Why not have the value "start_measurement" to change event read the length of measure command and send it as part of his message to the consumption loop. Then the loop of the consumer can Init and self talk to start the measurement.
  5. You may need to rethink your strategy mistake in the case of the measure. Currently you do not stop a loop if an error occurs, and allows you to keep the error between iterations of the loop information shift registers.  Therefore, if an error occurs in one of these loops you can never hear about it.
  6. In general, using the error state as the main way to stop a loop from consumers is a bad practice. I'd rather see a "Shutdown" command which causes the consumer to stop loop. It is more scalable and less likely to be triggered by the accident.

Good luck with the rest of your application.

~ Simon

Tags: NI Software

Similar Questions

  • 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.

  • Using the producer/consumer with GPIB/VISA model

    Hi all

    So I have a .VI I learned to communicate with my camera, I joined. I tried strip down as much as possible, just to understand the concept. It basically just takes a resource VISA name, use this open VISA, then uses the same resource VISA to write a command that reads the data from my machine (xall?) and then bed in 500 bytes and which prints. If it works, and it's good.

    I try to use producer/consumer model for doing essentially exactly what this guy. I have a RLC, I want to press a button that starts my measure, I want him to taste several times per second, save the data in a text file or .csv and then stop when I press the stop button. Thus, he will be given indefinitely potentially.

    I would like to have the data in a format something like:

    Time C R

    0 5.0 4.3

    ... etc.

    I read the link of model p/c above, but my LabView knowledge is still low. Currently, my plan is to take the part of read/write of my attached VI, which are a sub - VI and then put that in the pink box in the VI for the producer/consumer above page that is labeled "produce data to be placed in the queue":

    What prevents me to do this, it's that I can't get the piece of read/write to work properly as a standalone Subvi.

    What is the right way to go about this?

    Thank you!

    I put if you actually found data of your instrument.  Your instrument is not made to take new measures or just send you the last reading, she did.

    Insofar as the file IO, I recommend that you learn to use the palette for the file IO functions.  You need to create your file before your loop, write in a text file inside and then close after the loop.  I don't do the thing the comment on the express VI entry will do what you want.

  • Producer consumer with inputs and outputs analog and digital

    Hello world

    I'm working on a program of control system for some practical test work. Currently, I am working on the data acquisition of the Labview program component. My architecture is consumer-product loops with a what. My system will have analog inputs, outputs, analog inputs and digital outputs. It is not a criticism of time sytem, but I wish that all the acquisition of data to synchronize. I enclose my program because it is at the moment. I have difficulties to get all the data in the since that I have two types of data. In addition, I don't know if I have synced the four sequences of read/write correctly. I would be very happy if someone could take a look at my program and give me some advice. Thanks in advance.


  • change my model of producer consumer with different types of orders


    Right,

    Sorry I was not clear about that. I meant add the enum that I mentioned to the cluster.

  • 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.

  • Instead of using the structure of the event with the producer consumer?

    I used the architecture of producer-consumer in the past to control a state machine with the structures of the event.  I'm working now with the basic version of LV that does not include the structure of the event.  Can anyone recommend alternatives to the use of the same architecture in this case?  Thank you, David

    Before the introduction of the structure of the event, the only option was the election.  Control terminals are in a time loop (the producer) with shift registers and a wait, usually about 100ms.  At each iteration of the loop, the control's current value is compared to the previous value.  If it has changed, and then take appropriate action.  Andrey suggested, queues are a good way to pass information between the loops.

    It works for the equivalent of the value change events.  Things like mouse to top or filter events were much more difficult or not possible.

    Lynn

  • What is the fastest method producer consumer. Queue, RT-FIFO, event

    Hi all

    Another question completed for the pro:

    I recently inherited the labview code that uses RT-FIFO for the transfer mechanism in the architecture of the producer consumer.

    The code was first written in 3-4 years and is currently in LV8.6. It is possible that the reasons for the architectural decision no longer exists.

    I am qualified using a producer consumer queued architecture,

    I understand the RT-FIFO Architecture.

    I started using an architecture based on events from the user.

    (I have attached samples of each)

    I also see the existence of a priority queue

    Each method has its own capabilities and gaps, that hand, nobody knows the relative performance of each method.

    (Assuming that the only process)

    I would expect RT-FIFO to be faster, there seems to be a version of low characteristic of a standard queue.

    What is the perfornace hit to use a coding user-friendly queue more

    RT-FIFO description talks about commications between the time-critical and lower priority threads.

    Until today, I thought that the queues had the same capacity.

    I've included an event method that I commonly use for review by peers and help from other users...

    It allows to:

    1. several producers with different types of data

    2. process 37 production order.

    3 allows asynchronous verification of functional notifiers such as stop, start and abort.

    4. in a system not real-time, it can include interactions of façade.

    What I do not understand on this subject, that's what are overhead or thread priority changes that may occur using this architecture (it solves a lot of problems for me).

    Thanks in advance,

    Hi Timmar,

    Here's a KB article on some frequently asked questions about the RT FIFO: http://digital.ni.com/public.nsf/allkb/7AE7075AF1B2C58486256AED006A029F?OpenDocument

    The more relevant question is #4, I posted below.

    What is the difference between RT FIFO and queues? 
    Functionally, RT FIFO and LabVIEW queues are two pads of first in, first out. However, here are the main differences between them:

    • RT FIFOs run deterministically in LabVIEW and evanescent code queues are not. This comes from the fact that queues use block calls during read/write to the resource shared, while RT FIFOs use non-blocking calls.
    • RT FIFO are fixed size while queues develop when items are added to them.
    • RT FIFOs will execute the code, even if there are input errors. They can (and will) produce new errors and spread the existing errors.
    • Queues work with any type of data, while the data types that can be used with RT FIFOs are limited. Generally any type of data involving allocations of extra memory can be used with RT FIFOs to preserve determinism.

    Let us know if you have persistent questions!

    Ryan

  • trigger several events to user in an architecture of producer/consumer

    Hi all

    I use a producer/consumer architecture, where the case within the property are selected with enums sent via a queue.

    Enums are queued in the producer, which is a Structure of the event inside a While loop. Then each of the events in the producer is associated with a case in the well (to make it easier).

    Now I would like to run several events in the producer, programmatically in a given sequence. The events involved in the sequence are basically all triggered by changing the value of a Boolean value (button).

    Please find attached a schematic representation of the sequence, I would like to implement.

    I heard of 2 solutions:

    -"Writing to the node (Sgnl) Value property of the variable [I] want change."

    -Dynamic user events

    In any case, I don't know how to make sure this is done for several events in a specific sequence?

    Thank you.

    Florian


  • Learn how to use queues producer consumer event

    Hi all

    I'm trying to understand the good programming techniques for the use of the elements of the queue in a producer / consumer event-driven program. I am looking for some demonstration programs have an idea of the functioning of these looops-based. Currently, I'm not sure on how to deal with errors that occur before an event from the queue (see screen capture below).

    If a queue receives an error, it seems that the queue item is never received. I have an OR statement to stop the producer loop when it receives an error message. However, because the question has never been in queue, dequeue in the consumer just loop element crashes then the consumer don't never closed loop the while loop.

    What are some good techniques to handle errors that are placed in a queue? I could probably cable a timeout on the dequeue, but I prefer not to use this approach if possible.

    Thank you


  • 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.

  • acquisition and recording of analog data with producer consumer model

    Someone on this forum, in a separate last week discussion, suggested that I use the producer model consumer data acq.  My ultimate goal is to acquire analog channels 1-4 continuous data, display graphical band style and save the data on the boot disk when the user presses the 'Start Saving' button (and will continue to display recorder cards).  Economy will stop when the user presses the button "Stop Saving" but strip map will continue to operate.

    My attempt to use the producer-consumer model is attached (LV 8.5 only).  It does not work.  I have not tried to implement for recording user controls - just trying to make simple continuous display and save (1 channel) at this stage, using this model.  VI runs, but the graphic Strip is never updated with the actual data, and the data file that is saved has zero byte inside.

    Thank you.

    WCR,

    Looked at your code, and you are right.  It won't work.

    Take a look at this example:

    http://decibel.NI.com/content/docs/doc-2431

    The VI of the acquisition must be inserted in the loop of the producer.  In addition, you must tell him how many samples for (otherwise, it will get 0).

  • State machine in queue with the producer consumer

    Hello

    I am trying to build a VI where the user allows some Boolean controls on the front panel.
    VI uses a producer consumer in which based on Boolean values clicked architecture.
    some States are queued one recorded in a table.
    After the user is done by selecting, Boolean values should get disabled and the table of States
    should be indexed one after the other.
    It is an attempt to solve the review model car wash.
    However, the VI does not generate the required results.
    Can someone help me please understand what is the correct way to this implementation.

    Thank you

    Its because you have wired the consumer while loop the first stop. Remove and in your loop of consumer, make a comparison of the States that you receive and if it is equal to stop, stop the loop of the consumer.

  • 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.


  • How to do the sync with notifier

    Hi all!

    Now what I'm trying to do is to do a sync. A series of signal keeps coming back, and a counter records the number.

    And I also have a data acquisition to output voltages. Now I want that whenever the meter changes, a change in the production of data acquisition

    could be triggered. A synchronization problem! I would like to ask for help on the implementation of this. To use a declarant or appearance? and how?

    Someone has an idea?

    Thank you!

    Chao

    The screws you have found would be used, but when you select create options from the file menu, one is open one of several models of design pattern.,

    When you select new, a dialog box opens where you can select what you want to open. In the hierarchical menu on the left, expand the 'VI' section and the section she titled "from the model. Continue downhill expanding 'Managers' and finally 'Design Patterns '.

    In this final section, you will find a model called "model design of producer/consumer (events)." Select it and then click OK.

    This model uses an event (in this case an event on a button to change value) to do something (cause a value to be put in a queue). This basic idea would be expanded by first returning 'upside down' and then using a user-defined event to transmit information of change of State between the loops.

    In this scenario, the loop at the bottom (which is where your data acquisition logic would be) becomes the producer loop while the top loop (the one with the structure of the event inside) serves as the loop of consumer.

    Basically, the counter in your code generates an event defined by the user whenever the value of the counter changes. The event would pass this state change information to the consumer (instead of a queue) loop.

    I make this change because the question you should address with the help of queues and notifiers to synchronize is that only the consumer will see any given notification or the queue item. It's the way they are designed to work and it can be a very useful feature, but if you have more than one consumer who needs to be informed of a change of State, it is also a problem.

    On the other hand, an event will be seen simultaneously by all consumers who have registered to receive. Similarly, an event can spend as little or as much as you want.

    Mike...

Maybe you are looking for

  • Discs lost with ElCapitan

    I have an iMac 2010 with processor quad core i5, 8 GB of ram with internal superdrive and a LaCie 22 x usb dvd burner that has worked well, however, after the installation of El Capitan, I have lost the two discs, nor are recognized in disk utility,

  • No display of content pages

    When you try to browse to a Web site such as hotmail or google, there is no indication on the page.

  • Changelog of BIOS upgrade?

    Hello where can I find a changelog for the new BIOS versions (in my case A80)? To the download page, I can't find that the updated BIOS to file level, but "what's new". In the file zip is too no extra info. I want only to upgrade if it makes sense. D

  • Is a necessary additional security, such as McAfee software on the new iMac and iPad?

    Is a necessary additional security, such as McAfee software on the new iMac and iPad?

  • Don't stay connected to the internet browser

    I have a Hp Pavilion 15 laptop pc. The problem Im having is that I will be hooked up to the Web browser and it will work for about 5 minutes and then I will not connect after that. I know this isn't the connection because everything else on this netw