Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

RTSI with DAQmx (encoder-external scan clock continuous).vi example info and help

Hey all,

In the application I'm currently coding I'm using this exact example code, only with a read position function included in each loop iteration and the output wired to an XY graph instead of just waveform. Firstly, I'm encountering an error:

Error -200279 occurred at DAQmx Read (Analog DBL 1Chan 1Samp).vi:1

Possible reason(s):

Attempted to read samples that are no longer available. The requested sample was previously available, but has since been overwritten.

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.

Property: RelativeTo
Corresponding Value: Current Read Position

Property: Offset
Corresponding Value:


Task Name: _unnamedTask<17>

Can someone help me to troubleshoot this? I'm a bit confused by the fact that I'm only reading 1 sample and yet it appears as though I'm reading in too much and information is being overwritten. That said, I'm not sure why all the data points appear on my graph given the error.

The second issue is that I'm trying to optimize this code so that I can get data as quickly as possible while still maintaining synchronization... So I'm wondering how much leeway was built into the 25ms pause in the loop iteration, and any other tips for making it go faster.

Thanks


0 Kudos
Message 1 of 7
(4,865 Views)
Just an update - I've also wired a waveform chart up to the output of the read and while the xy-graph produces this error the waveform chart is OK. Problem is I want it in XY graph format. Also, in my previous message I wrote that I was not sure why it still displayed a graph full of points given the error, but I now realize I'm only getting data from a few degrees stretched over the entire x scale, but not so with the waveform chart.
0 Kudos
Message 2 of 7
(4,851 Views)
Hi FiberOptix,

The reason you are getting "Error -200279 occurred at DAQmx Read (Analog DBL 1Chan 1Samp).vi:1" is because the DAQmx buffer is being overwritten.  This is due to not reading data from the buffer fast enough.  The example should be using Analog Wfm 1 Chan N Samp for the DAQmx read.  The number of samples to read is set to -1 which means that it is going to read all the data available in the buffer every iteration of the loop.  This allows you to collect the data from the buffer fast enough before it is overwritten.  From your post, it looks like you have changed this to only read 1 sample.  This is why you are seeing the buffer overflow.  In addition, the reason that the chart is used in the example is because a chart contains history and can be updated with new data (with old data still remaining) each iteration of the loop.  With a graph, it is typical to collect all your data and update the graph once (outside the loop) at the end of your program.  This is because a graph doesn't have history data.  If you use an XY graph inside the loop, it will only  be updated with new data (forgetting the old).  You can manually use shift registers collect both the old data and new data and combine them into an array to update the graph, however this is less efficient.  Are you trying to graph the data vs something other than time?  Is this why you need to use the XY graph?  If this is the case, you might want to consider changing the DAQmx read to Analog DBL 1 Chan N Samp.  This would allow you to use it as one of the cluster inputs as your other axis data.  Below is a picture of how this might be implemented on a basic continuous acquisition.  I would also recommend taking a look at the XY graph.vi example (In LabVIEW go to Help » Find Examples » Fundamentals » Graphs and Charts).  This should give you some ideas on how the data should be inputted properly into the XY graph.



In addition, in regards to your second question, "
The second issue is that I'm trying to optimize this code so that I can get data as quickly as possible while still maintaining synchronization... So I'm wondering how much leeway was built into the 25ms pause in the loop iteration, and any other tips for making it go faster." 

The loop rate is seperate to the speed at which you are acquiring data.  The rate you are acquiring is based on the clock that you are using.  In this example you are using the encoder as your clock.  Essentially, your going to acquire data at a rate specified by and synchronized with your motor.  The DAQmx read in the example is doing nothing more than grabbing samples that were already taken by the card at the specified rate and updating the chart with that data.  This means that the 25 ms pause is only affecting the update rate of the chart not the rate of the acquisition.  Depending on your computer speed etc., you should be able to reduce this millisecond pause if you need the chart to update faster. 

I hope this helps,
Paul C.


Message Edited by Paul C. on 11-08-2007 02:21 PM

Message Edited by Paul C. on 11-08-2007 02:26 PM
Message 3 of 7
(4,829 Views)
Thank you for your very helpful explanation Paul. Perhaps you can help me with a logical problem that seems to remain.

As I said, I've stuck a read position function in there so that I can get synchronous position-voltage data displayed on my xy graph. Now, when I read N samples at a time it makes it difficult to plot those data points for a single position reading for each loop iteration. I can increase the buffer size and get it to take just 1 sample for each position reading (giving nice correlated points) but when I do that I get a just a small fraction of the beginning voltage data spread out over the entire position spectrum - I cannot understand why.
0 Kudos
Message 4 of 7
(4,804 Views)
Hi FiberOptix,

I'm having a little trouble visualizing what you're describing.  Is it possible for you to post a screenshot of what you are seeing?  I believe this is just a problem with how you are using the XY graph to plot the points.  Did you have a chance to take a look at the XY graph.vi example (In LabVIEW go to Help » Find Examples » Fundamentals » Graphs and Charts)?  In addition, it could also be helpful if you could post a picture of the modifications you made to the example so I could try and reproduce the same behavior on my end. 

Thanks,
Paul C.
0 Kudos
Message 5 of 7
(4,768 Views)
Hi Paul,

I've included two screenshots - the first is of the offending section of my code which I've taken from the example and tried to modify to do what I'd like. The second screenshot is of the output of my program, which looks fine but what's really happening is it's plotting the intensity data from maybe the first few degrees over the entire degree range.

Just to summarize what's going wrong - even though I tell it to take 1 sample at a time and pair 1 sample with a position reading I'm only getting a very small fraction of the intensity and it's being plotted over the entire position scale... I've looked at the examples and from what I saw I expected this to work because I moved the graph outside the loop and enabled indexing.

Thanks very much for your help


Download All
0 Kudos
Message 6 of 7
(4,764 Views)
Hi FiberOptix,

Is it possible that the arrays are of different sizes which is causing the samples of intensity to be plotted over the entire position scale?  Have you tried placing an indicator on both arrays prior to the input into the XY graph.  This would help us determine if the problem is due to array sizes or something else.  The XY graph will only plot the pairs of X and Y points.  If you have one array of 5 points and another of 10 points, it will only plot the 5 pairs of XY points.  This is shown in the pictures below.



I hope this helps,
Paul C.


Message Edited by Paul C. on 11-13-2007 01:51 PM
0 Kudos
Message 7 of 7
(4,714 Views)