简体   繁体   English

PyDAQmx将采集模式设置为按需

[英]PyDAQmx Setting Acquisition Mode to On Demand

I am trying to write a program in PyDAQmx that counts digital edges and outputs a TTL signal every nth edge. 我正在尝试用PyDAQmx编写一个程序,该程序对数字边沿进行计数并每n个边沿输出TTL信号。 I am having trouble setting the Acquisition Mode in PyDAQmx to be "1 Sample (On Demand)" which is what I set while using LabVIEW. 我在使用LabVIEW时在PyDAQmx中将“采集模式”设置为“ 1 Sample(On Demand)”时遇到麻烦。 I am using a NI USB6210 DAQ Device. 我正在使用NI USB6210 DAQ设备。

This is my first time coding with NIDAQ/PyDAQMX/etc so I based this on an example on the PyDAQmx page that shows how to translate a C program into Python, the relevant piece of code looks like this: 这是我第一次使用NIDAQ / PyDAQMX / etc进行编码,因此我以PyDAQmx页面上的示例为基础,该示例显示了如何将C程序转换为Python,相关代码如下:

read = int32()
data = numpy.zeros((1000,), dtype=numpy.uint32)
try:
    DAQmxCreateTask("",byref(taskHandle))
    DAQmxCreateCICountEdgesChan(taskHandle,"Dev6/ctr0","",DAQmx_Val_Rising,0,DAQmx_Val_CountUp)
    #Somehow set acquisition mode here
    DAQmxStartTask(taskHandle)

while True:

    DAQmxReadCounterScalarU32 (taskHandle, 1000, None, read)
    print "Acquired %d samples"%read.value  
    print "result is %s " %result

My expectation is that this is the default timing mode for counter input tasks, and you can confirm that by asking the driver via the DAQmx C API's Sample Timing Type parameter: 我的期望是这是计数器输入任务的默认计时模式,您可以通过DAQmx C API的Sample Timing Type参数询问驱动程序来确认这一点:

DAQmxCreateTask("",byref(taskHandle))
DAQmxCreateCICountEdgesChan(taskHandle,"Dev6/ctr0","",DAQmx_Val_Rising,0,DAQmx_Val_CountUp)

timingType = int32()
DAQmxGetSampTimingType(taskHandle, byref(timingType))
print(timingType)

If timingType has the value 10390 , then you have on-demand sampling. 如果timingType的值为10390 ,那么您将进行按需采样。

In general, if there isn't a function that does what you want (in this case, there isn't a DAQmxCfgOnDemandTiming() function), you can assume that is the default configuration. 通常,如果没有满足您需要的函数 (在这种情况下,没有DAQmxCfgOnDemandTiming()函数),则可以假定这是默认配置。 In addition, the DAQmx functions don't expose all of the device's settings, however, and so for very specialized behavior, you must get and set the properties you require explicitly. 此外,DAQmx函数不会公开设备的所有设置,因此,对于非常特殊的行为,必须明确获取并设置所需的属性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM