We have written a value (2v) to an output channel AO1 and was verified the value in hardware (voltmeter). The channel AO1 is wired to the input channel AI3. But when we read the value of AI3, we do not get the value that we have writtem. We have tried the behavior with and without a triggering source. In both cases, we did not get the value written to AO1, when reading from AI3.
The C++ code used for Analog value reading and writing is given below. Is there any issue with the below code?
Read analog
------------
TaskHandle oTask;
constexpr char TaskName[] = "";
double fRead{ 0 };
int32 nError = DAQmxCreateTask(TaskName, &oTask);
nError = DAQmxCreateAIVoltageChan(oTask, "Dev1/AI3", "", DAQmx_Val_Cfg_Default, -3.25, 3.25, DAQmx_Val_Volts, nullptr);
nError = DAQmxCfgSampClkTiming(oTask, "", 1.0, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, 2);
nError = DAQmxCfgDigEdgeStartTrig(oTask, "PFI0", DAQmx_Val_Rising);
int32 nError = DAQmxReadAnalogF64(oTask, 1, 60, DAQmx_Val_GroupByChannel, &fRead, 1, &nSampsPerChanRead, nullptr);
nError = DAQmxClearTask(oTask);
Write analog
------------
constexpr char TaskName[] = "";
TaskHandle oTask;
double dValues[2]{ 2, 2 };
int32 nError = DAQmxCreateTask(TaskName, &oTask);
nError = DAQmxCreateAOVoltageChan(oTask, "Dev1/AO1", "", -3.25, 3.25, DAQmx_Val_Volts, nullptr);
nError = DAQmxCfgSampClkTiming(oTask, "", 50.0, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, 2);
nError = DAQmxCfgDigEdgeStartTrig(oTask, "PFI0", DAQmx_Val_Rising);
nError = DAQmxWriteAnalogF64(oTask, 2, 1, 60, DAQmx_Val_GroupByChannel, dValues, nullptr, nullptr);
nError = DAQmxWaitUntilTaskDone(oTask, 60);
nError = DAQmxClearTask(oTask);