From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Pause in Analog Output from NI-USB-6001

I'm creating a waveform that is a simple Analog Output voltage ramp for 120 seconds which I'm running in continuous mode. When I run this on the NI-USB-6001 there is a 360 msec pause in the ramp about every 13.5 seconds. Doesn't seem to depend on the frequency I use for the waveform.  Is this a FIFO issue? 

0 Kudos
Message 1 of 4
(1,934 Views)

Hi ecandlc,

 

It's hard to say why that might be happening in your system without seeing the code. Would you mind attaching your code to the post?

 

Best,

 

Duncan Waldrop

Technical Support Engineer

National Instruments

0 Kudos
Message 2 of 4
(1,905 Views)

Here is the code. This is basically one of the examples with my own waveform. numMinV is set to 0.05, numMaxV is set to 2, frequencyNumeric is set to 100. The physicalChannelComboBox.Text is set to select the first analog output.

 

myTask = new Task();
myTask.AOChannels.CreateVoltageChannel(physicalChannelComboBox.Text,
"",
Convert.ToDouble(0),
Convert.ToDouble(5),
AOVoltageUnits.Volts);

// verify the task before doing the waveform calculations
myTask.Control(TaskAction.Verify);

// calculate some waveform parameters and generate data
FunctionGenerator fGen = new FunctionGenerator(
myTask.Timing,
frequencyNumeric.Value.ToString(),
samplesPerBufferNumeric.Value.ToString(),
cyclesPerBufferNumeric.Value.ToString(),
signalTypeComboBox.Text,
amplitudeNumeric.Value.ToString());

double freq = (double)frequencyNumeric.Value;
double time = 30 + 80 + 10;
int num = (int)(freq * time);
double dMinV = (double)numMinV.Value;
double dMaxV = (double)numMaxV.Value;

// configure the sample clock with the calculated rate
// at 100hz - 30+80 = 110 sec = 11000 samples
myTask.Timing.ConfigureSampleClock("", freq, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, num);
//fGen.ResultingSampleClockRate,
//SampleClockActiveEdge.Rising,
//SampleQuantityMode.ContinuousSamples, 1000);

double[] v = new double[num];
for (int i = 0; i < v.Length; i++)
v[i] = dMinV;

for (int i = 0; i < 80 * freq; i++)
v[i + (int)(30 * freq)] = dMinV + (double)i / (80 * freq) * (dMaxV - dMinV);


AnalogSingleChannelWriter writer =
new AnalogSingleChannelWriter(myTask.Stream);

//write data to buffer
writer.WriteMultiSample(false, v); //fGen.Data);

//start writing out data

myTask.Start();
0 Kudos
Message 3 of 4
(1,894 Views)

The onboard analog output buffer for the 6001 can only hold 2047 samples at a time. It sounds like your code is stopping to quickly reload this buffer as needed since you are writing more than this number of samples to the buffer in a single function call.

 

The most common way to avoid this is to write fewer samples to the buffer, but to do so more frequently. You can set up a loop to write portions of the array to the hardware periodically, then clock the loop using sleep().

 

I also want to mention that the 6001 does not have the resolution to output 11,000 unique samples between 0.05 and 2. The DAC is 14-bit and the range is +/- 10 V, which gives a resolution of ~0.001 V. The ramp you have currently created has ~0.0001 V separating each sample. This means that every 10 or so samples will be mapped to the same output voltage. Basically, you could construct your waveform with ~1,100 samples, instead of 11,000, and see the same output. This would be another way to get around the buffer limitation, although it won't scale too far beyond your current ramp range.

 

-Duncan

0 Kudos
Message 4 of 4
(1,886 Views)