Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

charting behavior part 2

There should be a way to edit posts on here, but anyway. I've done some debugging/recoding, and I've been able to get a waveform to plot smoothly. But If I have the number of samples to aquire higher than 1012 the waveform doesn't work properly. 1012 works fine, while aquiring 1025 samples doesn't work. I've changed the plothistory to over 1000 but that has no effect. Can anyone help. Thanks

JMD
0 Kudos
Message 1 of 5
(3,949 Views)
I tried to reproduce your problem by creating a new project, adding a ScatterGraph to the form, and adding the following code to the form class:

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);

const int dataLength = 1025;
double[] xData = new double[dataLength];
double[] yData = new double[dataLength];

Random rnd = new Random();
for (int i = 0; i < dataLength; ++i)
{
xData[i] = i;
yData[i] = rnd.NextDouble() * 10;
}

scatterPlot1.HistoryCapacity = 2000;
scatterPlot1.PlotXY(xData, yData);
}

This code seems to work with 1025 points. Were there any other properties that you changed? Could you please post a small test program that demonstrates the problem that you're
seeing? Thanks.

- Elton
0 Kudos
Message 2 of 5
(3,949 Views)
I've changed the property so that the plots update Immediately. The attached program shows the problem. I can get your code to work properly. I'm kinda lost for ideas right now.

JMD
0 Kudos
Message 3 of 5
(3,949 Views)
Could you describe the behavior you are seeing when the graph is not plotting smoothly in more detail?

Could the issue perhaps be that the graph is autoscaling and this is causing the data to jump around as new points are plotted. This could be remedied by setting the auto-scale mode to fixed and setting the axis ranges explicitly. The history should only matter if you are plotting so many points that some are being lost when you don't want them to.

At the acquisition rates you are using, both DAQmx and the graph should easily be able to keep up, so there must be another cause.

Thanks,
Tony H
Measurement Studio
0 Kudos
Message 4 of 5
(3,949 Views)
This behavior is due to data being kept in the buffer on your DAQ card and not being transferred to the computer. To force the on-board data to be transferred to the computer more regularly, you can either force the card to flush the buffer whenever it has the opportunity like this

aiTask.AIChannels.All.DataTransferRequestCondition = AIDataTransferRequestCondition.OnBoardMemoryNotEmp ty;

or you can reduce the size of your buffer:

aiTask.Stream.ConfigureInputBuffer(2*count);

where count is the number of points you read each time.

See the example code in my most recent comment to this ot
her question
for code that does this in the context of the rest of the application you are writing.

Let me know how everything turns out.

Tony H.
Measurement Studio
0 Kudos
Message 5 of 5
(3,949 Views)