hello, I have developed a program that automate several of the operations available on the PXI-6363 and I am tasked with performing multiple analog outputs to produce a specific waveform on each channel.
I can make a single waveform from a selected channel but I'm facing difficulties when I try to make 2 or more, I couldn't find any examples or explanations online or on the C:\Users\Public\Documents\National Instruments\NI-DAQ\Examples folder
I can make it work when I open a task from NI-MAX but only with the same frequency for both channels
since the workstation is an offline machine, I'm unable to bring the actual code which I'm working with but here is the code in a nutshell:
public void MultiChannel(frequency0, amplitude0, frequency1, amplitude1, SamplesPerBuffer0, CyclePerBuffer0, SamplesPerBuffer1, CyclePerBuffer1){
AnalogWriteTask = new Task();
AnalogWriteTask.AOChannles.CreateVoltageChannel("PXI1Slot5\ao0", "analog0", -10, 10, AOVoltageUnits.Volts);
AnalogWriteTask.AOChannles.CreateVoltageChannel("PXI1Slot5\ao1", "analog1", -10, 10, AOVoltageUnits.Volts);
AnalogWriteTask.Control(TaskAction.Verify);
FunctionGenerator fGen0 = FunctionGenerator(AnalogWriteTask,Timing, frequency0, SamplesPerBuffer0, CyclePerBuffer0, WaveformType.Sinwave, amplitude0);
FunctionGenerator fGen1 = FunctionGenerator(AnalogWriteTask,Timing, frequency1, SamplesPerBuffer1, CyclePerBuffer1, WaveformType.Sinwave, amplitude1);
AnalogWriteTask.Timing.ConfigureSampleClock("", fGen0.ResultingSampleClockRate, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, 1000);
AnalogWriteTask.Timing.ConfigureSampleClock("", fGen1.ResultingSampleClockRate, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, 1000);
AnalogMultiChannelWriter writer = new AnalogMultiChannelWriter(AnalogWriteTask.Stream);
double[,] data = new double[2, Math.Max(fGen0.Data.Length, fGen1.Data.Length)]
/*
use a loop to save the data in the 2D array
*/
writer.WriteMultuSample(false, Data);
AnalogWriteTask.WaitUntilDone();
AnalogWriteTask.Start();
}
this code does not prompt any errors, but it also doesn't produce any waveform from the channels, in addition to that, when I reach the AnalogWriteTask.Stop() it prompts an error with exception code -200018
can anyone point me to the right direction in that subject?