Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

counter output becomes unsnchronized when gated with an other counter

Dear all
i'm using a PCI-6602 to generate a range of different pulse trains / retriggered pulses. Ctr0 is running at the experiments base frequency (T0) and is configured like this:
Error = DAQmxCreateCOPulseChanTicks(T0TaskHandle, "Dev1/ctr0", "", "20MHzTimebase", DAQmx_Val_Low, 0, T0Low, T0High);
Error = DAQmxCfgImplicitTiming(T0TaskHandle, DAQmx_Val_ContSamps, 0);


A second counter (Ctr2) produces pulses synchronized with T0 but with n times longer period:
Error = DAQmxCreateCOPulseChanTicks(BlockTaskHandle, "Dev1/ctr2", "", "20MHzTimebase", DAQmx_Val_High, 0, BlockLow, BlockHigh);
Error = DAQmxCfgImplicitTiming(BlockTaskHandle, DAQmx_Val_ContSamps, 0);
Error = DAQmxCfgDigEdgeStartTrig(BlockTaskHandle, "/Dev1/Ctr0InternalOutput", DAQmx_Val_Rising);


A third counter (Ctr3) produces retriggered pulses from Ctr2 that will serve as a gate for the 4th counter output:
Error = DAQmxCreateCOPulseChanTicks(BlockEnableTaskHandle, "Dev1/ctr3", "", "20MHzTimebase", DAQmx_Val_Low, 0, BlockEnableLow, BlockEnableHigh);
Error = DAQmxCfgDigEdgeStartTrig(BlockEnableTaskHandle, "/Dev1/Ctr2InternalOutput", DAQmx_Val_Rising);
Error = DAQmxCfgImplicitTiming(BlockEnableTaskHandle, DAQmx_Val_FiniteSamps, 1);
Error = DAQmxSetStartTrigRetriggerable(BlockEnableTaskHandle, true);


Ctr4 should now output pulses at the frequency of Ctr0 but only when Ctr3Out is high. I tried along the lines of:
Error = DAQmxCreateCOPulseChanTicks(TriggerTaskHandle, "Dev1/ctr4", "", "20MHzTimebase", DAQmx_Val_Low, 0, TriggerLow, TriggerHigh);
Error = DAQmxCfgImplicitTiming(TriggerTaskHandle, DAQmx_Val_ContSamps, 0);


Error = DAQmxSetPauseTrigType(TriggerTaskHandle, DAQmx_Val_DigLvl);
Error = DAQmxSetDigLvlPauseTrigWhen(TriggerTaskHandle, DAQmx_Val_Low);
Error = DAQmxSetDigLvlPauseTrigSrc(TriggerTaskHandle, "/Dev1/Ctr3InternalOutput");


This works in terms of gating, but the gated pulses are no longer synchronized with the Ctr0 (they "move" through the gate when looking at it on an oscilloscope).
DAQmxCfgDigEdgeStartTrig does not work for Ctr4 as it is not possible to use start and pause in the same task (at least that's what the error message said).

I tried to synchronize using:
Error = DAQmxSetArmStartTrigType(TriggerTaskHandle, DAQmx_Val_DigEdge);
Error = DAQmxSetDigEdgeArmStartTrigSrc(TriggerTaskHandle, "/Dev1/Ctr0InternalOutput");
Error = DAQmxSetDigEdgeArmStartTrigEdge(TriggerTaskHandle, DAQmx_Val_Rising);


which works if i uncomment the three PauseTrig lines (no more drifting pulses, but no gating either). Using it all together produces no errors but the gated pulses still walk through the gating window.

Any help is deeply appreciated

Best regards

Christian


0 Kudos
Message 1 of 3
(4,419 Views)
Hello Christian,

the error message is right, you can not use start and pause in the same task.
I think it is not possible to realize your application only with the PCI-6602. You need an external AND Gate.
The problem is "Ctr4 should now output pulses at the frequency of Ctr0 but only when Ctr3Out is high".
Alternative you can use a FPGA board like a PCI-78xx.

Regards,
WolfgangZ

0 Kudos
Message 2 of 3
(4,382 Views)
Hello Wolfgang
thank you for your reply. I finally managed to get the 6602 to do what i want it to. The key was to use

Error = DAQmxSetDigEdgeArmStartTrigSrc(TriggerTaskHandle, "/Dev1/Ctr2InternalOutput");

instead of


Error = DAQmxSetDigEdgeArmStartTrigSrc(TriggerTaskHandle, "/Dev1/Ctr0InternalOutput");

and to make sure that Ctr4s task was started after the tasks of Ctr0 and Ctr2.

Now Counter 4 is pulsing at the frequency of Ctr0 (even with selectable delay and pulse width) but only when Ctr3Out is high without the need for an external AND gate or other hardware.

Best regards

Christian


Message 3 of 3
(4,375 Views)