04-22-2021 11:00 AM
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)
04-22-2021 12:03 PM
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'
04-22-2021 08:38 PM
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.
02-02-2023 10:04 PM
hi santo_13
May I ask a question about USB 6221. Is there a similar USB 6221 with 24 bit resolutin and can work with external sampling clock (encoder signal).
Regards.
Zhang
02-06-2023 10:16 AM
@zhm0204 wrote:
hi santo_13
May I ask a question about USB 6221. Is there a similar USB 6221 with 24 bit resolutin and can work with external sampling clock (encoder signal).
Regards.
Zhang
Please create a new topic to discuss your requirement, do not hijack other posts to suit your unrelated question.