Producer consumer error 200279

Hello,
So I’m about to go crazy and hoping someone can help me here. I’m writing a program that controls a motor and using a producer/consumer method to write the data at 10,000 intervals a second. I’ve read through multiple examples and I don’t see what I’m missing. I’m trying to record 18 different readings from a DAQ 9178, 3 readings for voltage module NI 9205, 1 reading for current module Ni 9203, 2 readings for accelerometer module Ni 9234 and 12 readings for temperature module 9213. Every time I run the program I keep getting the error message 200279 and it states that it’s trying to read samples that no longer exist. It advised me to increase the buffer rate. So I did as it suggested in multiple ways and the error messages keeps showing up. I’ve also shut down the computer, exited and restarted Labview several times and none of this worked. I have included the a picture file below.  Where the problem is, is in the producer loop and the error is shown coming out of the DAQ error indicator. One idea I had but I’m unsure how to approach it is to somehow mean the data coming out of the DAQ to reduce what’s getting to the buffer. If anyone knows how to fix this problem please explain it in detail (I mean talk to me like I’m stupid) cause I’ve been stuck on this problem for almost two weeks now. Thank you in advance to anyone who can help.
SteelTiki  
Solved!
Go to Solution.

The DAQ error isn't related to your choice of architecture, although your implementation of it might be hurting you.  It's almost impossible to follow what's going on in your diagram because you have wires running in many directions (try to keep data flowing from left to right), there are local variables all over the place (almost definitely not needed), and there's a lot of code that's not in the image or is hidden in another frame of the sequence.  Normally one would not have the event structure as the consumer loop (as you've done), and it's generally not a good idea to have multiple event structure in the same VI (with rare exceptions usually involving user events).  It might not solve your problem but it would be worth taking the time to clean up your diagram.  Eliminate sequence structures and local variables as much as possible, move some code into subVIs, and straighten out your wires.
As for the DAQ error: the DAQ board is reading data into a circular buffer, and you're not reading it fast enough, so samples are being overwritten.  The reason you're not reading it fast enough is because you only read a single sample at a time (the DAQmx Read is configured for 1 sample on multiple channels) but you say you're acquiring 10,000 samples/second.  Since your loop won't run 10,000 times per second, you're not reading all the data, which causes the error.  Try configuring the DAQmx Read for multiple samples.

