03-05-2010 01:49 PM
Hi-
I have setup a waveform graph which is obtaining data from an NI DAQ device. When I originally made my DAQmx Task, it was to read 1K samples at 1K hz in continuous mode. Things work fine and the waveform graph appears to update at a rate of 10hz. I no longer need the 1K acquisition frequency and I wish to switch it to 100hz. Even when changing the samples to read value, my waveformGraph is now only updating at 1hz. Is there any way to make it update at a faster rate? I had no luck in decreasing the buffer size, can you point me in the right direction? Thanks-
-Ryan
03-11-2010 06:40 AM
Hey Ryan,
Can I have a quick look at your code? If you read 1k samples at 1k Hz in continous mode it would either update the graph once a second, or as fast as your loop itterated, depending on how you set up the task.
Kind regards,
03-11-2010 10:42 AM
Thanks for your response Dominic. There isn't enough space to post the entire contents of the initializecomponents. Is that where I need to be looking? Can you give me an idea of what term I should be searching for?
Here is the method I am using to act on the acquired signal. Thanks for your help:
private void daqTaskComponent1_DataReady(object sender, DaqTaskComponentDataReadyEventArgs e)
{
acquiredData = e.GetData();
double[] bellowsdata = acquiredData[0].GetRawData();
double[] switchdata = acquiredData[1].GetRawData();
if (bellowsdata[0] > mysettings.LowerBellowsLimit && bellowsdata[0] < mysettings.UpperBellowsLimit)
{
waveformGraph1.PlotAreaColor = System.Drawing.Color.ForestGreen;
}
else
{
waveformGraph1.PlotAreaColor = System.Drawing.Color.Firebrick;
}
int plotlength = 6*mysettings.AcquisitionFrequency * mysettings.DisplayTime;
double[] upperlimitarr = new double[plotlength];
for (int i = 0; i < upperlimitarr.Length; i++)
upperlimitarr[i] = mysettings.UpperBellowsLimit;
double[] lowerlimitarr = new double[plotlength];
for (int i = 0; i < upperlimitarr.Length; i++)
lowerlimitarr[i] = mysettings.LowerBellowsLimit;
int startind = buffercount + 1;
int endind = startind + mysettings.AcquisitionFrequency;
int k=0;
for (int j = startind; j < endind; j++)
{
bellowsBuffer[j] = bellowsdata[k];
k++;
}
int copystartind = 0;
if (buffercount > plotlength)
copystartind = buffercount - plotlength;
double[] plotbellowssegment = new double[plotlength];
Array.Copy(bellowsBuffer, copystartind, plotbellowssegment, 0, plotlength - 1);
//Setup waveforms
AnalogWaveform<double> lowerlimitwaveform = AnalogWaveform<double>.FromArray1D(lowerlimitarr);
AnalogWaveform<double> upperlimitwaveform = AnalogWaveform<double>.FromArray1D(upperlimitarr);
AnalogWaveform<double> plotbellowswaveform = AnalogWaveform<double>.FromArray1D(plotbellowssegment);
// AnalogWaveform<double>[] mywaveforms = new AnalogWaveform<double>[3] { acquiredData[0], lowerlimitwaveform, upperlimitwaveform };
AnalogWaveform<double>[] mywaveforms = new AnalogWaveform<double>[3] { plotbellowswaveform, lowerlimitwaveform, upperlimitwaveform };
waveformGraph1.PlotWaveforms(mywaveforms);
// waveformGraph1.PlotWaveforms(lowerlimitwaveform);
waveformPlot1.LineColor = System.Drawing.Color.Black;
buffercount = buffercount + mysettings.AcquisitionFrequency;
// Determine if intervention has been performed
/*
if (switchdata[0] < -1)
{
if (interventionready)
{
interventionPerformed();
}
else
{
// MessageBox.Show("Reset Intervention");
}
}
*/
update5Dpositions();
update5Dgraphs();
}