From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Generation cannot be started, because the selected buffer size is too small Error

Hello everyone,

I wrote a program in  Visual Studio 2003 C# with Measurement Studio and DAQmx 8.50 , using as DAQ Card : PCI 6036 E , the program worked fine in all condition ( the program generates a analog signal , which passes through a device , then reads the new signal and compares the input and output signals).

When someone else  installed the program on a new computer that had a PCI-6251 M Card the following error appeared when he tried to generate the signal:
Measurements: Generation cannot be started, because the selected buffer size is too
small

Increase the buffer size

Selected Buffer Size: 1

Minimum Required Buffer Size: 2

Task Name:_unnamedTask<1>

So naturally I suspected that the program has a problem .. but when I simulated the PCI 6251 M Card with the program on a cmputer with no DAQ Card it worked fine.
So I thought the driver is incorrectly installed ..The person took the PCI 6036 E Card and installed it into the computer where the PCI 6251 M Card was and the program worked fine.

And my question ... where is the problem ? ( I no longer have access to the computers with the Cards , as I'm in a different country now :smileysad: )

Thank you in advanced for any ideas.:smileywink:

0 Kudos
Message 1 of 9
(10,336 Views)
Bump

Thank you in advanced .

0 Kudos
Message 2 of 9
(10,325 Views)

Hi Amutiano

I will first point you to an example already written to synchronize analog input and analog output; this example will be located inside the National Instruments folder “MultiFunctionSyncAIAO_DigStart.sln” and compare that example with your code. The error is self explaining that the minimum buffer size is two this is something you should change in your code the “samples to read” to two.  This error occurs because the buffer size needs to be greater than two for that card. In case you don’t find the example take a look at this knowledge base: NI-DAQmx, NI-VISA and NI-488.2 .NET Example Locations

I hopt this helps.

Jaime Hoffiz
National Instruments
Product Expert
0 Kudos
Message 3 of 9
(10,319 Views)
Hi Jaime F,
Thank you for answering ... i have study the indicated example ... but I can't see the problem in my program .... Here are the function that generate the output , and read the input :

        private void frmMainWindow_Load(object sender, System.EventArgs e)
        {
            frmOptions options=new frmOptions();
            try
            {
                input=new Task();
                input.AIChannels.CreateVoltageChannel(frmOptions.inputChannel,"",AITerminalConfiguration.Rse,
                    -10,10,AIVoltageUnits.Volts);
                input.Timing.ConfigureSampleClock("",1000,SampleClockActiveEdge.Rising,
                    SampleQuantityMode.ContinuousSamples);
                input.Control(TaskAction.Verify);
                input.Stream.Timeout=-1;
                output=new Task();
                output.AOChannels.CreateVoltageChannel(frmOptions.outputChannel,"",-10,10,AOVoltageUnits.Volts);
                output.Timing.ConfigureSampleClock("",1000,SampleClockActiveEdge.Rising,
                    SampleQuantityMode.ContinuousSamples);
                output.Control(TaskAction.Verify);
                output.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger("ai/SampleClock",
                    DigitalEdgeStartTriggerEdge.Rising);
                output.Stream.Timeout=-1;
                read=new AnalogSingleChannelReader(input.Stream);
                read.SynchronizingObject=this;
                write=new AnalogSingleChannelWriter(output.Stream);
                write.SynchronizingObject=this;
                callFctStepInput=new AsyncCallback(CallFctStepInput);
                callFctFrequencyInput=new AsyncCallback(CallFctFrequencyInput);

                lblStop.Text=frmStepResponseParameters.stepDuration.ToString()+" Sec";
                prbarStep.Maximum=frmStepResponseParameters.stepDuration*10;           
            }
            catch (DaqException daqE)
            {
                Options.Enabled=false;
                StepResponseParameters.Enabled=false;
                StepResponseShow.Enabled=false;
                FrequencyResponseShow.Enabled=false;
                FrequencyResponseNyquist.Enabled=false;
                FrequencyResponseParameters.Enabled=false;
                FrequencyResponseBode.Enabled=false;
            }

        }

        private void GenerateStepResponse()
        {   
            double [] stepSignalOutput=GenerateSquareWave(0.02,StepAmplitude(),StepOffset(),StepPhase(),1000,
                (int)(1000*frmStepResponseParameters.stepDuration));
            stepGraph=new frmStepResponseGraph();
            prbarStep.Value=0;
            txtStartVoltage.Text=frmStepResponseParameters.stepStartVoltage.ToString();
            txtStopVoltage.Text=frmStepResponseParameters.stepStopVoltage.ToString();
            txtOffsetVoltage.Text=frmStepResponseParameters.stepOffset.ToString();
            stepGraph.wfpStepOutput.PlotY(stepSignalOutput);
            generalTimer.Enabled=true;
            write.WriteMultiSample(true,stepSignalOutput);
            read.BeginReadMultiSample(1000,callFctStepInput,null);
        }

0 Kudos
Message 4 of 9
(10,308 Views)

        private void CallFctStepInput(IAsyncResult ar)
        {
            try
            {
                if (input==null)
                {
                    return;
                }
                double [] stepSignalInput=read.EndReadMultiSample(ar);
                stepGraph.wfpStepInput.PlotYAppend(stepSignalInput);
                if (generalTimer.Enabled)
                {
                    read.BeginReadMultiSample(1000,callFctStepInput,null);
                }
                else
                {
                    write.WriteSingleSample(true,(double)(frmStepResponseParameters.stepStartVoltage+
                        frmStepResponseParameters.stepOffset));
                    read.ReadSingleSample();
                    input.Stop();
                    output.Stop();
                }
            }
            catch (DaqException e)
            {
                MessageBox.Show(e.Message,"Error reading step response");
            }
        }

        private void GenerateFrequencyResponse()
        {
            freqIndex=0;
            FrequencyResponseBode.Enabled=true;
            FrequencyResponseNyquist.Enabled=true;
            CreateOutputSignal();
            prbarFrequency.Maximum=freq.Length;
            txtFrequency.Text=(freq[freqIndex]*2*Math.PI).ToString();
            prbarFrequency.Value=freqIndex;
            generalTimer.Enabled=true;
            run=false;
            write.WriteMultiSample(true,outputSignal);
            read.BeginReadMultiSample((int)period[freqIndex]*duration[freqIndex],callFctFrequencyInput,null);
        }
       
        private void CallFctFrequencyInput(IAsyncResult ar)
        {
            try
            {
                double [] signal=read.EndReadMultiSample(ar);
                inputSignals[freqIndex]=signal;
                wfpInput.PlotYAppend(signal);
                prbarFrequency.Value=freqIndex+1;
                prbarFrequency.Update();
                freqIndex++;
                if (freqIndex<freq.Length)
                {
                    read.BeginReadMultiSample((int)period[freqIndex]*duration[freqIndex],
                        callFctFrequencyInput,null);
                    txtFrequency.Text=(freq[freqIndex]*2*Math.PI).ToString();
                }
                else
                {
                    run=true;
                }
            }
            catch (DaqException e)
            {
                MessageBox.Show(e.ToString(),"Error reading frequency response");
            }
        }


The only time when I read/write a single sample is when I reset the voltage level using
write.WriteSingleSample and ReadSingleSample.

Thank you in advanced for any ideas.

Muntianu Andrei Gabriel.
0 Kudos
Message 5 of 9
(10,310 Views)

Hi Amutianu,

The method “WriteSingleSample” creates a buffer of one so you can not use this function with the PCI-6251. Why Am I Getting Error -200609 or Error -200802? In this case you need to reset the voltage level using “WriteMultipleSamples”. If you comment this line (write.WriteSingleSample) in your code you will see that the error will not occur. I would like to confirm that I understand your issue, you say at the end of your last post “The only time when I read/write a single sample is when I reset the voltage level using write.WriteSingleSample and ReadSingleSample”  by resetting I think you refer to updating the value right? And here is where the buffer is been setup for one.

I hope this helps.

Jaime Hoffiz
National Instruments
Product Expert
0 Kudos
Message 6 of 9
(10,300 Views)
Hi Jaime F.

Thx for confirming my suspicions about WriteSingleSample , I hope I'll be able to use WriteMultiSample without any impact on the program..
You only said that WriteSingleSample causes the error ... so can I steal use ReadSingleSample to start the reset of the voltage level ?

Thx in advanced.

Muntianu Andrei Gabriel.
0 Kudos
Message 7 of 9
(10,282 Views)

Hi amutianu,

The ReadSingleSample method should work properly with the way you have set up your application.

To give further explanation as to why the WriteSingleSample method doesn’t work we can take a look at how you have set up your timing on the output channel. I have quoted and highlighted this on the line below:

output.Timing.ConfigureSampleClock("",1000,SampleClockActiveEdge.Rising,
                    SampleQuantityMode.ContinuousSamples);

With this continuous sampling mode selected as I have highlighted above, you will only be able to use the WriteMultipleSamples function.

While your input channel is also defined as continuous you may still use the ReadSingleSample and ReadMultipleSamples methods without error.

Chris Behnke
Sr. RF Engineer
High Frequency Measurements
0 Kudos
Message 8 of 9
(10,251 Views)
Hi Chris J B

Thx for the help .. I will try to rewrite the program using WriteMultiSamples.
0 Kudos
Message 9 of 9
(10,243 Views)