Quantcast
Channel: Digital I/O topics
Viewing all articles
Browse latest Browse all 2181

Inconsistent Triggers

$
0
0

I'm currently having an issue with a NI-6363 card.  I set up two tasks -- a data task and a counter task.

 

The data task looks at the counter task as a clock -- it uses the Counter InternalOutput to as it's sample clock for timing.

 

The counter waits for an external trigger on PFI5.  When it receives that trigger, it should create 104 counter pulses that thus shift out 104 bits from the data task.  The data task is a port, so it shifts 104-bits out on all 32 lines.

 

I load up the data buffer with a ton of samples (enough for a couple hundred triggers) and then set about triggering.

 

But it keeps missing triggers here and there when we attempt to do this at above 100Hz or so.  There's plenty of time post the 104-pulses for recovery and arming for a re-trigger, but it's just missing them fairly regularly.

 

Shouldn't since I have the buffer in there, it just *go*?  This should be bread and butter, right?  So what am I missing?  I've attached an O-scope picture of what I'm seeing.  The red traces are the trigger, yellow is the clock (counter), green is the data line.  I've tried changing the frequency of the counter clock around and up and down from 300kHz to 6MHz with no real big changes in behavior.

 

Any help would be appreciated!!

 

 

//create tasks
tmp += ChkForError(DAQmxCreateTask("Data_t",out taskHandle_DAT));
tmp += ChkForError(DAQmxCreateTask("Counter_t",out taskHandle_CTR));

//asign port zero to the data task
tmp+= ChkForError(DAQmxCreateDOChan(taskHandle_DAT,$"{DeviceNum}/port0","Data",NI.DAQMX.DAQmx_Val_ChanForAllLines));

//Set all tasks that will be writing digital data to not allow regen of data.
tmp += ChkForError(DAQmxSetWriteRegenMode(taskHandle_DAT,NI.DAQMX.DAQmx_Val_DoNotAllowRegen));
//Set up counter for the clock, 50% duty cycle, rate defined by our global frequency, create only 104 samples out each time it's triggered
tmp += ChkForError(DAQmxCreateCOPulseChanFreq(taskHandle_CTR, $"/{DeviceNum}/Ctr2", "", NI.DAQMX.DAQmx_Val_Hz, NI.DAQMX.DAQmx_Val_Low, 0.0, Global_Frequency, 0.50));
tmp += ChkForError(DAQmxCfgImplicitTiming(taskHandle_CTR, NI.DAQMX.DAQmx_Val_FiniteSamps, 104));
//make the data task look at the Ctr2 (clock) for edges to shift data on. Frequency is inconsequential, as-is # of samples (cont samples)
tmp += ChkForError(DAQmxCfgSampClkTiming(taskHandle_DAT, $"/{DeviceNum}/Ctr2InternalOutput", Global_Frequency, NI.DAQMX.DAQmx_Val_Falling, NI.DAQMX.DAQmx_Val_ContSamps, 104));
//set the trigger for the clock, and set it to be retriggerable
tmp += ChkForError(DAQmxCfgDigEdgeStartTrig(taskHandle_CTR, $"/{DeviceNum}/PFI5", NI.DAQMX.DAQmx_Val_Rising));
tmp += ChkForError(DAQmxSetStartTrigRetriggerable(taskHandle_CTR, 1));

 

 


Viewing all articles
Browse latest Browse all 2181

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>