Enqueue Element

Hi All,
I am Using Message Queue for Implementing my Project.
Inside an event structure, enqueuing message to the queue. Message is selected depending upon a selection ring menu. a Variant also there, so a cluster object is used to cluster variant and string and given to the queue.
when i executing the vi, with default ring menu, its working properly. but when i change the ring menu i am getting an error. Please see the attachment.
Anybody Please Comment on this issue.
Regards,
mfp.
Solved!
Go to Solution.
Attachments:
error1.JPG ‏11 KB

You get an error 1 on the 'enqueu element' because you use an invalid queue reference. This is caused because you use 'use default if unwired' on the output of the event structure. In one (or more) of your event structures you don't feed a valid queue reference into this tunnel. LabVIEW will then output a default (NULL) queue. Since you use a shift register in a next iteration you will use that invalid reference.
There are two solutions:
Right click on the tunnel and deselect 'use default if unwired' and feed all queueu references through
Don't use a shift register, I think it's unlikely that you change to another queue during the runnning of this VI.
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!

Similar Messages

  • VI Fails to send queue elements

    I am trying to use a queue to send data from my pulse train subVI to my main VI.
    After my pulse train completes, I send a TRUE boolean via the 'Enqueue element' which goes to the 'Obtain Queue' and then to the Dequeue Element to acquire and log data.
    I am not sure why the data is only sent the first time, and not consequentially.
    I've tried the same with the Notifier to no awail. I am not sure if this is an issue in my SubVI or my main VI.
    I am not sure if this is correct? Do I need to release the reference or something?
    Thanks!

    belopsky wrote:
    Thanks - I tried that in a while loop, also tried probing the queue prior to it - would this probe list all of the elements queue up?
    If so, the additional elements never enter the queue....
    Probing the queue reference will not show the elements in the queue.
    If you are sure you are not getting more elements in your queue, then it is a problem with your producer loop.  Are you sure that loop isn't waiting for a message in order to do something that would then add an element to your queue?
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How to set the number of elements dequeued?

    Hello All,
    I am relatively new to LabView. I use LabView 8.2 to detect Joystick movement using a set voltage threshold. Totally, I have 6 channels of analog input. The sampling rate is 2 Kilo Hertz with continuous sampling mode (buffer size set to 10 Kilo Samples). I show a visual stimulus on a computer monitor. Within  3 seconds from stimulus onset, the subject has to press the joystick. So I use a while loop that runs until the subject moves the joystick in any direction as detected by crossing of voltage threshold. The while loop was intended to run for a max of 3 sec if joystick was not moved. My intention while using the vi (see below) was to continuously monitor the voltage signal by means of removing voltage data points from the queue by the labview function/vi - "dequeue element". When I dequeue from inside the loop, the dequeue function removes about 100 msec worth of voltage data points ( = 198-201 points; sampling rate -2Khz) from each of the six channels. This creates problem for me because a single dequeue operation takes 40 to 85 msec during which the loop cannot be stopped. This results in miscalculation of the actual time when the joystick was moved.
    Is there a way to set how many data points the dequeue function removes? My goal is to remove about 1-2 msec worth of data points so that the loop can exit within under 5msec of the joystick movement.
    I have attached the screen shots of the subvi's I am using.
    Acquire Response.jpg - the while loop that has the subvi: Access Analog Data Queue
    Access Analog Data Queue.jpg - front panel of the subvi that has the 'dequeue element' function.
    Remove Element.jpg - a case of Access Analog Data Queue.vi showing the 'dequeue element' function
    Sorry for the long message. Any help would be greatly appreciated.
    Thanks
    Mani
    Attachments:
    Remove Element2.jpg ‏135 KB
    Acquire Response1.jpg ‏266 KB
    Remove Element1.jpg ‏135 KB

    Hello Lynn and tst,
    Thanks for your suggestions. I have attached a screen shot of a vi that has the enqueue function. As Lynn pointed out, it was the enqueueing size that was reflected in the size of the dequeueing. I tried various ways to control the enqueue element size in order to control the dequeue element size. Many of my tricks failed. I had set the data acquisition to be continuous at 2kHz with 10Ks buffer size. You may want to look at the attached image of the subvi "Analog Acquisition" while I explain my attempts. The first thing that I noticed was the 'dt' value in the input node of the timed loop which had been set by somebody to 100. I thought that was part of the reason why my dequeue size was always worth 100msec data points. So I changed it to 1 msec. This definitely made a difference in the chunk size of the dequeued element. Now dequeueing removes only data points worth 1 - 5msec. I also noticed that my data reading timer loop(the while loop in "Analog Acquisition" picture) takes about 20 -25 msec instead of the set 1 msec.
    Why does the loop take so long? I have set the 'number of samples per channel' to -1 so that DAQmx read.vi (see it in Analog Acquisition subvi block diagram) can grab whatever data is available currently and put that into the queue. Can this be a reason why the loop takes more than 20 msec? I also tried to set the number of samples per channel to 2. I reasoned that with the sampling rate of 2KHz, 1ms loop should be able to pull 2data points and enqueue them. But it gave me the much-often-seen error code ":Error -200279 occurred at DAQmx Read (Analog 1D Wfm NChan NSamp).vi:1->Timed structure(s): DAQ Loop". I tried various combinations of loop time and number of samples per channel. I get Error-200279 very often. Note that I have several state transitions and only in a couple of them during every cycle of state transitions, I remove elements and flush the data queue (one place where I remove elements is shown in my original message in the picture-'Acquire Response.jpg').
    How do I set the data acquisition loop to enqueue elements for exactly 1 msec or n msec so that I can control my dequeue size?
    Thanks a lot, I am getting really tired of fixing this problem. Please help.
    Mani
    Attachments:
    Analog Acquisition.jpg ‏363 KB

  • Dequeue element times out even when queue element has new data

    Hi,
    I am using a producer/consumer set up and I am only getting one-iteration from my consumer loop.  I have probed the cluster wire that feeds the enqueue element of the producer and there is a continuous data stream there.  I have a timeout wired to the dequeue element in the consumer loop and have tried different times from 1ms to 1000ms.  It is currently at 25ms.  There has to be something else that is causing this issue, but I am overlooking it.  
    I also tried adding an event handler that would detect a value change in the data.  That didn't do anything.  I have tried to restart my machine to no avail.  I am about to shut down and take the battery out of my laptop and reboot (the act of a man out of options).
    If anyone could help, I would be indebted. 
    P Gnu
    If you want to increase your success rate, double your failure rate.
    Solved!
    Go to Solution.
    Attachments:
    Dequeue Waiting.vi ‏139 KB

    Thanks Javed_H
    I thought that I tried that, but either I didn't or I did it while there was another bug.  At any rate, the time-out on the event handler did fix it.  I appreciate your help.
    The reason I am using an event handler rather than a local variable is because I have been told many, many times that the local variable is somewhat of a hack.  They gave me other reasons, although they escape me now.  I do recognize and agree, however, that the local variable would work.  I'm letting the design asthetics of others dictate my code.
    Thank you for your input,
    P Gnu
    If you want to increase your success rate, double your failure rate.

  • What architecture is best for accurate data logging

    Hello,
    I'm desiging some LabVIEW code for a standard DAQ application that is required to plot about 100 variables onto the screen on several different graphs and numeric indicators, as well as perform some simple feedback control and log data into a file once a second.
    I've done this before, and used a simple state machine architecture, where one state takes care of my logging, and I have a timer vi in there that countsdown 1 second and then writes to file.  However, this method makes me miss a second every once in a while.
    I started looking into the producer/consumer architecture as a possible remedy for this.  Because I hear it's good for running two things at different times, so I"ll have my quicker loop handling data acquistion, plots and feedback control, and my slower logging loop, executing once a second.  But I don't see how to implement this
    questions:
    1. is a simple producer consumer the right topology for my application?
    2. when I create my queue do I create it a 100 element array (my data for logging) and then enqueue that in my producer loop from my data acquistion, then pass that to the logging VI.... this seems wrong to me, cause I'm going to be enqueing alot of 100 element arrays... and will be de-queing them slowly at once a second..
    3. How do I trigger my consumer loop to execute every second, should I set it up as a timed while loop? or should something from the producer loop tell it to?
    I'm sure this is a pretty standard thing to do, I'm jus tnot sure how to implment the correct architecture.
    much thanks! 

    Ok, let's try this.  I've put together an example that should do what you need.  I put notes in the block diagram, but essentially it runs data in a while loop at whatever execution rate you specify, then sends the data to another graph (or in your case, a log) every one second.  Basically, I've used a 100ms execution rate for the while loop, then every 10th time (you can change this if you want), it sends a boolean 'true' to a case structure within the while loop that contains the enqueue element.  The graphs that I included show that it does indeed add a new point to the second graph once a second while the first one is adding a point every 100ms.
    The actual wiring of this Vi could be cleaner for sure, but it was a quick and dirty example I put together.  Hopefully this will help you accomplish what you're trying to do.
    Regards,
    Austin S.
    National Instruments
    Academic Field Engineer
    Attachments:
    Enqueue array 2.vi ‏28 KB

  • Data acquisition loop with queue

    What I would like to do is have a data acquisition loop that samples a load cell at 500Hz and have another loop that runs much slower to run a state machine and display some data in real time.  The reason I want to sample the load cell so fast is to filter out some noise.  Making producer/consumer loops with a queue kind of makes sense but I don't really care about all of the samples, I just want to be able to read a real time filtered signal at certain times.  I looked at having just two parallel loops, one to acquire the data and the other to run a test and retrieve a real-time signal when I want but not sure how to pass data between the loops without using a queue.  You can do it with local variables but you are at risk of a race condition.  I hope this make sense.  I am sure this is a simple problem I just don't know what direction to go.  Thanks

    Good Evening secr1973,
    It sounds like you are on the right track.  You already know about the producer/consumer architecture; this is almost always the first step to the separation that I think you are after.
    The step that I think you are missing is a Case Structure around the enqueue element VI.  You likely have some event or specific pattern that you are looking for in the input signal.  You can have the output from this algorithm (likely a boolean) determine which case of the Case Structure to execute (Case 1: enqueue the element or Case 2: Do not enqueue the element).
    This, of course, leads to processing being done in the producer loop, which is quite the opposite of what you are trying to accomplish with the producer/consumer architecture.  You will have to decide if your processing is very simple or more complicated.
    If it is easy/fast, you can likely get away with doing this processing in the producer loop.  My guess is that your program falls under the category of do-it-all-in-the-producer loop because you are only acquiring at 500 Hz.
    If the application requires faster acquisition rates or if the logic is going to require some processing, you may want to implement a double layer producer/consumer architecture.  In this setup, you would pass all of the data from the DAQ producer to a second loop (using queue #1) that determines what to do with the data (to enqueue or not to enqueue...) and, if appropriate, write to a queue (queue #2) that the third loop can read.  The third loop would be where your state machine executes.
    If you have a quad core machine, each of these steps will execute on its own core.  If not, you will have a little more thread swapping; not a huge concern in most cases.  Here, we get into the art of programming more than the science.
    In any event, I think you will be OK with a little processing for the enqueue or not algorithm in the producer loop.
    Regards,
    Charlie Piazza
    Staff Product Support Engineer, RF
    National Instruments

  • Producer/consumer inside producer/consumer

    Hello all,  I am using a producer/consumer event structure within a producer/consumer....not sure if this is the best approach.  The main vi is setup to perform several different tests based on the user input.  It does an initialize, setup, and read a pressure controller.  The main vi continues to read the pressure controller until the user presses a button to perform a particular test. When the test is complete, it goes back to the main vi and monitors the pressure controller.  The user can perform another test or stop the program operation.  My question is......In the individual tests I use an enqueue element which sends it back to the monitor pressure controller in the main vi.  Is this the best approach?  THANKS in advance!
    Alma

    So the subVI is a popup window?  And nobody will be able to manipulate the main VI while the popup is there?  If so, I don't see much wrong with this.  But if you need to change things in the main VI while this subVI is running, it won't really work well since your main's consumer loop will not be iterating until the subVI is complete.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • XY graph in producer/consumer structure

    Hey there,
    this is my first shot at setting up a producer/consumer structure to operate a power supply (I've posted several questions about it here, but since this is more a Labview programming specific question, I thought this might interest more people). Seems to be working fine when using simple controls. But I also want to display the voltage plotted against time. To get the voltage, I have to send a control to the power supply to get the measurements in answer, get the voltage from there and put it in the graph. Since I can only send one control at a time, I've chosen to queue the "read" state behind every control (so for example, when queuing (or queueing?) "Run", I send "Read" immediatly afterwards so as to start the reading). But of course, every time I send a new control (change parameters for example), the graph is set back to zero. Does anyone know a way around this?
    This is just a tryout, no error handling or even closing of VISA sessions.
    Attachments:
    Producer consumer tryout.vi ‏37 KB

    crossrulz wrote :
    Not really.  Your waits are in parallel, so the delays do not simply add up.  You really should get rid of the 150ms wait that is outside of the case structure.  If you need to introduce any delays, they should be in the specific cases that will need them.
    Well, the power supply doesn't accept commands that come in at a faster rate, so I was thinking that by putting the wait function there, I would manage the queue in a way that it only sends commands at this specific rate. It's only the read function that needs to be executed at specific intervals. All the others don't need to. So I would still delete de 150 ms and put it inside every other command case?
    crossrulz wrote :
    One more comment on your code.  If you have something that needs to constantly happen, I just use the Timeout ability of the queue.  You could just set your timeout to be 500ms and then on timeout it performs a read.  This would eliminate the need to enqueue the Read command at all.
    You mean the timeout abilty of the queue? How would I go about this, create a separate "enqueue element", wire a constant of 500 to the timeout and the read state to the element input, then wire it to the Master Queue? I was thinking of using the timeout ability of the event structure. But I guess that wouldn't be ideal if I have more than one producer loop... Anyways, you Sir, are a genius.

  • Master and Slave Loops

    I'm having problems with my Master and slave loop combination.  I would like to be able to start and stop acquiring data from individual thermocouples. Please help.
    Message Edited by nicholas03 on 04-13-2008 03:22 PM
    Attachments:
    eight thermo.JPG ‏106 KB

    Dear Nicholas,
    My first advise would be to check the examples on master-slave patterns, and run them step by step, looking at what the data does...
    In a master-slave system, you use the queue to pass data from the master to the slave.   You're not passing data in the queue... in stead, you're passing data using local variables, which you should NOT do...  
    In the top loops, you should attach the temp array to the enqueue element.   In the bottom loop, you should remove the temp local, and instead get your data from the dequeue vi.
    Also, you have to create a queue with the proper variable.   You can create a queue from any variable type, but it has to know beforehand, and the init vi.  
    Assuming you want to queue the temp array, you're basic structure should look like this:
    It does help if you add your own code, so we can easier edit it for you...  Otherwise we need to use photoshop on your design...
    Message Edited by Anthony de Vries on 04-14-2008 11:30 AM
    Attachments:
    master-slave1.JPG ‏24 KB

  • Wish list for Queues

    A few functionalities I would like to see added to Queue functions:
    1. The ability to queue up an array of elements all at once (rather than having to use a For Loop with the Enqueue Element function inside).
    2. Given: A Queue with a set maximum number of elements.  I would like a boolean flag on the Enqueue Element function to allow addition of elements to a full queue (thus pushing out the oldest element(s)).
    Granted, I can reproduce the above effects thru coding, but it would be nice if they could be handled by the existing Queue functions.

    For getting around this, what you can do is build your routines once and then use some hierarchy renaming tool so that you can have unique names for all the VIs. Personally, I occasionally do this with a modified version of a duplicating tool I downloaded from MGI - I simply take the base files I want to duplicate, make a copy of the hierarchy and tell the tool to change\add the prefix or suffix I want.
    If you still want to keep the functionality in some base files you can modify, you can write the core using variants (place in the user.lib folder inside a folder beginning with an underscore and it won't appear in the palettes) and then only use the wrappers per project. Of course, you'll suffer some performance penalty with this method.
    Try to take over the world!

  • How to run a particular transaction called

    I want to run this transaction to post a closed period's material stock into PCA. I am using origin object 19 (for material stock).  Would really like to know from where I can get the material document numbers to key into this t-code. Any help would be appreicated
    Edited by: Rajesh Manohar on May 7, 2010 5:26 PM

    Say, in the attached program, when the user selects Autoset, it inserts corresponding state (Autoset) and now if you want this state to run again and again, probbbly you can again insert Autoset state while executing Autoset state... ohhh its confusing... check the picture below (A picture is worth a thousand words):
    1. Based on user selection, insert Autoset state.
    2. Re-insert Autoset state again and again while executing Autoset state.
    3. Now to come out of this loop, based on appropriate event generation, insert any other state AT FRONT (equivalent to Enqueue Element At Opposite End).
    I am not allergic to Kudos, in fact I love Kudos.
     Make your LabVIEW experience more CONVENIENT.

  • Event Handler with Internal Loops

    Hi...
    I'm trying to update a basic program to handle control events more efficiently.  The program needs to perform the following functions on start button press:
    1)  Import data file and parse instrument settings from multiple (X) rows
    2)  Perform loop with case for each row changing input settings, the read test equipment, and store data in new output data file
    I've looked at producer/consumer example and the continuous measurement and logging example, but not sure if either (or none) of the following two options is the best way to handle the looping from the file...
    A)  Use events to trigger looping for all input cases within a consumer (I've had a problem with this due to not being able to terminate the loop within the consumer with an abort button)
    B)  Make the consumer only a single data acquisition and load loop inputs as queues and generate output queues to be handled by another parallel logging loop
    Any advice?

    Hi bripple,
    Based on what you've described above, a Producer/Consumer Design Pattern (Events) might work. There is a template for this design pattern that ships with LabVIEW which you can access by going to File > New > VI > From Template > Frameworks > Design Patterns. When the user clicks the start button on your front panel, you can queue up a command that will trigger your consumer loop to read the file and loop over each instrument setting. Within that loop, you should be able to queue up additional events corresponding to each instrument setting and reading.
    In terms of error handling, you can conditionally stop a loop if you detect an error. If your user decides to push a button on the front panel to stop the entire process, you can use Enqueue Element at Opposite End to put a stop command at the beginning of the queue. When your consumer loop encounters this event, it can flush the queue and do any cleanup it needs to perform.
    One additional thing to be cautious of is that queues can only handle one data type. Because of that, you may also want to consider a Queued Message Handler design pattern. This design pattern allows you to send both a command and data along with that command. I think that would be ideally situated for you since you could send a "Read Instrument" command along with the data for its settings. You can access this design pattern from within LabVIEW as well. If you have LabVIEW 2012 or LabVIEW 2013, see these instructions. The things I've said above also hold true for the Queued Message Handler as well.
    Let me know if you have any questions or if this is helpful.
    Regards,
    Matthew B.
    Applications Engineer
    National Instruments

  • Generate an Event based on Counter Trigger

    Hello,
    I have the following part that is already working: a counter (used for period measurement) which is triggered by a digital input. After that I'm reading the data and I'm puting them in a Queue. Here I get an error. The Enqueue Element Vi is providing an error. (Error 1, something with a @  character that is illegal). I've notice that if I disable the trigger for the counter I don't get the error. I'm thinking that this is cause by the delay between the moment in which the Enqueue Block tries to enqueue and the moment in which the counter provides something to its ouptut.
    What I want to do is to Generate an Event based on the Counter Trigger Signal and to put all the reading and Enqueue part in an Event Structure. I've tried to do that using an Export Signal - Property Node, but I didn't manage to make it work.
    If you have any solution for this (with or without events -  I just want to get rid of that error) please let me know.
    PS: I have Labview 8.5.1 and the USB-6210.
    Thanks,
    LostInHelp

    Hello Mike,
    Thanks for your replay.
    I've attached two vi files. In one you can find how I've tried to generate an event based on the counter trigger (test.vi).
    The second one (test1.vi) is the vi where I get the queue error. I've deleted from the second vi the part where the data are dequeue and handled.
    Thanks
    LostInHelp
    Attachments:
    test41.vi ‏50 KB
    test110.vi ‏35 KB

  • How to run a particular case continuously in event based state machine architecture.

    I am making a program using event based state machine architecture, it is running as expected whenever i am generating an event, case structure corresponding to that event executes.
    we are taking some measurements from oscilloscope e.g. i am having one boolean button for rise time whenever i am pressing that that button it displays the value of rise time, it displays only once( since i have generated an event on that boolean button so it executes only once and displays value for one time and then comeback to timeout state) but in our program what we want, we want it to update value continously once that button is pressed.
    Now for a time being i have placed while loop on the case corresponding to rise time but this is not the right approach.
    since i am using state machine architecture( event based ), i am not getting how to run particular case continuously ,or if there is any other better architecture that i can use to implement the same application.
    Attached below is the program.
    Attachments:
    OScilloscope .zip ‏108 KB

    Say, in the attached program, when the user selects Autoset, it inserts corresponding state (Autoset) and now if you want this state to run again and again, probbbly you can again insert Autoset state while executing Autoset state... ohhh its confusing... check the picture below (A picture is worth a thousand words):
    1. Based on user selection, insert Autoset state.
    2. Re-insert Autoset state again and again while executing Autoset state.
    3. Now to come out of this loop, based on appropriate event generation, insert any other state AT FRONT (equivalent to Enqueue Element At Opposite End).
    I am not allergic to Kudos, in fact I love Kudos.
     Make your LabVIEW experience more CONVENIENT.

  • Interpreta​tion of and solution to error message

    I am trying to use a PCI-5122 card in a Windows XP PC/LabView set up to receive input from a Sodium Iodide detector to create a Multichannel Analyzer for Gamma ray spectrometry.  It runs for a second or so then gives an error:
    Error - 1074118632
    niScope Fetch Cluster.vi:1
    Driver Status: (Hex OxBFFA4018)
    Data has been overwritten in memory and ....
    Status Code -200004
    What does this mean, and what can I do about it?  It appears that there is a lack of synchronization between the card and computer and somebody's (probably the computer) memory is getting filled and overwritten?
    The Error Code vi says something like text unavailable and tells me nothing new.
    Thanks
    Gammarays

    Hi Gammarays,
    You're performing a continuous acquisition. You might have adapted it from the Fetch Forever example. You get the error because you aren't reading the samples in the circular buffer before they are overwritten. Many scope applications acquire records with reference to a trigger. Do you in fact need the continuous acquisition or does it make more sense for your application to continuously acquire?
    With regards to "playing around with the Min Sample and the Number of Samples", you should expect to see fewer problems if you set your number of samples to fetch to a higher number. Since the timeout is set to 0, if fewer samples are present than specified in "Number of Samples" they will be immediately fetched. This should correct any problems related to the acquisition. If you are still experiencing problems, it may be due to any processing you're performing on the acquired data. I'd recommend offloading the processing to another loop. I've edited the VI you attached to show how this can be done with a producer/consumer loop. Since we were seeing some issues already, I limited the size of the queue and set a timeout on the enqueue element. I also added an indicator to display whether you ever timeout (this would indicate that your processing loop is lagging behind and it can't keep up with the acquisition speed).
    Mike Lyons
    National Instruments
    http://www.ni.com/devzone
    Attachments:
    MCA test.vi ‏110 KB

Maybe you are looking for