Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Reference Trigger with Digital Pattern not supported, DAQmx_Val_DigPattern error -200077

Solved!
Go to solution

Hello,

I have a cDAQ NI9184: 4 slot chassis with a NI9234: 4channel IEPE Analog Inputs, and NI9421 8 channel Digital sinking input

I am trying to configure an analog input task with a digital start trigger and a digital stop trigger also. 

For stop trigger I am using a reference trigger as suggested in this tutorial link.   I would like to use the digital pattern reference strigger since I want the stop trigger to happen when two DI lines get.

 

When I try to do this using a DAQmxCfgDigPatternRefTrig i get the following error:

 

DAQmx Error: Requested value is not a supported value for this property. The property value may be invalid because it conflicts with another property.
Property: DAQmx_RefTrig_Type
Requested Value: DAQmx_Val_DigPattern
Possible Values: DAQmx_Val_AnlgEdge, DAQmx_Val_AnlgWin, DAQmx_Val_DigEdge, DAQmx_Val_None

Task Name: hw1

Status Code: -200077
in function DAQmxCfgDigPatternRefTrig

 

I tried to use the Digital Edge Reference trigger and it works fine. However the digital pattern trigger is giving that error. 

I am doing all this by calling the nidaqmx c functions from python. I have attached the code for reference.

 

import numpy
import time
import ctypes
nidaq = ctypes.windll.nicaiu
from ctypes.wintypes import BOOLEAN

int32 = ctypes.c_long
uInt32 = ctypes.c_ulong
uInt64 = ctypes.c_ulonglong
float64 = ctypes.c_double
TaskHandle = uInt32

DAQmx_Val_Cfg_Default = int32(-1)
DAQmx_Val_Volts = 10348
DAQmx_Val_Rising = 10280
DAQmx_Val_FiniteSamps = 10178
DAQmx_Val_GroupByChannel = 0
DAQmx_Val_PatternMatches = 10254
DAQmx_Val_CurrReadPos = 10425
DAQmx_Val_DigPattern= 10398
DAQmx_Val_AnlgEdge = 10099
class MyList(list):
    pass

# list where the data are stored
data = MyList()


totD = []


def CHK(err):
    """a simple error checking routine"""
    if err < 0:
        buf_size = 1000
        buf = ctypes.create_string_buffer('\000' * buf_size)
        nidaq.DAQmxGetErrorString(err,ctypes.byref(buf),buf_size)
        raise RuntimeError('nidaq call failed with error %d: %s'%(err,repr(buf.value)))

taskHandle = TaskHandle(0)
max_num_samples = 1024
data = numpy.zeros((max_num_samples,),dtype=numpy.float64)
read=int32

CHK(nidaq.DAQmxCreateTask("hw1",ctypes.byref(taskHandle)))
CHK(nidaq.DAQmxCreateAIVoltageChan(taskHandle,"cDAQ9184-1B20914Mod1/ai0","",DAQmx_Val_Cfg_Default,float64(-5.0),float64(5.0),DAQmx_Val_Volts,None))
CHK(nidaq.DAQmxCfgInputBuffer(taskHandle, 10240))
CHK(nidaq.DAQmxCfgSampClkTiming(taskHandle,"",float64(1024.0),
                                DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,uInt64(max_num_samples)))
CHK(nidaq.DAQmxCfgDigEdgeStartTrig(taskHandle,"/cDAQ9184-1B20914Mod2/PFI0", DAQmx_Val_Rising))
CHK(nidaq.DAQmxSetRefTrigType(taskHandle, DAQmx_Val_AnlgEdge))
CHK(nidaq.DAQmxCfgDigPatternRefTrig(taskHandle,"/cDAQ9184-1B20914Mod2/PFI0:7", "11xxxxxx", DAQmx_Val_PatternMatches, 2))
CHK(nidaq.DAQmxSetReadRelativeTo(taskHandle, DAQmx_Val_CurrReadPos))
    
CHK(nidaq.DAQmxStartTask(taskHandle))
    
time.sleep(5)
flag=1
while flag:
    print 'hi'
    CHK(nidaq.DAQmxReadAnalogF64(taskHandle,-1, float64(-1), DAQmx_Val_GroupByChannel,
                                 data.ctypes.data,
                             max_num_samples,ctypes.byref(read), None))
    print"acquiring data"
    totD.append(data)
    time.sleep(1)

if taskHandle.value != 0:
    # DAQmx Stop Code
    CHK(nidaq.DAQmxStopTask(taskHandle))
    CHK(nidaq.DAQmxClearTask(taskHandle))


print "final data"
nptotD=numpy.array(totD)
print nptotD

Is the digital pattern refernece trigger not supported on nidaqmx? 

0 Kudos
Message 1 of 2
(3,341 Views)
Solution
Accepted by topic author kampan

Not every device supports every trigger type available in the DAQmx API. Specifically, as the error indicates, the NI 9421 does not support digital pattern reference triggers. (Nor does any C Series module in CompactDAQ as far as I can see.)

——
Brandon Streiff
ni.com/compactdaq · ni.com/daq
0 Kudos
Message 2 of 2
(3,317 Views)