Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Code does not continuously update data buffer

Hello friends. I have been working on a data acquisition software in C++ for an experiment at my university. I am working on a ni9239 module and have identified my problem with the code, but I do not yet know how to fix it. The problem is that my code does talk to the DAQ but only when the task is created. While the rest of my code is running (software that just prints out results) the DAQ code (I will place it below) does not update the buffer. When the program starts the active light flashes green but then does not again. This means to me that the program does talk to it, but does not update. The code states that the DAQ should update for the total time the program is running but it does not. Can anyone help me? 

 

(if this is the wrong place to ask this please let me know I was unsure)

 

Here is my code: 

 

DAQmxCreateTask("", &taskHandle);

 

DAQmxCreateAIVoltageChan(taskHandle, "cDAQ1Mod1/ai0:3", "", DAQmx_Val_Cfg_Default, -10.0, 10.0, DAQmx_Val_Volts, NULL); 


DAQmxCfgSampClkTiming(taskHandle, "", SampleRate, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, SampleRate * SampleTime);

 

DAQmxReadAnalogF64(taskHandle, SampleRate * SampleTime, 10.0, DAQmx_Val_GroupByScanNumber, data, 4 * SampleRate * SampleTime, &read, NULL);


DAQmxStartTask(taskHandle);

0 Kudos
Message 1 of 2
(810 Views)

Hi aar105@pitt.edu,

 

Have you referred to any shipping examples installed in your PC? 
Since NI-9239 is a voltage input module, you can try to refer to the shipping example in the path below. Perhaps this can be a good start for you review the code and make any modifications according to your need.

 

C:\Users\Public\Documents\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Analog In\Measure Voltage\Cont Acq-Int Clk

0 Kudos
Message 2 of 2
(711 Views)