Similar Messages

  • Producer/ Consumer Design error?

    I am learning labview as I go and little errors keep stumping me. I set up the producer/consumer design and it reads the two while loops like I want. However, when I stop the program to save it to the write to measure it gives me an error saying invalid input and highlights the dequeue. I have to queues running (one for a button and one for data) and they both do this. I tried connecting it different ways but its always the same error. Any ideas? 
    Attachments:
    2whlloopprgrm.vi ‏392 KB

    Dublicate post
    Stick to one post at a time. Do not post the same question on two different threads. 

  • Attempting to write data to file, but getting error 200279

    I am having trouble when writing data to a file. About 10 seconds into the saving process, I get the error 200279. I have done some research on the topic, but am unable to corect my code. I believe I do not want to increase the buffer size, but would rather, I assume, read the data more frequently. The way I save my file is, before running the VI, I assign a location and name of the file (e.g. data.csv). The date and time is appended to the end of the actual file when the I begin to save the data (e.g. data_07-26-13_122615.csv). If the file does not exist, it creates a new file, then appends data to that file after every loop iteration. The reason I did it this way was so I do not have to worry about running out of memory, but apparently my code is flawed. 
    I will include a copy of the flawed section of my code. Any help would be greatly appreciated.
    Thanks.
    Solved!
    Go to Solution.
    Attachments:
    data_acquisition.vi ‏127 KB

    Your problem is that writing to disk is slow.  It is slow enough that it is causing your DAQ buffer to overflow and cause the error and loss of data.  What you need to do is implement a Producer/Consumer.  This will put the daq and the logging to disk in seperate loops.  This will allow the DAQ to run at the speed it needs to keep up with incoming samples and the writing to disk can run at whatever rate it can.  You send the DAQ data to the logging loop using a queue.
    You might also want to think about changing how you write to the file.  That VI is constantly opening and closing the file, which is a very slow process if you are doing it inside of a loop.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • First attempt at Producer Consumer Architectu​re: continuous read and dynamicall​y update parameters​.

    Hello,
    I am currently working with two instruments; an Agilent E3646A and an NI 6212 BNC. My objective is to have the 6212 to be continuously taking measurements according to predefined parameters while the E3646A's parameters can be continuously updated. This simple instrument combination is intended to help me learn the necessarry achitecture; continuous measurement, dynamic output control, and more instruments will be added in the future.
    I've previously posted on a similar, but more complicated, setup (http://forums.ni.com/t5/Instrument-Control-GPIB-Se​rial/Split-second-lag-when-controlling-two-instrum​... and was advised to try the Producer Consumer Architecture. I've found relevant literature on the site (http://www.ni.com/white-paper/3023/en/, https://decibel.ni.com/content/docs/DOC-2431), searched the forums and constructed my own VI. While my first attempt at a Producer Consumer Architecture has resolved some of the issues I was having when I first posted on the subject, however, new issues have arisen with regard to reading and stopping the VI.
    I am currently able to run the VI and update the device parameters. Previously, I would get a freeze while the instrument was being updated and could not toggle parameters until it was done. This has been resolved although the read only updates when a parameter has been updated although it is outside of the event structure. Furthermore the Stop button does not work in any context. I've also gotten occasional errors regarding the Deqeue Element but the bulk of the trouble is Error -200279 "Attempted to read samples that are no longer available" at DAQmx Read. I realize that there is a problem in my Producer Loop but haven't been able to figure out how to resolve 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 the relevant examples but expected to have some issues in the beginning. Would really appreciate any advice so I can take full advantage of the architecture.
    Hope to hear from you,
    Yusif Nurizade
    Solved!
    Go to Solution.
    Attachments:
    DCe3646A_DAQ6212_Prod_Con_4_13a_2014.vi ‏89 KB

    Jon,
    Thank you for the response and the suggestions.
    I created the Local Variable for the Stop Button and moved the original into its own Event Case. It is now able to stop VI execution although I get Warning -1073676294 which I understand to be the buffer issue. The warning says that this was incurred on VISA Open for the E3646A's Initialize VI which is outside both loops, however, which I don't understand.
    I tried increasing buffer size by decreasing the Number of Samples as per suggestions I found on NI forum threads. I've brought it down as low as 1 but the graph still only updates when an Event occurs and I keep getting the same buffer error. You suggested that the problem could be that they are in the same loop; does this mean that the DAQmx read should be outside both Producer and Consumer Loops or moved into the Consumer Loop? I found a couple of links ( http://forums.ni.com/t5/LabVIEW/Producer-Consumer-​Design-Pattern-DAQmx-Event-Structure/td-p/2744450 ,  http://forums.ni.com/t5/LabVIEW/Producer-Consumer-​Architecture/td-p/494883 -first response) on dealing with an Event Structure that my own VI is based. Alternatively, I found another link ( http://forums.ni.com/t5/LabVIEW/Producer-Consumer-​Design-Pattern-DAQmx-Event-Structure/td-p/2744450 - first response) on a DAQmx Read with an Event Structure that places the graph in the Consumer Loop.
    The core of my purpose in setting up this Producer Consumer Architecture is so that I could read continuously while the instrument parameters are updated dynamically so it's very important that I understand how this works. I am particularly struggling with how the Event Structure is controlling the While Loop's Execution.
    Hope to hear form you,
    Yusif Nurizade
    Attachments:
    DCe3646A_DAQ6212_Prod_Con_4_14a_2014_Edit_I.vi ‏90 KB

  • Producer consumer control of temperature

    Hello Everyone
    Im using a DAQ 6008, and Labview 8.5 to achieve the following outcome:
    measure the temperature across a heater bank, compare the temperature to set point, using PID, output a analog value - (0 -5) this then is used to control the duty cycle of pwm output in labview (pwm vi)
     I previously tried to write this all into 1 while loop, however due to the slow duty cycle required (1hz) for my output, and the fast sampling of the input I got a 200279 error.
    After reading many forums, I have now converted this to a producer consumer loop. Where the Producer loop, reads the temp, and PID produces an output, it outputs the result to the consumer loop, to create the duty cycle of my pwm output.
    I have a question about the queuing data: My worry is that "old duty" cycle values will be building up in the queue, resulting in a old duty cycles for the pwm output, which do not correspond to the latest as possible temperature - resulting in a unstable control.
    Was hoping some one would be able to clarify this ?
    Thanks/ Dankie

    If you only want the latest data, use a notifier instead.  The notifier can only store a single value.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Producer consumer timing

    Back again
    Thought I was getting somewhere now I am at another brick wall.
    Bit of background:
    I have a producer consumer set up. In the producer loop there are 2 DAQmx read VI's reading from a Pressure task and a Temperature task. These are multiple channels, 1 sample, outputtng a 1D wave form. This loop is set to run every 20ms. The two tasks were created using DAQmx Create Channel VI's and DAQmx Start Task VI's. The producer loop feeds a display on the front panel with the sensor values and this hopefully is refreshed at the 50Hz I have asked for. Secondly the loop bundles up the waveforms and puts them in a queue where they are picked up for logging by the consumer loop. In the consumer loop I have a wait 1000ms timer and a Write to Measurment File Express VI to do the logging. This is supposed to log at 1 per second.
    The queue is set to enqueue at opposite end, and the max queue length is set to 1. I.E. I only want to log the value at that specific second, but I want to show the data on the front panel at 50 times a second.
    Now heres my problems:
    1) I replaced the DAQmx Create channel's with a MAX project task wired into my DAQmx Start Task VI. As expected the thing picks up and displays the sensor values as it did before. However there is now a problem logging. Before when I had the DAQmx Create Channel, the logging recorded my values correctly at 1 second intervals. The time stamp in the X column went up by 1 second for each set of results. But now, with the MAX project task (needed because of custom scales and differing min/max values for different sensors), The logging still seems to happen at 1 per second, but the time stamp intervals are the same as the sampling rate set in the task!!! (ie at 50Hz the time stamp goes up 20ms for each result even though the results are being recorded at 1 per second)
    2) The timing just seems out of whack.
    I keep getting errors that the requested data no longer exists, that it was there but then was over written. Increasing the buffer size or sampling rate is supposed to remedy this... but what sampling rate? the rate set in the task? or the loop iteration speed? I dont understand.
    Secondly, despite telling my consumer loop to wait one second between picking up stuff out of the queue to log, it seems to be going round nearly the same pace as the producer loop. To top this off the producer isnt going round at the speed I asked it too either! I put indicators on the loop counters to see this. they are going round at maybe 2Hz.
    I have included my VI's
    What am I doing wrong, its really bugging the crap out of me!
    Attachments:
    EngineMon.zip ‏90 KB

    The reason you would use get time and date in seconds to to ensure that you log every second. If you use the 1 second wait then you do not take into account the exicution time of your loop. If you add more to the loop in the future than you will see that you do not log every second as you thought. If you loop took 500ms to exicute and you have the 1000ms wait then the actual excution time for recoding to file is 1.5 seconds not 1000ms as you desired. The way I did it will always give you one second unless you exicution time for your loop exceeds one second.''
    I did make one change to the vi. I shoulod have put the write in the true false case so that the write only happens when the 1 second has expired.
    Tim
    Johnson Controls
    Holland Michigan
    Attachments:
    VDU3.vi ‏59 KB

  • Input and output on same device, producer/consumer structure

    Hello interested people,
    I have a question about using the same device for both digital inputs
    and outputs.  I have written a simple program of one while loop
    that continuously polls the device, processes, and requests.  I
    have addressed the device using two DAQmx Asst. and I have attached
    them with their error in/out cluster terminals to provide data flow and
    eliminate the chance of addressing the devices at the same time (which
    produces an error).  Now I want to change this program structure
    to a producer/consumer loop foundation with state machine.  
    In this design, I will have the DI in the producer loop and the DO in
    the consumer loop, under one of the states.  I can't simply
    connect the error in/out ports in this configuration, so my question is
    how to avoid the error caused by addressing the same device
    simultaneously with two different tasks (input and output)?  I
    have attached two VI's, the "One Loop" vi is the original configuration
    (simplified), and the Producer-Consumer vi is a NONSENSICAL program
    that simply represents the desired configuration.  (I don't need
    any comments on the programming of this vi, it is only an example for
    illustration of the problem). 
    I am thinking about bundling the input data and the error cluster, both
    from the PXI 6528 DI, into one cluster, queueing that up, and
    unbundling the de-queued elements for some kind of data flow between
    the producer loop and the "Request" state of the consumer loop. 
    Is this the right approach, or am I barking up the wrong tree?
    Thanks
    Attachments:
    One Loop DO DI.vi ‏102 KB
    Producer-Consumer DI-DO.vi ‏106 KB

    Hello,
    It sounds to me like you really have two modes:
    1. user interface actions determine execution
    2. user interface is locked, and execution is automated.
    I think it would make sense to use the producer consumer for an architecture.  Basically you would do the following:
    1. program the producer to handle the user interface as you normally would.
    2. provide one additional event case in the producer which would be your "automated handling" case.  In that case, you could put a state machine which could run until whatever conditions were met to put your program back in "user interface mode".
    Keep in mind that you can use custom USER EVENTS to programmatically generate events ie. you can trigger the start of your "automated handling" form anywhere in your code at virtually any time.
    I think this would allow you to take advantage of the producer consumer architecture in its intended spirit, while integrating an automated routine.
    I hope this helps!
    Best Regards,
    JLS
    Best,
    JLS
    Sixclear

  • Producer/Consumer Design Pattern with Classes

    I'm starting a new project which involves acquiring data from various pieces of equipment using a GPIB port.  I thought this would be a good time to start using Classes.  I created a GPIB class which contains member data of:  Address, Open State, Error; with member vis such as Set Address, Get Address, Open, Close...general actions that all GPIB devices need to do.  I then created a child class for a specific instrument (Agilent N1912 Power Meter for this example) which inherits from the GPIB class but also adds member data such as Channel A power and Channel B power and the associated Member Functions to obtain the data from the hardware.  This went fine and I created a Test vi for verfication utilizing a typical Event Structure architecture. 
    However, in other applications (without classes) I  typically use the Producer/Consumer Design Pattern with Event Structure so that the main loop is not delayed by any hardware interaction.  My queue data is a cluster of an "action" enum and a variant to pass data.  Is it OK to use this pattern with classes?  I created a vi and it works fine and attached is a png (of 1 case) of it.
    Are there any problems doing it this way?
    Jason

    JTerosky wrote:
    I'm starting a new project which involves acquiring data from various pieces of equipment using a GPIB port.  I thought this would be a good time to start using Classes.  I created a GPIB class which contains member data of:  Address, Open State, Error; with member vis such as Set Address, Get Address, Open, Close...general actions that all GPIB devices need to do.  I then created a child class for a specific instrument (Agilent N1912 Power Meter for this example) which inherits from the GPIB class but also adds member data such as Channel A power and Channel B power and the associated Member Functions to obtain the data from the hardware.  This went fine and I created a Test vi for verfication utilizing a typical Event Structure architecture. 
    However, in other applications (without classes) I  typically use the Producer/Consumer Design Pattern with Event Structure so that the main loop is not delayed by any hardware interaction.  My queue data is a cluster of an "action" enum and a variant to pass data.  Is it OK to use this pattern with classes?  I created a vi and it works fine and attached is a png (of 1 case) of it.
    Are there any problems doing it this way?
    Including the error cluster as part of the  private data is something I have never seen done and ... well I'll have to think about that one.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • 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

    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.
    National Instruments
    Attachments:
    ImplementedProducerConsumer.zip ‏250 KB

  • Producer consumer vs state machine

    Hi there,
    I have been on and around for quite a while to understand how can I re-design an application, which was originally built using a mix of sequence structure, while loops and event structures. And now I am making a newer version of the same application, for research purposes, while learning the LabVIEW techniques. Earlier I used LabVIEW versions 5 and 6 to make simple programs for fuzzy logic and neural networks. And that's not a good reference.
    Ok, after learning that Producer Consumer (PC) and Standard State Machines (SSM or SM) are two new approaches for a better (scalable, flexible and efficient) coding as suggest by veterans, in one thread where I asked about another issue, I have started digging into this topic and now I am on a point where I have to implement it finally (spent pretty much time in the learning phase).
    I have several questions.
    To start the discussion, I would give a brief description of my application.
    It's a networked application, where the network communication happens using DataSocket (one reason to use LabVIEW as the environment).
    We are talking about the client application, which communicates with other applications on remote computer, via Internet.
    User interface involves a tab control, with several pages-
    On startup, the controls/indicators (now onwards referred as controls only), are initialized, datasocket connection is checked (rather internet is checked, and a connection established with the remote datasocket server) (page 1)
    If connected to the datasocket server, the user selects Login/Registration (page 2)
    Login and/or Registration happen on page 3/4
    Then the user sees a table of remote users to connect to (page 5)
    Upon selection of a remote user, and after clicking on "connect", the user will see a video indicator, with a lot of other controls. (page 6)
    On this page with video indicator and controls, the user has a lot of activities, in which many messages are sent and received to/from the remote machine.
    the user may disconnect and go back to page 5, and log out and go back to page 2 and so on.
    I hope this is clear.
    I have thought about two different ways to do this application. Using PS or by SSM.
    In the attachments, I have given a diagram (with errors, of course, because of unlinked controls), for each of the approach, plus the original application's diagram.
    I hope this is sufficient for anybody to understand my case and give suggestions.
    I am looking for suggestions about which is a better model for my type of case. I have been to discussions like this one and saw that there are many issues regarding dequeue in PC model. So I am curious to know if SSM is a better and latest model or it's more primitive? Which looks better for my application's performance?
    Thanks ahead!
    Vaibhav
    Attachments:
    OldDesign.vi ‏41 KB
    PCDesign.vi ‏42 KB
    SSMDesign.vi ‏46 KB

    Vaibhav wrote:
    @ Harold
    Thanks. Any suggestion how can I start and stop that loop in parallel with other loops? Like, if some event occurs, the loop should start execution, and keep on moving, while other events are being traced and executed.
    In those examples where you had a while loop inside a case structure, that bit of code will only execute one time.  It will immediately read the boolean at the start of the program, if the value was true before the porgram started, then the while loop will run.  Once that while loop stops, the case structure will end.  It will never execute again unless you completely stop and restart your program.  If the boolean is false before the program starts, the false case will execute immediately.  Nothing happens since it is empty and it is done, never to run again (unless you stop and restart your VI)  You should turn the structure around.  Put the case structure in the while loop.  Make sure you put a small wait statement in the loop so that it doesn't run full speed eating up CPU cycles just polling the status of the boolean.
    @ Ravens
    Thanks for the detailed comment.
    One thing I would clarify. The user will not be able to switch between the pages using the tab control. The program will direct appropriate page to the user. I kept the tabs visible just for your idea of the pages. Sorry, I didn't mention that.
    Do you think it's still a bad design?
    If the tabs will be hidden or disabled, you will probably be okay.  I wouldn't call it a bad design.  I wouldn't do it that way.  But as long as you understand the possibility of problems and prevent that.  Especially some time down the road when you modify the program in some other way that could lead to a problem because you forgot about the dependencies of the event structures on the state of the state machine. 
    Yes, I agree about only one event structure to handle all the events. But since the user will not be able to click somewhere else, other than those possible controls, I thought to keep it like this.
    I thought the events are captured only if we are in that case. I think I am wrong, right? Events are captured at any time, even if the case has never executed before, or will never execute.  Ok, The events will be captured, but will not be executed until in that case.
    And that's the reason why I have two separate event structures, in two separate phases of the program.
    Because, prior to page 6, the events will occur sequencially. The user will click somewhere, then some message will be transmitted over DataSocket, then some message may come , then again some user action and so on. But, when the user starts using page 6, there will be parallel process of user controls events and actions, and incoming messages and corresponding actions. For this, in the page 6, I need a different kind of execution. So I separated the two event structures.
    At first I thought to have SSM, and then I thought to PC, just because I can have two separate parallel processes - one for user events, and another for messages (because that way I can take maximum advantage of message tracking). But looking at other complexities, I find SSM more appropriate. Can you please tell me how can I have my message loop and events loop parallel to each other and just one event structure?
    You can have a dequeue function in your state machine loop and have it be a consumer loop.  Use a timeout on the Dequeue.  If there is a timeout, have the statemachine execute normally after that perhaps just passing the enum wire straight into the case structure of the state machine.  If it doesn't timeout meaning you got a message, then look at the message that is dequeued and act on it.  Perhaps it means ignoring the enum coming in from the shift register and changing the enum to something else to feed into the case structure of the state machine.  Attached is an example
    Attachments:
    PCDesign[1]_BD.png ‏6 KB

  • Producer/consumer w/ScanEngine issue

    All,
    I have a large VI implemented with producer/consumer architecture using 10 events and uses conditional disables to select the data acquisition hardware.  The application is being developed in LV2009 with FPGA & RT on XP.  The application is intended to acquire and control analog signals in a cRIO-9073, but early development is done using LV simulated signals.  I can switch back/forth between the different configurations quickly & easily.  In the simulation mode, the front panel, controls, events, etc; all behave as one would expect.  When the conditional disable is changed to use ScanEngine and cRIO modules, then a very primary control fails to generate an event and does not function.  All other controls that can be tested are functional and generate their events.  I am at a loss and seeking suggestions on techniques to diagnose & fix the problem.  The application behaves as if the 'event structure' for primary control gets corrupted or some size threshold is been exceeded.  The whole concept, scanEngine based and simulated data, were functioning several days ago prior to numeruous edits and I can revert back to not using the scan engine and cRIO hardware with simulated data to validate correct function, but that is not the intended final path.  At the present time, I am stuck and looking for ideas.  All suggestions will be considered and appreciated.  The applicatiion is company proprietary and can't be posted.  Thanks in advance.

    I can definitely understand your confusion, and on the surface it seems like everything should transfer over.  However, when using simulated data you won't get errors that can occur once you introduce hardware.  Errors can prevent events from occuring, there is also the issue of timing, to see if when using actual hardware, the timing causes issues.  As I menationed before, there are a hundred different reasons why it would work with simulated data, but not actual hardware.  Please let me know if you need further direction in your troubleshooting.
    National Instruments
    Applications Engineer

  • Producer Consumer Issues

    Hi all,
    I'm creating my first producer-consumer program, and I've run into a few problems.  I have two producer loops (one is a pressure controller and the other is power reading loop).  I've used queues to pass data into the consumer loop which records the data (at a much slower rate).  The problem is that the producer loop (the pressure controller) contains the stop signal for the program.  So I've had problems shutting down all 3 loops.
    My questions are......Do I have to shut down the consumer loop first, then the producers?  What is the best way to pass stop signals (local variables, booleans in a queue, etc)?   Also when I try to use the producer loop to stop the other loops I get the attached error.  Anyone have any recommendations for making an efficient stopping procedure?  The wait inside the consumer loop is quite long (5 min), so I'd like the minimize the stopping time, if possible.
    I've attached two versions that I've been working with.  They use version 8.5.
    Thanks in advance - Dan
    Attachments:
    Final Controller No Inputs.vi ‏274 KB
    Final Controller Other.vi ‏274 KB
    error.JPG ‏19 KB

    I like to stop the program in the producer loop, and wire the error output of the dequeue element function to the stop of the consumer loop (when the producer loop stops the dequeue element function will generate an error, the error out will cary this to the stop and the loop will stop).  Hope this helps!
    CLA, CLED, CTD,CPI, LabVIEW Champion
    Platinum Alliance Partner
    Senior Engineer
    Using LV 2013, 2012
    Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.

  • Producer/Consumer Design Pattern + DAQmx + Event Structure

    Dear community users,
    at the moment I try to implement the Producer/Consumer Design Pattern into my current project. For this purpose I am trying to make a "minimal-example" in which I use the Producer/Consumer Design Pattern for the data acquisition and analysis (display in GraphXY, calculation etc..) process. In the Producer Loop I perform the data readings via DAQmxRead.VI and in the Consumer Loop, in this example only, I display the data in a GraphXY. At the same time I want to control the data acquisition via an Event Structure, for example Start Measurement/Stop Measurement Buttons. To configure the measurement time, for example if the user only wants to measure 150 sec, I use the Time Out Event of the Event Structure. This is a technique which is often used, when data acquisition and Event Structures are used at the same time (Excuse me if this is wrong!). Due to understand the Producer/Consumer Design Pattern I looked up in the Template\Framework of LabVIEW.
    In the attachment you will find my "minimal-example", which -sadly-, not working. What should I do ? 
    Thank you.
    Best regards,
    tugrul öztürk
    Attachments:
    daqEngine_PCP.vi ‏35 KB

    Your VI will never stop due to the Ok Button that stops the producer loop is read OUTSIDE of the loop.  Add an event case for it.
    Move the Start and the Ok Button inside of their respective event cases.  This will allow the latch to reset when they are read.
    Change the Ok Button to a stop button.
    Use a Greater Or Equal instead of Equal for the measurement time comparison.  What if somebody randomly changes it to 0 on you?  Again, you will never stop.
    Is the DAQ only supposed to read for "Measurement Time".  Right now, it constantly reads.  So if you don't use the DAQmx Read, you will get a buffer overflow error.  You need to put the DAQmx Start Task inside of the Start event case and then the Stop DAQmx Task inside of the Timeout event case when the measurement time is exceeded.  You should also perform the read regardless inside of the Timeout event case.
    I HATE telling the consumer loop to stop by destroying the queue.  You can look data that way.  Instead, send something an empty array.  In the consumer, check for an empty array.  If it is empty, stop.  Destroy the queue only AFTER BOTH LOOPS HAVE COMPLETED.
    You should also report your errors in some way.  Simple Error Handler at the minimum.
    Since you are using Continous Samples, don't limit the buffer.  Leave the Samples per Channel unwired on the DAQmx Timing VI.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Producer consumer loop array building

    Hello,
    I am trying to build an array in the consumer loop of a queued vi. This is the first time I have tried to use a producer-consumer structure since class many months ago. Each element is queued and sent to the consumer loop, and in that loop I want to build an array of the elements before I save it to disk. For some unknown reason I am having trouble accomplishing this. Usually I throw this stuff into a for loop, but here it isn't working.
    I am converting the random number to a string in the producer loop because when I build the real program I will be using strings.
    What am I missing?
    Tay
    Attachments:
    Loop test.vi ‏35 KB

    Just built your array in a shift register.
    (The error case is simply wired across.)
    Message Edited by altenbach on 05-16-2008 08:03 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    looptest.png ‏8 KB

  • Releasing Queue in Producer Consumer model

    I am having a VI which reads data from ethernet,writes to disk,processes and displays. Since lot of processing and displays are there, I am converting it to a Producer- Consumer model so that no data is lost.
    I am using 2 loops. IN the Producer I am doing the UDP read and Write to disk functions.and use the enqueing also.In the Consumer loop I am dequeing it and do all the processing and displays.My idea is to avoid any data loss in UDP reception and file writing.
    My confusion- where to use the release queue?from the Producer or Consumer ? In a third loop ? Should it be in a sequence structure ?
    How to set the loops stop conditions ?
    My requirements for stopping - when I press the stop button the program should stop completely(the Consumer loop should stop only after dequeing and processing all the data in the queue).  If i don't press the stop button the whole program should run continuously (if data does not arrive for some time it should wait without time out-i am using -1 for the time out condition in UDP read.)

    Here is the ultimate Producer-Consumer loop.  It queues a stop command when the stop button is pressed.  This ensures that every element is dequeued and processed before the bottom loop stops.  The last queue data to get processed is the stop command because after you press the stop button, the top loop stops enqueueing more elements. 
    If your data type is other than a string, you can create something to represent stop, like NaN for a numeric. 
    Notice the shift registers.  This is good practice.  Every loop starts with an error out of the previous loop.  If an error occurs, it is passed on to the next loop iteration.  Also, if an error occurs in the consumer loop, the loop stops.  It is good practice to put shift registers on the queue reference also, but not necessary in this case.  If you use a For loop, and the loop iterates 0 times, the output of the queue reference would be a null reference, and the Release Queue would not release the queue.  With While loops, they always iterate at least once, so it isn't necessary.  Its just good practice to make a habit of using shift registers so you don't forget when using For loops. 
    Notice also that the error in to the Release Queue is not wired.  If there were an error, the Release would not take place.  All errors are merged at the end to report exactly where an error occured.  A timeout is included in case an error prevents the stop command from being enqueued or dequeued.
    - tbob
    Inventor of the WORM Global
    Attachments:
    ProducerConsumer.vi ‏53 KB

Maybe you are looking for

  • Help!! after I upgrade os vga card does not work with my ipad2...

    I use ipad2 my class presentations. VGA cable was fascinating to show most of ipad screens, but after I upgraded os it does not working any more.... os bugs? Please give me advices.... I need to use it this week! Dan

  • Acrobat x Pro 10.1.3 suddenly stopped working

    Today Acrobat suddenly stopped working insofar as it just would not start. Looking in the task manager shows it starts then stops. This is on a Win 7 x64.

  • Ios6 - wifi log in does not appear for secured network

    Hi, I installed ios6 on my ipad2 last night. Today - when I connect to a secure wifi network via settings, the log in screen does not appear, like it used to do automatically. Is this an issues with the OS? Can anyone suggest a fix or a solution? Tha

  • Query regarding finding Business Partner from the External Number

    Hi Group, I have a requirement to update Address of the Business Partner from the External Number and then using that Business Partner I have to update the Address. Now the question is that, <b>how I can get the value of the Business Partner by using

  • About disable the cellular data function

    Hi everyone, I get a big problem... I have just come back to HK after my holiday. I'm really sure that I had turned off the cellular data function when I left HK. However, I was really surprised  when I received the bill. There is a big charge for da