06-22-2008 01:46 PM
09-05-2011 06:00 AM
Hi could you help me please, after defining the channel how you can read and save the data for each inputs?
DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,
"Dev1/ai8:9","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
I need to read and save the inputs separately ,for example ai8 ,ai9 inputs in the SQL DB
09-15-2011 02:06 AM
Hi darya,
for C/C++ programming of DAQmx you might consider to have a look at this tutorial: Here
Best regards,
Benjamin
08-31-2016 09:08 AM
Hy i try to use a USB 6008 with 8 channel but it doesn't work i used your model but it works for only one channel. when i change the Group BY Channel with Group by Scan Number it returns me 0 . And when i want to save the data i can save only from one channel. Can you help me?
My code is :
from PyDAQmx import *
import numpy
from time import *
from xlwt import Workbook
import csv
# Declaration of variable passed by reference
taskHandle = TaskHandle()
read = int32()
data = numpy.zeros((2000,), dtype=numpy.float64)
#sampling rate
sampleRate = float64(100.0)
samplesPerChan = uInt64(100)
#specifiy the channels
chan = "Dev1/ai0:1"
clockSource = "OnboardClock"
print chan
print clockSource
try:
# DAQmx Configure Code
DAQmxCreateTask("",byref(taskHandle))
DAQmxCreateAIVoltageChan(taskHandle,chan,"",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,None)
DAQmxCfgSampClkTiming(taskHandle,clockSource,sampleRate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,samplesPerChan)
# DAQmx Start Code
DAQmxStartTask(taskHandle)
# DAQmx Read Code
DAQmxReadAnalogF64(taskHandle,-1,float64(1.0),DAQmx_Val_GroupByScanNumber,data,2000,byref(read),None)
print "Acquired %d points"%read.value
except DAQError as err:
print "DAQmx Error: %s"%err
finally:
if taskHandle:
# DAQmx Stop Code
DAQmxStopTask(taskHandle)
DAQmxClearTask(taskHandle)
timestamp=strftime("%Y-%m-%d %H:%M:%S")
ofile=open('eggs.csv', 'wb') # as csvfile:
spamwriter = csv.writer(ofile, delimiter=',',quotechar='"', quoting=csv.QUOTE_MINIMAL)
print data
for x in data:
spamwriter.writerow([x]+[timestamp])
ofile.close()
08-31-2016 12:37 PM
Hello Stefan,
I wrote this about 8 years ago so please forgive me as I'm working from memory 🙂
for 8 channels you need (on Device 1)
CHK(nidaq.DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0:7","",
leave the Groupby as is
I would also check that you are really sending data on all channels.
Hope it helps
Best regards
Daleflow