PyDAQmx icon indicating copy to clipboard operation
PyDAQmx copied to clipboard

Support of other DAQmx channels

Open murenrb opened this issue 11 years ago • 5 comments

I am using PyDAQmx to measure temperatures via thermocouples and a NI 9213 board. I am using the normal thermocouple DAQmx call: http://zone.ni.com/reference/en-XX/help/370471W-01/daqmxcfunc/daqmxcreateaithrmcplchan/

This is working great when I don't use the Task object but I am wondering if these other channel types will be supported in the Task object in the future or if I can somehow add them manually. I am fairly new to Python, so this may be easy and I just don't know how to do it.

murenrb avatar Apr 09 '14 22:04 murenrb

Can you send me the python code that works without Task.

Le 10/04/2014 00:27, murenrb a écrit :

I am using PyDAQmx to measure temperatures via thermocouples and a NI 9213 board. I am using the normal thermocouple DAQmx call: http://zone.ni.com/reference/en-XX/help/370471W-01/daqmxcfunc/daqmxcreateaithrmcplchan/

This is working great when I don't use the Task object but I am wondering if these other channel types will be supported in the Task object in the future or if I can somehow add them manually. I am fairly new to Python, so this may be easy and I just don't know how to do it.

— Reply to this email directly or view it on GitHub https://github.com/clade/PyDAQmx/issues/13.

clade avatar Apr 11 '14 10:04 clade

Clade, The code is attached. I am using the standard DAQmxCreateAIThrmcplChan call as described by NI. All I had to do was comment out the Create Voltage Channel call and input this call. Seems like it would be trivial to make the Task object include other standard NI calls, but I don't really know.

Let me know if I can help any other way.

On Fri, Apr 11, 2014 at 4:25 AM, Pierre Cladé [email protected]:

Can you send me the python code that works without Task.

Le 10/04/2014 00:27, murenrb a écrit :

I am using PyDAQmx to measure temperatures via thermocouples and a NI 9213 board. I am using the normal thermocouple DAQmx call:

http://zone.ni.com/reference/en-XX/help/370471W-01/daqmxcfunc/daqmxcreateaithrmcplchan/

This is working great when I don't use the Task object but I am wondering if these other channel types will be supported in the Task object in the future or if I can somehow add them manually. I am fairly new to Python, so this may be easy and I just don't know how to do it.

Reply to this email directly or view it on GitHub https://github.com/clade/PyDAQmx/issues/13.

Reply to this email directly or view it on GitHubhttps://github.com/clade/PyDAQmx/issues/13#issuecomment-40190096 .

Russell Muren CO-founder Rebound Technology LLC 303 330-2712 | email [email protected] | websitehttp://www.REbound-tech.com| linkedin http://www.linkedin.com/in/russellmuren

Unless otherwise noted, please consider all information in this email confidential

murenrb avatar Apr 11 '14 12:04 murenrb

I don't see any file attached to your message.

Pierre

Le 11/04/2014 14:22, murenrb a écrit :

Clade, The code is attached. I am using the standard DAQmxCreateAIThrmcplChan call as described by NI. All I had to do was comment out the Create Voltage Channel call and input this call. Seems like it would be trivial to make the Task object include other standard NI calls, but I don't really know.

Let me know if I can help any other way.

On Fri, Apr 11, 2014 at 4:25 AM, Pierre Cladé [email protected]:

Can you send me the python code that works without Task.

Le 10/04/2014 00:27, murenrb a écrit :

I am using PyDAQmx to measure temperatures via thermocouples and a NI 9213 board. I am using the normal thermocouple DAQmx call:

http://zone.ni.com/reference/en-XX/help/370471W-01/daqmxcfunc/daqmxcreateaithrmcplchan/

This is working great when I don't use the Task object but I am wondering if these other channel types will be supported in the Task object in the future or if I can somehow add them manually. I am fairly new to Python, so this may be easy and I just don't know how to do it.

Reply to this email directly or view it on GitHub https://github.com/clade/PyDAQmx/issues/13.

Reply to this email directly or view it on GitHubhttps://github.com/clade/PyDAQmx/issues/13#issuecomment-40190096 .

Russell Muren CO-founder Rebound Technology LLC 303 330-2712 | email [email protected] | websitehttp://www.REbound-tech.com| linkedin http://www.linkedin.com/in/russellmuren

Unless otherwise noted, please consider all information in this email confidential

— Reply to this email directly or view it on GitHub https://github.com/clade/PyDAQmx/issues/13#issuecomment-40197610.

clade avatar Apr 14 '14 07:04 clade

Clade, How odd, it was attached and I can still see that it was attached on this email chain. There must be an issue with the mail clients somewhere along the way. I have attached it again to this message and also pasted the code below:

'''

Created on Apr 7, 2014

@author: russellmuren

'''

from PyDAQmx import *

import numpy

Declaration of variable passed by reference

taskHandle = TaskHandle()

read = int32()

data = numpy.zeros((1000,), dtype=numpy.float64)

try:

# DAQmx Configure Code

DAQmxCreateTask("",byref(taskHandle))

DAQmxCreateAIThrmcplChan(taskHandle,"cDAQ1mod1/ai0","",-100.0,100.0

,DAQmx_Val_DegC,DAQmx_Val_K_Type_TC,DAQmx_Val_BuiltIn,25.0,"")

