producer-consumer: optimize data acquisition rates

I have a type of producer-consumer of application in which a single loop continuous waiting there and reads data from the card and another loop readings/backups of data. But besides a loop more trace data. The number of channels and real-time scanning is set by the user, the time it would take to save, view, and analyze each data block (an iteration of analog-to-digital reading) may vary according to different parameters.

I'm putting 'number of samples to get' big enough on analog/digital playback to the beginning so I don't get the overflow of queue. Now I would like to adjust automatically when the program is running so I understand any overflow from the queue and at the same time the data are not exposed in the huge chunks at a time. Someone did he do this kind of thing before? For now, the only idea I have is to read the number of items in the queue at all times and use a mathematical formula to increase or decrease the number of samples.


The number of items in the queue of streaming and using a mathematical formula to increase or decrease the number of samples is a good method. You can also use the decimate 1 D table function to display a smaller grouping your data if your problem is that you do not want to display huge chunks of data at the time.

Tags: NI Software

Similar Questions

  • Synchronization of data from different sample of data acquisition rate

    I use a high RT 8135.  I'm sampling of signals from analog pressure thermocouples to 20 ms and 10 ms.  I use the stream network to transfer the data from the SMU on my host.  I would like to be able to synchronize the timestamps of all data to the 1ms sampling note and record in a file.

    Search in the file my sampling data 10ms end timestamp does not match the timestamp of 20ms, missing data... I know you have empty queues to get the rest data but is possible to interpolate any data to adapt a unique timestamp?

    Thank you!

    Hi aokada09,

    Looks like you are facing problems resulting from parallel execution two loops you have.  There is nothing necessarily bind the two loops together, so that each of them an iteration at the rates you specified, but are allowed to start each software (sort of random) dictates that they start.

    To get a solid synchronization, share a sample between the two measures clock, but run the sample clock at 100 Hz for 50 Hz for thermocouple measurement and pressure measurement.  You should be able to use shared inside the SMU chassis backplane clock.  This will be as close as possible to synchronize without using a card of timing.  The only real source of delay/tilt between readings at this point is the physical distance that must travel the clock signal. This will not lead to steep, but there will certainly be some (probably on the scale of the high-nanoseconds or microseconds bass).  This article gives more information about the synchronization and the sample clock:

  • How to divide 3 signals which are produced by a data acquisition Wizard?

    I've only been using LabVIEW for a few months without any type of training, so I don't know what's ridiculous or wrong. I checked the forum and LabVIEW help for something similar to what I want to accomplish, but I use the wrong words, questions or methods in general. No matter what help options or directions.

    I expect 3 incoming signals that will be accessible by a DAQ Assistant. A signal is the complete signal, the other two are part of the complete signal. Partial signals each separately multiplied by the full signal. How to separate the signals that are in dynamic data produced by the wizard DAQ in a way that I can apply these processes?

    Or, as I have already said, use the Signal from Split.

  • Error of timing architecture producer/consumer


    I use architecture of producer/consumer for the acquisition of measures of constraint by using several channels. Also, I am interested to write data all 1 minute given that the program should be run for a month. Currently, I get a 200279 error whenever I increase the time of 10 sec. To control the execution of the loop of producer, I use 'weight up to the next multiple ms' function. According to the error message, I tried to fix the samples to read without increasing the frequency of data acquisition, but I still get the same error.

    Thank you


    Your was not included, so we do not know what is happening there.

    What is the rate of acquisition for your data acquisition task?  DAQ hardware do you use?

    Have you tried to increase the size of the buffer?  There is a property node that can define it.

  • Producer/consumer or master/slave, acquisition, control, analysis and recording of data

    Hi all

    I have NEITHER cDaq-9188 and its modules NI 9214 (thermocouple), NI 9203 (HAVE current) and NI 9263 (AO tension). I need to measure the temperature and pressure, and according to these data, I need a frequency converter to drive a compressor control. I've developed acquisition, analysis and recording program by the use of the state machine, the design of producer/consumer model and I have no doubt about their. They all work very well. Now, I need to add a control program in their. The problem is that I need to check the compressor with feedback from temperature data permanently, but I do not necessarily all the data acquired and permanently from the results of the analyses. For example, I need to record data once in 30 seconds. Which model desing should I use for this task?

    Edit: I was not able to find examples of advanced program relevant to the design of master-slave model. If you know where to find them, could you write in this thread please?

    The declarant buffer not data.  Do only the queues.  A new notification replaces the old value if she is ever read or not.  You would be loss of data with the notifiers if the loop of consumers with a notification utility cannot keep up with the data that they fade.

    What I show all the data buffers through the queue in the loop of the producer.  The queue of the consumer removes all data and do stuff with him (such as logging) if the elapsed time is over.  What is the problem with that? That is what for (imstuck) described in his message.

    The other alternative is that you put the timer into the loop of the producer.  Have the Boolean value TimehasElapsed drive a deal structure this place only the data if the time is over.  In this case, only some data gets queued, and consumer loop removes all data as it gets and it opens a session.

  • acquisition and recording of analog data with producer consumer model

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

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

    Thank you.


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

    Take a look at this example:

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

  • Producer/consumer vs Master/Slave of data loss

    Hello users of Labview,.

    I did experiment with vs p / M/S lately in the context of data aquistion. Many messages did appear (correct me if I'm wrong) that p/c is the correct architecture to if the data retention is desired, so that's what I tried to implement.

    In the loop of producer, I've included 3 Assistant DAQ VIs (2AO, 1 HAVE), which generates data actively and which is being queued. I have 3 other loops of consumers, two of which are consumer 1) written loops of 2) outputs TDMS data of a chart 3) no producer: structure of the event, monitors changes to the user interface.

    When I run data acquisition, the generated file are always half either acquire the half of the sample that I've specified regardless of the sampling rate. I also have a strange displayed graph (see image).


    If I replace with a master/slave architecture, this seems to solve the problem.

    So question is: anyone met with this kind of problems? Are there disadvantages to stick with M/S instead of p/c in terms of data loss?

    Thank you

    johnji wrote:

    I think I'm well done

    You are not.  Once an article is removed, he went.  Since you have three loops made of the same queue, each loop will get ~1/3 of the data.  If all the loops are to treat everything, then you want another line for each loop and meet the producer, write to each queue.  You can also use a user event.

  • Producer / consumer set loop of dynamic data item type

    Hey all,.

    I do a simple exercise of producer / consumer in a loop. In my loop of producer I audio Aqcuerir and in the loop of consumer I'm projecting on a chart

    Everything works as I had in mind, the only thing that bothers me is the way that I had to set the type of the element to the block "Get the tail" at the beginning.

    I knew no better way to get the kind of data that I used to just take an another "acquire its" Express VI and which hang. But that may not be the only way to get there, right?

    Note: I know that I might not need to use a producer / consumer design tend to do, but I need to get hold of technology for school work so I came with this exercise just to get a hang of it.

    Thanks in advance,



    You just need to feed the correct data type in this entry, which you did by getting the output of a second acquire its Express VI.

    You can also use the "Convert to Dynamic Data" function to do this.  When you drop to the bottom of the function, you will be asked to give the input type.  Tests I've done, it seems not to matter, but for example if you chose the entry to a single scalar type, you need to feed a digital constant (change to double type) in the entrance and use the output of dynamic data such as line item data.

    I don't like the dynamic data type because it is not very clear as to what it is.  Another thing you could do would be to use the "Convert from Dynamic Data" function to change the output of the VI of its acquisition to a different data type for more or less to avoid the original problem all together.

  • How to stop an acquisition continues in producer/consumer


    I'm trying to use producer/consumer to control 'Start' and 'Stop' to my continuous data acquisition system. I can start the acquisition process successfully, but I can't stop it botton 'Stop '.

    I enclose my simplified VI. Can anyone help to have a look and tell me what is the problem here?

    Thank you


    As I said before, use a notification utility and manage the expiration time.  I used a select statement with timeout? Optional Boolean.  If a time-out of events, use the previous value.  If we got a notification, use this value.

  • Producer-consumer mode, PDM and Acquisition journal continues

    I created a VI based on events to control the parameters of data acquisition. I created a queue of producer-consumer in TDMS file in the loop of the consumer.

    Question 1: Why should I get DAQmx TASK through each defined event? If I don't, I get error task DAQmx.

    Question 2: I need the QUEUE of each event? If I don't I get error in the file close TDMS (consumer loop)

    Question 3: When I look at the data file, I get manily in the near TDMS file loop of consumer-related. Since there is no element in the QUEUE why should - I get this error.

    Please advice.

    Thank you

    This is certainly not how I would like to start to create a Soft Front Panel for a task to HAVE.  Leave to file logging asside for now (appearing, it is actually very easy to add later.)

    As food for thought - and because that create a FPS really involves a slightly different thought where you started I whip a 'start' of a FPS.  It also shows how to create a simple API around a 'resource Module.   (Just a natural extension of a "motor action - if you haven read the nugget of community is always a good read.")

    What I compressed is not complete - but you should get an idea of what to expand and where.  You could even have there more faster here than when you are now.

    An approach like that can really help when you go to unwind the problems as you mentioned in your code when you are unable to move around the information that the GUI can't really do use anyway and not IS NOT NECESSARY at this level.  the guys from 'Computer Science' will use terms such as 'Hide data', "Functional Abstraction" and "Encapsulation".

    The capture below is meant to tease the project so that others can get the idea of code - (sorry no LAVA TDC today! )

  • data acquisition won't taste at the specified rate

    Material: C - DAQ 9178, AI 9239, inside a servo and an encoder potentiometer module

    Setup: I use the 9239 to measure the angular position of my servo and encoder of trees by streaming came pressure pot of the servo and my encoder. I put the sampling frequency on the DAQmx - Schedule VI to 100 Hz.

    Problem: I don't think that my DAQ is sampling data at 100 Hz because my VI registers more than 10 000 data points for a 10 second test. In addition, every time I have save my data in a text file, the vector of time my test data resets after a number of iterations.

    To debug, I tried the following configuration:

    I've defined the sampling frequency of 100 Hz (or is that s/s?), the samples per channel (size of buffer for continuous mode) at 2000 samples, number of samples per channel up to 10 and loop milliseconds timer on my VI at 10 m accordingly, data acquisition would send 100 samples per second (or 1 sample every 10 ms) on my PC buffer (which could store 20 X that amount). Then LabVIEW would read up to 10 samples per loop iteration (which is itself ~ 100 Hz) and work with these 10 samples inside the loop. However, since the loop is operating close to the sampling frequency of data acquisition, then LV should only work with 1 sample each iteration of the loop (100 Hz / 100 Hz)-not the 10-sample-max that I specified.

    However, I stumbled on "error-200279: the application is not able to cope with the acquisition of material" when I ran the program. Why?

    My code and materials should be easily able to cope with data acquisition - at least the way I put it in place

    This whole situation wondered my fundamental understanding of data acquisition timing, so I would really appreciate an explanation of exactly how to deliver DAQmx uses data synchronization, why my DAQ sample at 100 Hz, and how can I fix the calendar specified by the user.

    Thank you!

    aeroAggie wrote:

    The C - DAQ 9178 there some minimum sampling rate I will not meet?

    It's actually the 9239 that limit your sampling rate.  Read the data sheeton page 5 there's available data rates.  In short, your data rate allowed is 50kS/s / n, where is goes from 1 to 31.  50 k/31 gives you 1.6kS / s.  So, it's the minimum sampling frequency that can be used.

  • Sample of high acquisition rate of data using data acquisition and continuous data backup. Also I would chunck data into a new file in each 32 M


    I'm very new to LabView, so I need help to find an idea that can help me to record data continuously in real time. I don't want the file is too big, so I would like a new file in Crete in each 32 mega bytes and clear the previous buffer. Now I have this code can save data of voltage in the TDMS files and the sampling frequency is 2 m Hz, so the amount of data very fast increase and my computer have more ram 2 G, then the computer hangs after 10 seconds, I'm starting to collect data. I need some advice you briliant people.

    Thank you very much I appreciate really.

    I'm a big supporter of the architecture of producer/consumer .  But this is the place that I recommend.  The DAQmx Configure Logging does all that for you!

    Note: You will want to use a table instead of a graph here.

  • export to spreadsheet - data 2 channels appear in alternation with loop of producer/consumer


    I'm having trouble with the function "Export the waveform to the worksheet" - but it is not clear to me if the problem is with how I use the export feature or if I am wrong concatenating two waveforms of different modules of the series prior to export, or if my queue is wired incorrectly for producer-consumer loops.

    I use a hunts SMU-1073 with SMU-6361 and 4330 modules (tension and strain). I tried to change the example of the "entry analog cross synch" for use with a structure of producer-consumer (see VI below).

    The output of the worksheet contains a large part of the data in the string tension, followed by a smaller piece of data (with timestamp) strain, after which the alternate output data between data of tension and strain.

    Can anyone suggest where I could go wrong, or how I could solve this?

    Attachments do not work, so I'll try to post in an empty message directly after this post.

    Thank you


    That's what I thought.

    A number of wire.  -1 gives all the samples available in the buffer (which can be zero for some reason any).  A number will expect that there are many examples.  If the two readings can wait until they have both the amount of data requested.  This way, they will also have the same number of samples and be better aligned in the text file.

    Your loop will continue to run until you press stop or get an error.

  • Data types in the design for the producer consumer model

    Is it possible for me to use any type of data in a model of design producer consumer, without specifying specific data type?

    what I mean is if there is a way to connect to a data type with which I can use any other type of data, not to mention that one that I have connected, and if not, how can I specify the data type for a number or any other data type, for use in a design of producer-consumer model?

    You can make a part of your cluster of data a Variant.  It will take any type of data.  A common architecture for the producer/consumer is a cluster which is an enum and a Variant.  The enum contains all possible "orders", you might want to send.  The variant contains data that could be of any type.

    Ungroup you in the consumer and get the enum and Variant.  Attach the enum to a case structure.  In the specific case, convert the variant type in a data type of regular LabVIEW and with it as you please.

  • Will be the leak memory for the queue when it is used in producer and mode of consumption data acquisition transfer different size table.

    In data acquisition, I use a loop to query the data from the hardware, another loop to receive the data from query sent by queue loop.

    Each time the size of the transferred data matrix is perhaps not the same, so the system can assign different table size and recycle frequently.

    It cost memory leak. Or it will slow down the performance, given that the size of the array is not fixed, so everytime need to create a new array of size.

    Any suggestion or the best method.

    If I understand your description, your DAQ loop acquires data with the parameter of the function of reading-'1 ' for reading at the DAQmx samples. This translates into different picture sizes.

    Passage of these tables directly to a queue is valid and she didn't mind important in performance (at least AFAIK) and it certainly does not leak memory.

    So the question is more or less:

    It is valid that the consumer receives sizes different picture for analysis? How your consumer manages these tables?

    hope this helps,


Maybe you are looking for