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

Similar Messages

  • Consumer for different frequencies

    Hello,
    what is the proposed architecture for consumer that muxes multiple producers with different frequencies ?
    Example: DEV1 goes 100 Hz, DEV2 goes 50 Hz. You need to mux the data together in order to get 1 list to simplify programming further and boost searching performance and so on. The cluster contains DEV1,DEV2 , when there is no new DEV2 you keep the last value there.
    I am deciding between multi-queue and functionalglobal. The queues seem better option to me.
    Let me know your opinions. Thank you !

    Dear Bublina!
    You are correct, queues are generally a safer and more reliable way of transmitting data between loops.
    The way I would do it is to have one single queue for all the producers with two items stored in the queue: 1 enumerated type and 1 variant. The ENUM can tell the consumer from which producer loop the data is coming from, and the variant can contain all the data sent. You can store the latest values of DEV1 and DEV2 in a shift register, and overwrite the one that was sent.
    Please tell me what you think.
    Regards:
    Andrew Valko
    NI Hungary
    Andrew Valko
    National Instruments Hungary

  • Simultaneous AO generation at different frequencies

    Is it possible to run two sine waves simultaneously from the same board, at different frequencies?
    example:
    Dev0/ao0...sine wave with amplitude = 10, freq = 1
    Dev0/ao1...sine wave with amplitude = 1, freq 100
    thanks for any replies.
    dave

    why not just set up 2 sine waveforms at the different parameters and send it to the AO write:
    Creat Channel->Timing (use waveform)->AO Write (using array of waveforms)->Start
    LV 7 example attached (uses DAQmx).
    2006 Ultimate LabVIEW G-eek.
    Attachments:
    simusine.vi ‏71 KB

  • AI/AO at different frequency

    Hi,
    As a newbie, I met a problem when I tried to input and output analog signal at different frequency.
    I followed PID-control-Multichannel.vi to build a control program, so input/output can be synchronized. However, the project requires that the AI frequency to be ten times of the AO. I could rewrite the while loop to make the output value constant for 9 of 10 cycles. However, I believe there is more straight forward way to do it.
    Could anybody provide an example?
    Thank you in advance.
    Sincerely yours
    Ming 
    Solved!
    Go to Solution.

    lmuri wrote:
    Hi,
    As a newbie, I met a problem when I tried to input and output analog signal at different frequency.
    I followed PID-control-Multichannel.vi to build a control program, so input/output can be synchronized. However, the project requires that the AI frequency to be ten times of the AO. I could rewrite the while loop to make the output value constant for 9 of 10 cycles. However, I believe there is more straight forward way to do it.
    Could anybody provide an example?
    Thank you in advance.
    Sincerely yours
    Ming 
    Hello Ming!
    Thank you for using the NI Forums. You'll be glad to know that DAQmx allows I/O tasks such as these to be ran not only concurrently but also at different rates.
    The problem with the solution you've devised is that this implementation will remove the delegation of the tasks down to the hardware level and your program would become software driven; this becomes problematic when running data acquisition tasks at very high speeds as you become limited to the output speed of your Operating System (OS).
    You can co-ordinate your tasks to operate synchronously and perform output and acquisition at different rates by creating a task master. This generally means that you configure a task through DAQmx that maintains a clock frequency and you create tasks which use this clock frequency, or a division of it, to operate at their own individual frequency. This will ease not only the implementation of synchronous DAQmx tasks but also provide an entirely hardware driven solution to maximimse performance.
    Through LabVIEW, if you go to Help > Find Examples to open the NI Example Finder. If you browse through Hardware Input and Output > DAQmx > Synchronization > Multi-Function > Multi-Function-Synch Dig Read Write With Counter.vi, you will find an example of how to configure a Counter as a task master to control the operation of both a Read and Write operation. (This example shows a digital implementation but may be easily replaced with analogue.)
    By setting the counter rate to the maximum frequency that you will require for your task (In this case, the speed at which you want to output values) and applying it to the output task SampleClock, you will drive the output task clock with the Counter as the clock source. You can then use the Counter as the source for the SampleClock for the input task, however set the rate to whatever division of the driving frequency you want. In the case of your example, you can set the input rate to 0.1 times the Counter Frequency to acquire at a 10th of the rate.
    If you wanted to acquire at the same rate but only retrieve values at the 10th of the speed, this same solution could be configured to instead produce a trigger to return a buffered acquisition. With a master clocking task, the opportunities are endless!
    I hope that you find this helpful, and if you need any more clarifcation don't hesitate to let me know. Have fun with your DAQ!
    Alex Thomas, University of Manchester School of EEE LabVIEW Ambassador (CLAD)

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

  • I want to add one Continuous function in Producer consumer event??

    Hello,
    producer consumer event vi is base example for me ,I have design my system according to it.
    Now I am dealing with photo sensor in that its measure continuous data according to intensity of light,for continuous function I have make while structure for photo sensor but the problem is that I don't know how to add this while loop in producer consumer event ,if I add then its run continuously and then my operation is stuck there.
    Will you please guide me that how can I add this continuous function in this structure so simultaneously I can do other function like pause reset..Etc...
    Here in attachment I have attaché one example regarding to this in that I have add simply increment function in case structure and when I execute my vi then execution is stuck at while loop until it manually stop.
    Thank you very much...
    Attachments:
    ProducerConsumerEvents 1.vi ‏15 KB

    Hi AnkitRamani,
    I made a simple example with a UI queue and a second producer which is pushing data into its own consumer, displaying the signal and its spectrum.
    Maybe this is what u need.
    Marco Brauner NIG
    Attachments:
    ProducerConsumerEventsData.vi ‏70 KB

  • LV producer consumer and TestStand

    In the TestStand process model, I've replaced the original Get UUT Serial Number dialog with a custom dialog that has some additional fields, and will (eventually) allow the operator to BarCode scan the serial number.
    I'm thinking about using LabVIEW's template for Producer/Consumer.  I basically want to allow the user to hang out at this dialog until the click on either "START" or "CANCEL".  They can tab to the different fields, and Scan in the serial number if desired.  What types of 'events' would I want to capture?  Is this even the right design pattern for this situation?
    Also, this dialog needs to be modal (in front of TestStand executive). 
    Thoughts?

    mrBean,
     By custom dialog do you mean a seperate VI that you open and show the front panel when the step executes?
    If that is the case the producer consumer might be overkill. From what I've seen one of the main reasons one would use this pattern is to seperate the acquisition loop from the data record loop. In that manner the data recording doesn't slow down the data acquisition. I've used a wedge type barcode scanner in the past and it is pretty easy to impliment.
    On a side note I really enjoy reading your posts on both of the forum boards. I too at some later date will be creating a custom operator interface using LabView and your questions have been really helpful in my formulation of a plan. Thanks
    Using LabVIEW 2010SP1 and TestStand 4.5

  • Basic Producer/Consumer loops for a newbie

    Labview neewbie here.
    I was looking at Producer Consumer loops.
    Can anybody give me a very basic explanation of how to set one up.
    I want to take readings from a HP 53131A counter and store them in an excel spreadsheet.
    I understand the part about labview slowing down as it opens the Excel file, and a seperate loop will help solve this.
    But I dont understad how to set up the Que function.
    Thanks.

    Multithreading will not make excell open faster but using concurrency you can have more than one operation operate ate different speeds.  The nice thing about the produce consumer model is that the if the consumer is slow or unreliable (freeses up) the producer doesnt care and will continue.  To use a queue is very simple, 1. create the queue, name it(optional) and give it a data type (ie int, array of floats ...)  in the produce loop use the enqueue vi to add items as needed to the queue, in the consumer dequeue these items (using a timeout = -1 the loop will wait for a new item and not consume resources)  the consumer can process the data acquired in the producer loop.
    Paul Falkenstein
    Coleman Technologies Inc.
    CLA, CPI, AIA-Vision
    Labview 4.0- 2013, RT, Vision, FPGA

  • 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

  • Finite pulse train with different frequency

    Hello,
    I'm trying to modify the labview example "generate finite pulse train" to generate a finite pluse train with different frequencies. Each freq will run 400 pulses. The freqs are stored in an array, which is being fed into a for loop. Thus ramp up the freq each iteration. However the program only generate 400 pluse at first given freq. I'm fairly new to daqmx and not sure what is wrong. Anyone have some idea how to fix it?  
    Attachments:
    pulse train finite mod.vi ‏38 KB

    The best "fix" will depend a bit on the needs of your app.
    Is it ok to have a fraction of a second without any pulses each time you change frequencies?  If so, then there's a pretty simple solution:
    1. Outside the loop you'd create a DAQmx virtual channel and configure for Finite Sampling (# samples = 400) using DAQmx Timing.vi.  
    2. Inside the loop you'd chain together a DAQmx Channel property node where you set the pulse frequency property, then perform a DAQmx Start, a DAQmx "Wait for Task Complete", and a DAQmx Stop.
    3. So for each freq in your array, you'll program the counter for that frequency, start the generation of pulsetrains, and then stop the task after 400 pulses have been generated.
    If you must change frequency on-the-fly, producing *exactly* 400 pulses at each freq setpoint will be tricky, and maybe even impossible to do reliably.  Some techniques will get you closer than others though, so post back if you need to do this.
    -Kevin P.

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

Maybe you are looking for