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.

Similar Messages

  • 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

  • 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 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 simultaneous operations at different frequencies

    My goal is to do two operations simultaneously.
    The desired end result is:
    1)      Produce an output signal which oscillates at a specified frequency (1 to 10 hz)(using DIO NI-9403). This signal will cause a solenoid to vibrate at different frequencies.
    2)      Monitor voltage on 3 lines in real-time (using analog input NI-9201). This will monitor system response to vibration.
    3)      Produce an output signal which oscillates at a different frequency from (1) – producing 1-second HI values 5 seconds apart. This will cause the system to “pulse”; system response will be monitored.
    4)      Have a front-panel user interface where: the signals in (2) can be monitored; frequency of (1) can be monitored and changed; and the output on (3) can be monitored and changed.
    My efforts so far have been to build a producer-consumer structure. This is my first time using this structure so I may be completely misunderstanding its use. Feel free to correct me if I’m way off target.
    The issue I have is the solenoid in the consumer loop (which handles item (1)) is not operating at the desired frequency. It is too slow. I used a 10ms timer for this loop, but instead it is operating about 1 cycle per second.
    There may be a much better way to approach this, or maybe my program only needs some minor tweaks. Either way, thanks in advance for your help.
    Attachments:
    ProdComsLoop Pulser 2-27-14.vi ‏65 KB

    Hi BradleyDDC,
    It seems from your program that you don't need a producer consumer loop. The only thing you are feeding from one loop to another can be put in one loop, I mean the simulator on button.
    The timer does not determine how fast the loop runs in real time. To get more precise timings, we recommend hardware timed operations as opposed to the software timed ones.
    Instead of using a digital output signal, you can use a counter output task, here is a knowledgebase, which has an example of what you may want.
    Paolo F.
    National Instruments
    Applications Engineer

  • Producer-consumer: optimize data acquistion rate

    I have a producer-consumer type of application in which one loop continuously reads data from the card and queues it and another loops reads/saves data. Additionaly one more loop plots the data. The number of channels and real-time analysis is defined by the user so the time it would take to save, display, and analyze each block (one iteration of Analog/Digital Read) of data may vary for different settings.
    Currently I am setting the "number of samples to get" large enough on the Analog/Digital Read at the start so I don't get queue overflow. Now I would like to adjust it automatically while the program is running so I don't get any queue overflow and at the same time the data is not display in huge chunks at a time. Has anyone done this sort of thing before? Right now the only idea I have is to read the # of elements in the queue continuously and use some mathematical formula to increase or decrease # of samples.
    Solved!
    Go to Solution.

    Abdel2,
    Reading the number of elements in the queue continuously and using a mathematical formula to increase or decrease the number of samples would be a great method. You could also use the Decimate 1D Array Function to display a smaller grouping of your data if your issue is that you don't want to display huge chunks of data at time.
    Ben Sisney
    FlexRIO V&V Engineer
    National Instruments

  • QSM (Producer/Consumer) Template

    Hello everyone. Before I start with my project (instrument control and data acquisition) I made a template using the JKI State machine template and converted to queued based state machine with producer/consumer loop. Basically, I wanted to separate the processing i.e.. data acquisition etc. from any front panel activity i.e. button press etc. Since I've worked with JKI template quite a lot, I'm used to the idea of string based queues and the layout of the template itself, so I just modified it to better suit my needs.
    I checked the JKI Producer/Consumer design at: http://forums.jki.net/topic/1347-jki-state-machine-producer-consumer-loop/, but it wasn't quite what I wanted since if my hardware (i.e. motor) reaches a certain limit (safety issue) I have to terminate the process (easily accomplished with the above example), however, if user decides to intervene (HARD STOP), then the process wouldn't terminate on the second loop. 
    Anyway, above is just an idea of what I'm in to and attached is a template I decided to do with QSM Producer Consumer style.
    I would appreciate any comments/improvements that you might be able to do in this template.
    Thanks 
    Kas
    Attachments:
    Qued State Machine.zip ‏96 KB

    Thanks anyway.
    Regards
    Kas

  • Producer/Consumer Multi-Microphone Capturing

    I was getting buffer overflow problems when I foolishly used multiple "Capture Sound" Express VIs to listen to several mics and process them. 
    I then created a producer/consumer structure where I produced 2 signals (2 producer loops) and processed them in 1 loop. It worked great!
    I expanded this idea today to 3 microphones (and hoped for more later). Trouble is I'm getting errors again. I can't quite explain the errors, so I've attached images (in sequence). By highlighting execution, it seemed the error happens on the SECOND iteration of the "Sound Input Read" in each of the 3 "Producer" loops.
    I hope someone can shed light on this issue. Seems strange that it would work for 2 mics but not for 3.
    I briefly tried playing with the sampling rates with no apparent results.  
    Message Edited by ap8888 on 03-17-2010 07:43 PM
    Solved!
    Go to Solution.
    Attachments:
    New2.vi ‏1074 KB

    Here are the errors:
    Attachments:
    greenshot_2010-03-17_20-27-23.jpg ‏291 KB
    greenshot_2010-03-17_20-27-34.jpg ‏503 KB
    greenshot_2010-03-17_20-29-01.jpg ‏253 KB

  • Progmatically stop vi with producer/consumer architecture

    I can't seem to get my VI to fully stop, so that I can go on to do some more things in the program.  I am trying to progmatically stop the vi (pictured below), so that I can return to my main gui (not pictured).  The main gui just consists of a login, exit test system, and run test.  Once the user presses run test, the vi pictured below opens.
    I am using a producer/consumer architecture with a state machine.  The problem I run into is that when I press the "Main Menu" button, it should close the pictured vi and return to the main gui.  I tried using the vi server, and when the user presses the Main Menu button, it fires an event and then it goes to the Stop state in the consumer loop, which opens a reference to the vi's (one for the strip chart vi and another for the gage vi), closes the front panel using an invoke node and then closing the reference.  I also tried adding in the abort vi method after the close front panel and it still gave me the same result.
    Here is the catch, it does close the vi's, but it does not stop the while loops (producer and consumer), or it stops only one of the loops.  I thought of putting in a constant in the event structure for when the Main Menu event is fired, but that will stop the producer loop before the consumer loop reveices the info to go to the stop state, so the consumer loop does not end.
    I also tried a "dummy" control that was connected to the comsumer loop Stop terminal (for the while loop), and then progmatically changed the value in the stop case to true and then read that value in the producer loop to, hopefully, stop both loops, but it did not work either.
    I am sure that it is something so stuipidly simple that I cant see it right now
    Kenny
    Kenny
    Attachments:
    test system.gif ‏252 KB

    Hi Kenny,
    I think of two solutions to your problem. First, use the message queue to pass the message "stop" or something from producer to consumer or second (and I think, better), use occurrences. I made a little draft how it could work.
       You have to pass the occurence- Refnum to both VIs, the producer and the consumer, when the producer finishes execution, then use "Set Occurence".
       In the consumer blockdiagram you react on the generated occurrence.
    If you set in the VI- properties "Open Frontpanel when called" and "Close if originally..." the VI Frontpanel should disappear itself when execution is stopped.
    Hope this helps,
    Dave
    Message Edited by daveTW on 08-14-2006 04:53 PM
    Greets, Dave
    Attachments:
    occurrence 1.png ‏1 KB
    occurrence 2.png ‏5 KB

  • How to change the transmissi​on rate of data flow in producer/ consumer pattern

    Hi All
    I am new to labview and trying to design a application to transfer image data in different rates, that means I can change the transfer rate in the transmission process. In fact,I refer to the the Queue Basic.vi to achieve this function by Changing the delay value of dequeue and enqueue.The program is divided into three parts:
    The first part is the sender in vc used to split and send image data.Data size is 226kb and each time we send a 1kb packet;
    The second is labview rate-change part,use producer/ consumer pattern and queue to transfer data;
    The third one is the receiver in vc,receive data in sequence and synthetic images.
    The entire transfer process is: image data was sent from the sender to producer loop through DLL, then enqueue--dequeue in consumer loop--DLL--receiver.The sleep time in vc sender is equal to the delay value in producer loop and this makes it look like the data generated as in the loop.
    Now this is where my dilemma is:
    When transferring data, if the producer loop and consumer loop delay value are equal(both 20ms), I can see image synthesis at a constant speed and no data lose; if I change the consumer loop delay value and make it greater than the producer delay(one is still 20ms and another is 50ms),that means receive in a lower rate and store data in queue. I can see Elements in Queue
    increase but the image data randomly lost, and the image synthesis speed is not reduced.
    My question is why image data loss and I can't see the image synthesis speed reduced when change the delay value in consumer loop?
    Do anyone know how to solve the problem? Are there any examples I can refer to? Any suggestions are greatly appreciated!
    Attachments:
    image1.JPG ‏56 KB

    thisoldman,
    I don't have '/usr/lib/modules/3.17.3-1-ARCH/build/Documentation/VGA-softcursor.txt' on my file system. Does it contain the info about changing the blinking speed?
    P.S. The other two links I found yet before starting this thread. I only found in them the recommendations about changing "the color and shape of the cursor and turning blinking on/off" (as I mentioned in the original question). Did I miss the info about the blinking speed?
    PPS: I found the vga-softcursor.txt here: https://www.kernel.org/doc/Documentatio … cursor.txt
    But that file doesn't tell about changing the blink rate either.
    Last edited by nbd (2014-11-23 20:55:41)

  • 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

  • Can anyone tell me what's wrong with my queue or producer consumer loop?

    A Labview engineer helped me with the overall structure of my program, necessitated by the fast data sample rate and post processing requirements. He recommended the producer/consumer loop and using one of the example files (Cont Acq graph voltage - int clk) to do the actual data acquistion. So I put together the loop and go my two channels of data acq going in the producer loop. However, nothing's getting picked up in the consumer loop and none of my data gets displayed over there.
    Anyone care to take a look at it and let me know what I'm doing wrong?
    Solved!
    Go to Solution.
    Attachments:
    P-C Yanmar Program.vi ‏296 KB

    Your Enque Element should be inside the while loop where you aquire the data.  As it is now, the data has to stop being aquired before you send the last set of aquired data.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Time Stamps in Producer/Consumer Setup

    I am trying to acquire signal from a Gas Analyzer, Flow Meter, and 3 RTDs.  My hardware is a NI 9215 and NI 9217.  I need to write the data to a file with a time stamp at which the sample was read.  The program is written in a producer/consumer setup in which the data is being acquired in the prodcuer loop and sent to the consumer loop to be written.  I can get the samples written to the file okay. However, I have not figured out how to put the time stamp in the data file correctly. I thought the time stamp was created with the corressponding measurement at the Data Acquisition VI. However, whenever I open the data file, there are only 0s in the time column.  So, I've tried to use Format/Date String to add the time stamp. I can get it to work if I place it in the consumer loop. However, the time stamp is not accurate.  It puts the same time stamp up to six digits of precision for two consecutive samples. I've tried to figure out how to add it to the producer  loop, but I don't know how to add it and the measurements to the queue at the same time. Please tell me the best way to acquire signals with the exact time stamp and write them to a file using a producer/consumer design.
     Example:
    Date             Time               RTD1     RTD2      RTD3     CO2      Flow
    5/26/07      5:20:01.25       57         56         56.5      100       0.5
    5/26/07      5:20:01.30       57         56         56.5      100       0.5
    5/26/07      5:20:01.35       57         56         56.5      100       0.5
    Attachments:
    Producer-Consumer From Scratch2.vi ‏75 KB

    Okay, I've put it in a For Loop and it will connect now. However, whenever it runs the time stamp increments for a couple seconds and then it just repeats. How do I correct this?
    Attachments:
    Producer-Consumer From Scratch2.vi ‏88 KB
    pleasework.txt ‏20 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

  • Running subVI in parallel with itself using producer-consumer pattern

    I'm using the procuder-consumer pattern to create what I call threads in response to various events much like in Producer Consumer with Event Structure and Queues
    I have several physical instruments, and would like to run the exact
    same test in parallel on each of the instruments.  I have a subVI
    that takes as inputs a VISA resource and a few control references among
    other things and then performs the desired experiment.  I have a
    separate consumer loop for each physical instrument, with this subVI
    inside each consumer loop.
    My test VI worked great; each consumer loop was a simple while loop
    incrementing a numeric indicator (not using my real subVI above). 
    However, my real program can only run one consumer loop at a time much
    to my dismay.  Reworking my simple test VI to use a subVI to
    increment the indicator rather than just explicitly coding everything
    resulted in the same problem: only a single consumer loop ran at a time
    (and as I stopped the running loop, another would get a chance to
    begin). The subVI in this case was extremely
    simple taking only a ref to the indicator and a ref to a boolean to
    stop, and incrementing the indicator in a while-loop.
    Is there a way around this?  Now that I've spent the time making a
    nice subVI to do the entire experiment on on the physical instrument, I
    thought it would be fairly trivial to extend this to control multiple
    instruments performing the same experiment in parallel.  It seems
    only one instance of a given subVI may run at one time.  Is this
    true?  If it is indeed true, what other options do I have?  I
    have little desire to recode my subVI to manually handle multiple
    physical instruments; this would also result in a loss of functionality
    as all parallel experiments would run more or less in lock step without
    much more complexity.
    Thank you.

    You need to make your subvi reentrant.  Then it can run several instances at any time with each instance occupying its own unique memory space.  Click on File - VI Properties - Execution, and check the reentry execution checkbox.  Then save the vi.
    - tbob
    Inventor of the WORM Global

