If I run a while loop (to obtain my DAQ data), the maximum number of times the loop will run is 4. After 4 times, "after start task" is displayed, but then nothing else. Therefore, it seems every time the loops gets stuck on the read function.
Any ideas?
I continue to move around what's inside of the function obtain_value, as well as change # of samples and sampling frequency.
Here is the code I'm referring to:
Code:
def obtain_value():
print 'entered main program'
CHK(nidaq.DAQmxCreateTask("",ctypes.byref(taskHandle)))
print ' after create task'
CHK(nidaq.DAQmxCreateAIVoltageChan(taskHandle,"Dev2/ai0:1","",DAQmx_Val_Cfg_Default,float64(-13.0),float64(13.0),DAQmx_Val_Volts,None))
print ' after create voltage'
CHK(nidaq.DAQmxCfgSampClkTiming(taskHandle,"",float64(50),DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,uInt64(max_num_samples))); #(samples/sec/channel) #ContSamps
print ' after clk'
CHK(nidaq.DAQmxStartTask(taskHandle))
print ' after start task'
CHK(nidaq.DAQmxReadAnalogF64(taskHandle,-1,float64(-1),DAQmx_Val_GroupByChannel,data.ctypes.data,max_num_samples,ctypes.byref(read),None))
print ' after read'
print data
if taskHandle.value != 0:
nidaq.DAQmxStopTask(taskHandle)
nidaq.DAQmxClearTask(taskHandle)
print ' end'
i = 0
while i < 5:
i += 1
print i
obtain_value()