[英]NIDAQmx Counter input Edge Source change
I'm a little bit confused with my code.我对我的代码有点困惑。 I want to read the position of a counter input (edge counter).我想读取计数器输入(边缘计数器)的位置。 I can get the Device and the channel but I want to change the Edge Source or the Terminal.我可以获得设备和通道,但我想更改边缘源或终端。 If I add the channel the Edge Source is automatically "PFI0" which counts some different thing that I need.如果我添加通道,Edge Source 会自动变为“PFI0”,这会计算出我需要的一些不同的东西。 I want to change it to "PFI1" as seen in the picture.如图所示,我想将其更改为“PFI1”。 I tried the following, but it didn't work.我尝试了以下方法,但没有奏效。 Can someone please help me out!有人可以帮帮我吗!
import nidaqmx
def read_position():
task = nidaqmx.Task()
task.ci_channels.add_ci_count_edges_chan("Dev1/ctr0")
task.ci_channels[0].ci_count_edges_term = "PFI1"
task.start()
pos = task.read()
task.stop()
task.close()
return pos
Best regards, Szilárd最好的问候,西拉德
You need to specify the device as well as the channel: instead of task.ci_channels[0].ci_count_edges_term = "PFI1"
you should write task.ci_channels[0].ci_count_edges_term = "/Dev1/PFI1"
您需要指定设备和通道:而不是task.ci_channels[0].ci_count_edges_term = "PFI1"
你应该写task.ci_channels[0].ci_count_edges_term = "/Dev1/PFI1"
An easy way to check for the correct syntax is just to print the default channel: print(task.ci_channels[0].ci_count_edges_term)
检查正确语法的一种简单方法是打印默认通道: print(task.ci_channels[0].ci_count_edges_term)
Note how the /
is necessary at the beginning of the string.请注意/
在字符串的开头是必需的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.