Jump to content

Graph & Timing

Recommended Posts


This is probably a silly question but my mind is stuck!

Attached there is a simple voltage acquisition vi. The aim is to have a case structure in a while loop and acquire-plot data from a sensor when the case structure is true. The displayed data needs to be plotted against time in seconds starting from 0 and ending in Xsec. Each time the case structure is true, the x-y graph needs to display the new data with the time starting at 0.

The vi does not do that, instead the old data remains on the graph and on top of that the vi gives an Error -200279 after a while.

What am I doing wrong?

Voltage - Continuous Input.vi

Edited by Ano Ano
Link to comment

Your description doesn't make much sense relative to what your code is doing. Have you tried probing the wires going to the graph so you can see what you're doing? What about replacing the analog input value with a front panel control so you can test and simulate the behavior easily?

Link to comment

Have you checked the error description? It is defined as follows:

The application is not able to keep up with the hardware acquisition. 

Increasing the buffer size, reading the data more frequently, or specifying a fixed number of samples to read instead of reading all available samples might correct the problem.

The issue might come from the fact that you're in continuous sample mode, so the hardware is going to keep filling a buffer and your Read function is supposed to partially flush it each time, but you only flush 1 sample when the case structure is TRUE, and you don't flush it at all when the case structure is FALSE. So the buffer fills faster than you flush it and eventually gets full and generates the error. I'm not 100% sure of my description but it makes sense to me.

Also the way you generate your array of X for your graph is weird. You reset your timestamp shift register each time the structure is false. So when it becomes true again you don't compute the elapsed time since you started the VI, instead you get the elapsed time since the last time the structure was FALSE. Is that by design?

Link to comment

Thank you both for the prompt answers.

The application is for testing a strain sensor against an increasing load.

The aim is to start the vi and then press a start boolean button to start acquiring data until another boolean stops the acquisition. The acquired multichannel data need to be plotted against time, starting at 0sec and ending ie 10sec later. When the user presses the start button then the graph starts at 0sec and plots the new data.

Thus my weird X-axis if for counting the time passed in sec while the boolean is true and all this on-off is what is causing the buffer issues.

Any ideas?

Link to comment

A few problems with your algorithm.

  1. You need to read the DAQ task continuously to keep the buffer from overflowing (error -20027).  Move the DAQmx read outside the case structure.  That will clear the buffer even if you don't use the readings.  Also, get rid of the metronome timing function and let the DAQmx read function time your loop for you.
  2. If you don't want the old points from the last Boolean=true phase, reinitialize your shift registers with 0 arrays to clear the old data when your Boolean=false.
  3. Move the graph update into your Boolean=true case structure to retain data in the graph from the last run when boolean=false.

Hope this helps.  Here is the solution:




I should also add here (after re-examination) that the DAQmx read should be changed to NChan NSamp for multiple channels, and 1Chan NSamples for one channel, if you set up the task as 100 samples per channel at 1000 S/s (your defaults).  In your example, and my pics, you are only reading 1 sample out of the buffer for each channel.

Also, if you run in continuous samples mode, you will need to wire the "Number of Samples" control to the Number of Samples input of the the Read function to force it to wait for the number of requested samples.  Otherwise use the "Finite Samples" mode.

Edited by smarlow
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.