02-26-2013 06:30 AM
Hi All,
Aparently SampleQuantityMode.ContinuousSamples and DoNotAllowRegeneration does not work for digital output (on a 6229 board).
For analog output, a DAQ-mx task correctily raises the Done event when all the supplied values have been clocked out of the buffer(s):
private void a()
{
var Device = "Dev1";
var ByteRate = 100; ;
var SamplesPerChannel = 100;
var BufferLen = 2000;
var AOtask = new Task();
AOtask.AOChannels.CreateVoltageChannel(Device + "/ao1", "", -10, 10, AOVoltageUnits.Volts);
AOtask.Timing.ConfigureSampleClock("", ByteRate,
SampleClockActiveEdge.Falling, SampleQuantityMode.ContinuousSamples, SamplesPerChannel);
AOtask.Stream.WriteRegenerationMode = WriteRegenerationMode.DoNotAllowRegeneration;
AnalogSingleChannelWriter AOwriter = new AnalogSingleChannelWriter(AOtask.Stream);
AOwriter.WriteMultiSample(false, new double[BufferLen]);
AOtask.Done += new TaskDoneEventHandler(AOtask_Done);
AOtask.Start();
}
void AOtask_Done(object sender, TaskDoneEventArgs e)
{
Debug.Print("Output buffesr are now empty");
}
.
However for a Digital output task the Done event is never raised:
void b()
{
var Device = "Dev1";
var ByteRate = 100; ;
var BufferLen = 2000;
var DOtask = new Task();
DOtask.DOChannels.CreateChannel(Device + "/port0/line0:7", "", ChannelLineGrouping.OneChannelForAllLines);
DOtask.Timing.ConfigureSampleClock("/" + Device + "/PFI8", ByteRate,
SampleClockActiveEdge.Falling, SampleQuantityMode.ContinuousSamples, BufferLen);
DOtask.Stream.WriteRegenerationMode = WriteRegenerationMode.DoNotAllowRegeneration;
var DOwriter = new DigitalSingleChannelWriter(DOtask.Stream);
DOwriter.WriteMultiSamplePort(false, new Int32[BufferLen]);
DOtask.Done += new TaskDoneEventHandler(DOtask_Done);
DOtask.Start();
}
void DOtask_Done(object sender, TaskDoneEventArgs e)
{
Debug.Print("The Done event is never raised");
}
The specified digital data is output allright (clocked by the signal on PFI8), but as the last data valueis clocked out the digital data stream continues by repeating the last data value, and Done is never raised.
Is there a trick to get the Done event raised when the output buffer is empty, or is there any other way to tell when the last pieces of data has been clocked out of the buffer(s) ?
Best regards
Morten
PS: I am aware that in my simple examples above I could have used SampleQuantityMode.FiniteSamples, but in general this is not an option
03-22-2013 04:10 AM
Hi Morten.
Please see this post for an answer:
http://forums.ni.com/t5/Digital-I-O/DoNotAllowRegeneration/m-p/2327224