08-20-2023 12:46 AM
Hi,
We need to transmit 2 pattern via 2 channels periodically
We use “AnalogMultiChannelWriter function and it works good, see the code below.
Our problem is that the number of sample in each channel is different, therefore the shorter pattern is pad with zeros.
How can we transmit periodically 2 patterns with unknow lengths independently (without zero padding)?
Thanks,
fGenTask = new Task();
for (int chIndex = 0; chIndex < channels.Length; chIndex++)
{
channelName = ProduceChannelName(deviceName, channels[chIndex]);
fGenTask.AOChannels.CreateVoltageChannel(channelName, chNames[chIndex], min, max, AOVoltageUnits.Volts);
}
//Verify the task before doing the waveform calculations
fGenTask.Control(TaskAction.Verify);
if (fGenTask.Timing.SampleTimingType == SampleTimingType.OnDemand)
{
fGenTask.Timing.SampleTimingType = SampleTimingType.SampleClock;
}
fGenTask.Timing.ConfigureSampleClock("", rate, SampleClockActiveEdge.Rising,
SampleQuantityMode.ContinuousSamples, samplesPerBuffer);
AnalogMultiChannelWriter writer = new AnalogMultiChannelWriter(fGenTask.Stream);
writer.WriteMultiSample(false, data);
fGenTask.Start();
08-20-2023 09:14 AM
When writing to channels in a DAQmx task, you must write to all channels in the task and equal samples for all channels in the task.
The only option is to separate the channels into different tasks. Unfortunately, cDAQ supports only 1 AO task per chassis.
Why do you need variable sample lengths for each channel? what are you generating using AO?
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019KWYSA2&l=en-US