#

DAQmxCreateAIVoltageChan(taskHandle,"cDAQ1Mod1/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,None)

DAQmxCfgSampClkTiming(taskHandle,"",10000.0

,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,1000)

# DAQmx Start Code

DAQmxStartTask(taskHandle)


# DAQmx Read Code

DAQmxReadAnalogF64(taskHandle,1000,10.0,DAQmx_Val_GroupByChannel,data,

1000,byref(read),None)

print "Acquired %d points"%read.value

print data[-1]

except DAQError as err:

print "DAQmx Error: %s"%err

finally:

if taskHandle:

    # DAQmx Stop Code

    DAQmxStopTask(taskHandle)

    DAQmxClearTask(taskHandle)

On Mon, Apr 14, 2014 at 1:07 AM, Pierre Cladé [email protected]:

I don't see any file attached to your message.

Pierre

Le 11/04/2014 14:22, murenrb a écrit :

Clade, The code is attached. I am using the standard DAQmxCreateAIThrmcplChan call as described by NI. All I had to do was comment out the Create Voltage Channel call and input this call. Seems like it would be trivial to make the Task object include other standard NI calls, but I don't really know.

Let me know if I can help any other way.

On Fri, Apr 11, 2014 at 4:25 AM, Pierre Cladé [email protected]:

Can you send me the python code that works without Task.

Le 10/04/2014 00:27, murenrb a écrit :

I am using PyDAQmx to measure temperatures via thermocouples and a NI 9213 board. I am using the normal thermocouple DAQmx call:

http://zone.ni.com/reference/en-XX/help/370471W-01/daqmxcfunc/daqmxcreateaithrmcplchan/

This is working great when I don't use the Task object but I am wondering if these other channel types will be supported in the Task object in the future or if I can somehow add them manually. I am fairly new to Python, so this may be easy and I just don't know how to do it.

Reply to this email directly or view it on GitHub https://github.com/clade/PyDAQmx/issues/13.

Reply to this email directly or view it on GitHubhttps://github.com/clade/PyDAQmx/issues/13#issuecomment-40190096

.

Russell Muren CO-founder Rebound Technology LLC 303 330-2712 | email [email protected] | websitehttp://www.REbound-tech.com| linkedin http://www.linkedin.com/in/russellmuren

Unless otherwise noted, please consider all information in this email confidential

Reply to this email directly or view it on GitHub https://github.com/clade/PyDAQmx/issues/13#issuecomment-40197610.

Reply to this email directly or view it on GitHubhttps://github.com/clade/PyDAQmx/issues/13#issuecomment-40338240 .

Russell Muren CO-founder Rebound Technology LLC 303 330-2712 | email [email protected] | websitehttp://www.REbound-tech.com| linkedin http://www.linkedin.com/in/russellmuren

Unless otherwise noted, please consider all information in this email confidential

murenrb avatar Apr 14 '14 15:04 murenrb

In order to use Task object, the following code should work. If it doesn't, please send me the error you get (preferably using ipython). Don't use the try .. except, so I can see where the error occurs.

Pierre

from PyDAQmx import * import numpy

Declaration of variable passed by reference

read = int32() data = numpy.zeros((1000,), dtype=numpy.float64)

task = Task() task.CreateAIThrmcplChan("cDAQ1mod1/ai0","",-100.0,100.0,DAQmx_Val_DegC,DAQmx_Val_K_Type_TC,DAQmx_Val_BuiltIn,25.0,"") task.CfgSampClkTiming(taskHandle,"",10000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,1000)

DAQmx Start Code

task.StartTask(taskHandle)

DAQmx Read Code

task.ReadAnalogF64(taskHandle,1000,10.0,DAQmx_Val_GroupByChannel,data,1000,byref(read),None)

print "Acquired %d points"%read.value

Le 14/04/2014 17:56, murenrb a écrit :

from PyDAQmx import *

import numpy

Declaration of variable passed by reference

taskHandle = TaskHandle()

read = int32()

data = numpy.zeros((1000,), dtype=numpy.float64)

try:

DAQmx Configure Code

DAQmxCreateTask("",byref(taskHandle))

DAQmxCreateAIThrmcplChan(taskHandle,"cDAQ1mod1/ai0","",-100.0,100.0 ,DAQmx_Val_DegC,DAQmx_Val_K_Type_TC,DAQmx_Val_BuiltIn,25.0,"")

DAQmxCreateAIVoltageChan(taskHandle,"cDAQ1Mod1/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,None)

DAQmxCfgSampClkTiming(taskHandle,"",10000.0 ,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,1000)

DAQmx Start Code

DAQmxStartTask(taskHandle)

DAQmx Read Code

DAQmxReadAnalogF64(taskHandle,1000,10.0,DAQmx_Val_GroupByChannel,data, 1000,byref(read),None)

print "Acquired %d points"%read.value

print data[-1]

except DAQError as err:

print "DAQmx Error: %s"%err

finally:

if taskHandle:

DAQmx Stop Code

DAQmxStopTask(taskHandle)

DAQmxClearTask(taskHandle)

clade avatar Apr 14 '14 16:04 clade