From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use an external digital signal to trigger a digital sequence output (USB-6221)

I am using USB-6221 port0 to generate a 8-bit digital sequence. Below is the Python code calling C program.

How to use the PFI0 port to take another digital sequence for triggering the port0 output? How to use the function DAQmxCfgDigEdgeStartTrig?

 daq.DAQmxCreateTask("",taskCounter)
daq.DAQmxCreateCOPulseChanFreq(taskCounter,"Dev1/ctr0","",daq.DAQmx_Val_Hz,daq.DAQmx_Val_Low,0.0,freq,0.50)
daq.DAQmxCfgImplicitTiming(taskCounter,daq.DAQmx_Val_ContSamps,1000)

daq.DAQmxCreateTask("",taskHandle)

daq.DAQmxCreateDOChan(taskHandle,"Dev1/port0/line0:7","",daq.DAQmx_Val_ChanForAllLines)
daq.DAQmxCfgSampClkTiming(taskHandle,"Ctr0InternalOutput",freq,daq.DAQmx_Val_Rising,daq.DAQmx_Val_FiniteSamps,nsamples)
daq.DAQmxWriteDigitalU32(taskHandle,2,0,10.0,cnst.DAQmx_Val_GroupByChannel,startdata,None,None)
daq.DAQmxStartTask(taskHandle)
daq.DAQmxStopTask(taskHandle)

daq.DAQmxWriteDigitalU32(taskHandle,nsamples,0,10.0,cnst.DAQmx_Val_GroupByChannel,idata,None,None)
print("Data Written\n")

daq.DAQmxStartTask(taskCounter)

 

0 Kudos
Message 1 of 5
(1,018 Views)

I simply added the DAQmxCfgDigEdgeStartTrig function, but obviously it doesn't work.

        daq.DAQmxCreateTask("",taskCounter)
        daq.DAQmxCreateCOPulseChanFreq(taskCounter,"Dev1/ctr0","",daq.DAQmx_Val_Hz,daq.DAQmx_Val_Low,0.0,freq,0.50)
        daq.DAQmxCfgImplicitTiming(taskCounter,daq.DAQmx_Val_ContSamps,1000) 
        # Create Digital Channel
        daq.DAQmxCreateTask("",taskHandle)
        daq.DAQmxCreateDOChan(taskHandle,"Dev1/port0/line0:7","",daq.DAQmx_Val_ChanForAllLines)
        daq.DAQmxCfgSampClkTiming(taskHandle,"Ctr0InternalOutput",freq,daq.DAQmx_Val_Rising,daq.DAQmx_Val_FiniteSamps,nsamples)
        # q = daq.DAQmxRegisterDoneEvent(taskHandle,0,None,None)
        # q = daq.DAQmxRegisterDoneEvent(taskCounter,0,None,None)
        # External trigger
        daq.DAQmxCfgDigEdgeStartTrig(taskHandle,"Dev1/PFI0",daq.DAQmx_Val_Rising)
        # write startup values
        daq.DAQmxWriteDigitalU32(taskHandle,2,0,10.0,cnst.DAQmx_Val_GroupByChannel,startdata,None,None)
        daq.DAQmxStartTask(taskHandle)
        daq.DAQmxStopTask(taskHandle) 
        # load trigger sequence
        daq.DAQmxWriteDigitalU32(taskHandle,nsamples,0,10.0,cnst.DAQmx_Val_GroupByChannel,idata,None,None)
        print("Data Written\n")
        # start counter
        daq.DAQmxStartTask(taskCounter)

The error is shown below:

b'Specified property is not supported by the device or is not applicable to the task.\nProperty: DAQmx_StartTrig_Type\n\nTask Name: _unnamedTask<5>\n\nStatus Code: -200452'

 

0 Kudos
Message 2 of 5
(996 Views)

I am not a python guy, but in general, it should be possible.

 

I observe that you're using a counter task to be the sample clock for the DO task. Try one step at a time, just set up a DO task with an onboard clock and digital edge trigger.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 3 of 5
(977 Views)

hi 

 

 

0 Kudos
Message 4 of 5
(652 Views)

@zhm0204 wrote:

hi 

 

 


Please create a new topic to discuss your requirement, do not hijack other posts to suit your unrelated question.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 5 of 5
(632 Views)