06-23-2022 07:06 AM
Hi,
I am using a NI 6052E card with Matlab 2020 (with Data Aquisiotin and Instrument Control Toolbox) and would like to use the Ctr0 as pulsegeneration TTL output (e.g. f1=1MHz) and then trigger this frequency with a second counter output (Ctr1, f2=200kHz) so that Ctr0 only generates pulses when Ctr1 is high.
This way I want to generate pulsetrains, in this example 5 TTL pulses, then pause, 5 pulses, pause, etc.
My code is at the moment around:
d = daq("ni");
ch1 = addoutput(d,"Dev1", "Ctr0" ,"PulseGeneration");
ch2 = addoutput(d,"Dev1", "Ctr1" ,"PulseGeneration");
ch1.Frequency = 1000000;
ch2.Frequency = 200000;
trig = addtrigger(d,"Digital","StartTrigger","External","Dev1/Ctr0Gate");
start(d, 'Duration', seconds(10));
I connected the output Ctr1out via cable to Ctr0Gate. However Ctr0 is generating TTL signals all the time, ignoring this trigger input at the gate channel and I don't know why.
Any help is appreciated,
Michael S
06-23-2022 08:13 AM
I don't know any of the syntax for Matlab, but here are 2 main ideas:
1. You'll need 2 distinct counter tasks, one for ctr0 at 1 MHz, one for ctr1 at 100 kHz.
2. You should configure ctr0 to use the output from ctr1 as a *pause* trigger, not a start trigger.
-Kevin P
06-23-2022 08:22 AM
That is indeed the problem.
Matlab (with their fancy data aquisition toolbox) only allows StartTrigger.
Therefore I am a bit at a loss and unfortunately not an electical engineer. I tried to connect many different in and outputs and all different kinds of connectors, but with no success.
06-23-2022 10:55 AM
A simple external logic AND gate would do the trick too. It's simple enough, it doesn't take an EE.
-Kevin P