我是一名Python新手,但通常会通过修改示例来满足我的有限需求。
我正在尝试使用NI 9213结合NI CDAQ 9714自动进行一些温度测量
我查看了NI的视频,并且能够进行一般的测量
https://www.youtube.com/watch?v=NMMRbPvkzFs
但我无法正确指定热电偶的类型
导入nidaqmx
nidaqmx.constants.ThermocoupleType(10073) nidaqmx.constants.TemperatureUnits(10143)
使用nidaqmx.Task()作为任务:
task.ai_channels.add_ai_thrmcpl_chan("cDaq1Mod1/ai0:1")
#task.ai_channelsadd_ai_thrmcpl_chan("cDaq1Mod1/ai0:1","bob", 0.0, 100.0,units="TemperatureUnits.DEG_C: 10143", thermocouple_type="ThermocoupleType.J: 10072")
data=task.read(1,1.0)
print (data[0])
从这里开始 http://nidaqmx-python.readthedocs.io/en/latest/ai_channel_collection.html
我无法弄清楚如何设置热电偶的单位和类型。
我可以使用命令来设置这些,但我不能在add thermocouple命令中引用它们
我正在使用Anaconda Spyder 3.6
add_ai_thrmcpl_chan(physical_channel,name_to_assign_to_channel = u'',min_val = 0.0,max_val = 100.0,units =,thermocouple_type =,cjc_source =,cjc_val = 25.0,cjc_channel = u'')[来源]
Creates channel(s) that use a thermocouple to measure temperature.
Parameters:
physical_channel (str) – Specifies the names of the physical channels to use to create virtual channels. The DAQmx physical channel constant lists all physical channels on devices and modules installed in the system.
name_to_assign_to_channel (Optional[str]) – Specifies a name to assign to the virtual channel this function creates. If you do not specify a value for this input, NI-DAQmx uses the physical channel name as the virtual channel name.
min_val (Optional[float]) – Specifies in units the minimum value you expect to measure.
max_val (Optional[float]) – Specifies in units the maximum value you expect to measure.
units (Optional[nidaqmx.constants.TemperatureUnits]) – Specifies the units to use to return temperature measurements.
thermocouple_type (Optional[nidaqmx.constants.ThermocoupleType]) – Specifies the type of thermocouple connected to the channel. Thermocouple types differ in composition and measurement range.
cjc_source (Optional[nidaqmx.constants.CJCSource]) – Specifies the source of cold-junction compensation.
cjc_val (Optional[float]) – Specifies in units the temperature of the cold junction if you set cjc_source to CONSTANT_VALUE.
cjc_channel (Optional[str]) – Specifies the channel that acquires the temperature of the thermocouple cold- junction if you set cjc_source to CHANNEL.
任何建议都非常感激。这么简单的事情,但我遇到了障碍,无法看到任何直接相关的例子。
非常感谢
加文
答案 0 :(得分:0)
我有同样的问题。
解决方案是在nidaqmx.constants.
中使用add_ai_thrmcpl_chan
:
with nidaqmx.Task() as task:
task.ai_channels.add_ai_thrmcpl_chan("cDaq1Mod1/ai0:2",name_to_assign_to_channel="", min_val=0.0,
max_val=100.0, units=nidaqmx.constants.TemperatureUnits.DEG_C,
thermocouple_type=nidaqmx.constants.ThermocoupleType.K,
cjc_source=nidaqmx.constants.CJCSource.CONSTANT_USER_VALUE, cjc_val=20.0,
cjc_channel="")