Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

National Instruments cDAQ Analog Output Sample Frequency using c#

I am using the cDAQ equipment to produce a sinewave. Using the cDAQ 9189 chassis and the Analog Output Module NI 9264, so far I have been able to produce a sample frequency of up to 400KS/s using regeneration and enabling the UseOnlyOnBoardMemory property. However, in the cDAQ 9189 specification document, the maximum onboard Sampling frequency is 1.6MS/s. How do I reach this Sampling frequency?

Whenever I set the sampling frequency to higher than 400KS/s. I get the following error:

[DAQ Exception][1]
I use an internal clock

I create a sinewave buffer with one cycle of the wave of length
= fsamp/fsinewave
so for 500kHz fsamp for a 50kHz signal - just 10 samples.

[1]: https://i.stack.imgur.com/ZJ5jY.png
The code in question:
The Function Generator class is the same used in the examples. It generates a double array with the parameters entered in.
````````
NationalInstruments.DAQmx.Task mySineWaveTask = new NationalInstruments.DAQmx.Task();

mySineWaveTask.AOChannels.CreateVoltageChannel(name,
"aoChannel",
-10,
10,
AOVoltageUnits.Volts);
mySineWaveTask.Control(TaskAction.Verify);

foreach(AOChannel aoChannel in mySineWaveTask.AOChannels)
{
aoChannel.UseOnlyOnBoardMemory = true;

}
mySineWaveTask.Stream.WriteRegenerationMode = WriteRegenerationMode.AllowRegeneration;
double cycles = 1;
double sampfreq = 400;//InkHz //The sample time differenc
double samples = cycles*sampfreq / ( Math.Pow(10, -3) * sinewavef);
if( samples > 8191)
{
Console.WriteLine("The samples are limited");
samples = 8191;
cycles = 8191 * sinewavef / sampfreq*Math.Pow(10,-3);
}

FunctionGenerator fGen = new FunctionGenerator(
mySineWaveTask.Timing,
sinewavef,
samples,
cycles,
WaveType.SineWave,
lower_bound,
upper_bound);
Console.WriteLine("The freq {0}", sinewavef);
Console.WriteLine("The resulting sample frequency {0}", fGen.ResultingSampleClockRate);
mySineWaveTask.Timing.ConfigureSampleClock(
"",
sampfreq*1000,
SampleClockActiveEdge.Rising,
SampleQuantityMode.ContinuousSamples);
Console.WriteLine("The real sample clock rate: {0}",mySineWaveTask.Timing.SampleClockRate);

AnalogSingleChannelWriter writer = new AnalogSingleChannelWriter(mySineWaveTask.Stream);
writer.WriteMultiSample(false, fGen.Data);
mySineWaveTask.Start();

Thread.Sleep(time);

mySineWaveTask.Stop();
mySineWaveTask.Dispose();
```````

0 Kudos
Message 1 of 1
(1,629 Views)