Here is the function that starts tha acquisition
m_InputTask = new Task("ScanDelay Input");
m_OutputTask = new Task("ScanDelay Output");
m_InputTask.AIChannels.CreateVoltageChannel(
"Dev1/ai0",
"",
AITerminalConfiguration.Differential,
-1,
1,
AIVoltageUnits.Volts);
m_OutputTask.AOChannels.CreateVoltageChannel(
"Dev1/ao0",
"",
-1,
1,
AOVoltageUnits.Volts);
m_InputTask.Timing.ConfigureSampleClock(
"ao/SampleClock",
m_SampleRate,
SampleClockActiveEdge.Rising,
SampleQuantityMode.ContinuousSamples);
Double[] SquareWave = new Double[10] { -1, -1, -1, -1, -1, 1, 1, 1, 1, 1 };
m_OutputTask.Timing.ConfigureSampleClock(
"",
m_SampleRate,
SampleClockActiveEdge.Rising,
SampleQuantityMode.ContinuousSamples,
SquareWave.Length);
m_InputTask.Control(TaskAction.Verify);
m_OutputTask.Control(TaskAction.Verify);
m_Writer = new AnalogSingleChannelWriter(m_OutputTask.Stream);
m_Writer.WriteMultiSample(false, SquareWave);
m_StartButton.Enabled = false;
m_StopButton.Enabled = true;
m_Count = 0;
m_InputCallback = new AsyncCallback(OnData);
m_Reader = new AnalogSingleChannelReader(m_InputTask.Stream);
m_Reader.SynchronizingObject = this;
m_Reader.BeginReadMultiSample(m_SamplesPerAq, m_InputCallback, null);
m_OutputTask.Start();
m_LastTime = DateTime.Now;