Hi
Language Python 2.5 with the nidaq library
Mode: DAQmx_Val_Diff
Device: USB 6008 Analog input
The short question:
How do I get multiple channel data from the 6008 at the same time? The freq should be 6 reads per sec on 3 channels
If I call the get_data function below, the tuple returned is fine for 1 channel. If I thread it, then I get odd results
The data below was a 1.6v dc (battery) connected to 1 of the 3 channels continuously. So why the 0.0369321676022 result?
With 1 channel, I get a constant correct reading
...
0.0301219406728#0.0301219406728#0.0369321676022#0.0301219406728#0.0301219406728#0.0301219406728#
0.0301219406728#0.0369321676022#0.0301219406728#0.0301219406728#0.0301219406728#0.0301219406728#
0.0216441357288#0.0301219406728#0.0301219406728#0.0301219406728#0.0301219406728#1.61159945056#
0.0301219406728#0.0301219406728#0.0301219406728#0.0301219406728#0.0301219406728#1.61159945056#
0.0301219406728#0.0301219406728#0.0301219406728#0.0301219406728#1.61159945056#0.0301219406728#
0.0301219406728#0.0301219406728#0.0301219406728#0.495573123804#0.0301219406728#1.61669546119#
0.0301219406728#0.0301219406728#0.0301219406728#0.0301219406728#1.61159945056#0.0301219406728#
0.0301219406728#0.0301219406728#0.0301219406728#0.0301219406728#1.61159945056#0.0301219406728#
0.0301219406728#0.0301219406728#0.0420281782266#0.0301219406728#0.0301219406728#0.0301219406728#
1.61159945056#0.0301219406728#0.0301219406728#0.0301219406728#0.0301219406728#1.61159945056#
0.0301219406728#1.61159945056#0.0301219406728#1.61159945056#0.0301219406728#1.61159945056#
0.0301219406728#0.0301219406728#0.0301219406728#0.0301219406728#1.61159945056#0.0301219406728#
...
Thread Example
self.lock=thread.allocate_lock()
thread.start_new_thread(self.myThread1,("myThread1",self.lock))
thread.start_new_thread(self.myThread2,("myThread2",self.lock))
thread.start_new_thread(self.myThread3,("myThread3",self.lock))
def get_data(chan):
# initialize variables
taskHandle = TaskHandle(0)
max_num_samples = 1000
data = numpy.zeros((max_num_samples,),dtype=numpy.float64)
# now, on with the program
CHK(nidaq.DAQmxCreateTask("",ctypes.byref(taskHandle)))
CHK(nidaq.DAQmxCreateAIVoltageChan(taskHandle,"Dev1/%s" % (chan),"",
DAQmx_Val_Diff, #DAQmx_Val_RSE, #DAQmx_Val_Cfg_Default,
float64(-10.0),float64(10.0),
DAQmx_Val_Volts,None))
CHK(nidaq.DAQmxCfgSampClkTiming(taskHandle,"",float64(10000.0),
DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,
uInt64(max_num_samples)));
CHK(nidaq.DAQmxStartTask(taskHandle))
read = int32()
CHK(nidaq.DAQmxReadAnalogF64(taskHandle,max_num_samples,float64(1.0),
DAQmx_Val_GroupByChannel,data.ctypes.data,
max_num_samples,ctypes.byref(read),None))
#print "Acquired %d points"%(read.value)
if taskHandle.value != 0:
nidaq.DAQmxStopTask(taskHandle)
nidaq.DAQmxClearTask(taskHandle)
return data