Hi,
I'm currently implementing a DAQ in my C++ software which will generate the user voltage. It works fine with Matlab and I get nice changes when I put different voltages.
In spite of that, when I implement in my main the following code:
TaskHandle taskHandle = 0; float64 data[1000]; int var=1; while(var<10){ cin >> var; for (int i = 0; i < samplesReceived; ++i){ data[i] = var;
// - Initiation PART - // DAQmxCreateTask("",&taskHandle);
DAQmxCreateAOVoltageChan(taskHandle,"Dev1/ao1","",-10.0,10.0,DAQmx_Val_Volts,NULL);
DAQmxCfgImplicitTiming(taskHandle, DAQmx_Val_HWTimedSinglePoint, 1000);
DAQmx // - WRITE PART - //
//DAQmxWriteAnalogF64(taskHandle,1000,0,10.0,DAQmx_Val_GroupByChannel,data,NULL,NULL);
DAQmxWriteAnalogScalarF64(taskHandle, 0, 1, var, NULL);
// START
DAQmxStartTask(taskHandle);
//DAQmxStopTask(taskHandle); } }
I don't see any changes on a oscilloscope graph U=f(t).
However, when I put something this way:
TaskHandle taskHandle = 0; float64 data[1000]; int var=1; while(var<10){ cin >> var; for (int i = 0; i < samplesReceived; ++i){ data[i] = var; // - Initiation PART - // DAQmxCreateTask("",&taskHandle); DAQmxCreateAOVoltageChan(taskHandle,"Dev1/ao1","",-10.0,10.0,DAQmx_Val_Volts,NULL); DAQmxCfgSampClkTiming(taskHandle, "", 10000.0, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, 1000); DAQmx // - WRITE PART - // DAQmxWriteAnalogF64(taskHandle,1000,0,10.0,DAQmx_Val_GroupByChannel,data,NULL,NULL); //DAQmxWriteAnalogScalarF64(taskHandle, 0, 1, var, NULL);
//START DAQmxStartTask(taskHandle); //DAQmxStopTask(taskHandle); } }
It works but with graphs not smooth at all and if I put var=1 it evolves with big noise to 1V and if I write it again it switches to 0V (it depends in fact, sometimes it stays for 2 or 3 times at 1V ...).
I don't understand why on Matlab using just something like (after createSession etc.) outputSinglescan(s, 1) gives me really nice results while in C++ I get noisy graph.
Probably I'm not using the right commands, so if someone could help me having the Matlab equivalent of outputSinglescan for C/C++ NIDAQmx,
Thanks,
Complementary informations; I work with a NI USB-6221 with an oscilloscope in BNC ao1.