Maybe you are looking for

  • How do I avoid crash/burn/lock ups when install FF3?

    Hi, I've tried to install FF3 three times since it came out. Each time was a disaster, favorite bookmarks were erased and any attempt to do an internet search locked up the computer, it took weeks to solve each time. I've learned to hate and fear FF3

  • Error 13019 when trying to sync my Ipod Touch 3rd generation

    For the past two days, I have not been able to sync music unto my Ipod. It started when I tried to sync two new albums onto my Ipod, but one album would not sync (the other album did). Every time I tried to sync it, an "unknown error 13019" popped up

  • Oracle BI  plug in needed for Microsoft Word 2007

    Hi Gurus, I'd like to add an Oracle BI plug in for Microsoft Word 2007 The OracleBIOffice.exe creates plug ins for Excel and Powerpoint only. I'd appreciate any help! Best regards Laszlo

  • Insert a current date

    hI., I am using jdev11.1.5 My scenario: When user clicks the button the values should be inserted i had used this coding in my AMImpl Method         ViewObjectImpl gjh  = this.getGlJrnlHd1();         Row gjhr1 = gjh.getCurrentRow();         Row gjhr

  • Image prep for iphoto calendars/prints/cards

    Hello folks, Is there a preferred edit procedure, size, resolution, sharpening, etc for images used in a calendar/card/book? thanks for your help Diana