ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

WriteMultiSample with changed data - lag problem

Hi,

I'm using .Net 2008 (C#), USB-6255 DaQ Mass Termination device + SCB 68.
I am connecting AO0 (Analog Output 0) to AI0, using WriteMultiSample I am writing a sin wave which is constantly changing (for example) to AO0-
and constantly reading the (same) data from AI0.
the problem is that there's a lag between each sample while reading:

an example code:

                myTask = new Task();
                myTask.AOChannels.CreateVoltageChannel("Dev1/ao0",
                                       "aoChannel",
                                       MIN_VOLTAGE,
                                       MAX_VOLTAGE,
                                       AOVoltageUnits.Volts);



                myTask.Control(TaskAction.Verify);



                myTask.Timing.ConfigureSampleClock(
                    "",
                    numberOfSamplePointsInSecond,
                    SampleClockActiveEdge.Rising,
                    SampleQuantityMode.FiniteSamples,
                    numberOfSamplePointsInSecond);


                    double[] data = new double[numberOfSamplePointsInSecond];
                    AnalogSingleChannelWriter writer = new AnalogSingleChannelWriter(myTask.Stream);
                    int i = 0;

                    for (int j=1; j<5; j++)
                    {
                        for (i = 0; i < numberOfSamplePointsInSecond; i++)
                            data[i] = Math.Sin(2 * Math.PI * ((double)i/100.0)) * (double)j;
                        writer.WriteMultiSample(false, data);
                        myTask.Start();
                        myTask.WaitUntilDone();
                        myTask.Stop();
                     }

                    myTask.Dispose();

the problem, while reading the data, there's a lag between each read (using BeginReadMultiSample/EndReadMultiSample, I know I have no problem with reading) can be seen in the attached file - there's a lag between each sample.

I guess it's the myTask.Stop() which causes the lag - but how can I change the data otherwise?
Thanks.





0 Kudos
Message 1 of 3
(4,421 Views)
found solution:

http://forums.ni.com/ni/board/message?board.id=232&thread.id=6412

the DoNotAllowRegeneration was all I missing. it works!


Message Edited by LiorS on 05-28-2008 08:08 AM
0 Kudos
Message 2 of 3
(4,413 Views)

Hello LiorS. Would it be possible for you to show your syntax after implementing DoNotAllowRegeneration? I have the same problem with my coding and, even after looking at the link you posted and following their syntax for chaging the Regeneration settings, I get an error.

0 Kudos
Message 3 of 3
(3,475 Views)