首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Python nidaqmx读取K热电偶值

Python nidaqmx读取K热电偶值
EN

Stack Overflow用户
提问于 2017-11-25 04:56:58
回答 1查看 1K关注 0票数 0

我是一个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()作为任务:

代码语言:javascript
复制
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

我就是想不出如何设置热电偶的单位和类型。

我可以使用命令来设置它们,但是我不能在添加热电偶命令中引用它们

我使用的是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‘’)源

代码语言:javascript
复制
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.

任何建议都非常感谢。这么简单的事情,但我遇到了障碍,看不到任何直接相关的例子。

非常感谢

加文

EN

回答 1

Stack Overflow用户

发布于 2018-05-08 20:39:41

我也遇到过同样的问题。

解决方案是在add_ai_thrmcpl_chan中也使用nidaqmx.constants.

代码语言:javascript
复制
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="")
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47479913

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档