Retriggerable pulse generation in NiDAQ

2 ビュー (過去 30 日間)
gujax
gujax 2023 年 3 月 9 日
コメント済み: gujax 2023 年 3 月 12 日
Hi,
i am having trouble figuring out how to set retriggerable pulse generation.
I can generate continuous pulse from a counter but I have to specify a frequency. But if the specified frequency is not exactly what is being triggered then I have a phase delay
For example I allocate an external trigger to PFI0
addtrigger(d,'starttrigger','external',Dev1/PFI0') & addclock(d,'Scanclock',external,Dev1/PFI0);
Next I add a counter
ch=addcounter(d,'cntr0',Dev1/PFI4,'PulseGeneration')
Then I have to specify
ch.Frequency = something close enough to clock and trigger frequency
and
ch.DutyCycle =0.5
When I output the trigger and the counter output on the scope, I see that the two slowly shift the edges w.r.t each other. I am assuming that is because my external clock may not be exactly matched to the specified frequency or perhaps it is using 'internal clock' to generate this pulse.
I don’t want to do that. Instead I want retriggerable pulses.
I Googled and found this mentioned here which is exactly what I need.
However, I am not sure how to set this up in matlab. Is there a parameter 'retriggerable'? What is source here? I am guessing it is my external clock.
https://www.ni.com/docs/en-US/bundle/crio-904x-feature/page/retrig-pulse-train-gen.html.
Thanks
  1 件のコメント
gujax
gujax 2023 年 3 月 12 日
I have by chance come upon this Matlab function:
Multiple-trigger acquisition
dq.NumDigitalTriggersPerRun = 20000;
However, not sure how does this work? Besides I still see the counter output drifting and recovering which implies perhaps for 20000 triggers the counter is free-wheeling, then it recovers back on the 20001th trigger ?
here is the code
s = daq('ni');
ch1 = s.addoutput('Dev3','ao0','Voltage'); % USB-6218
trig = addtrigger(s,"Digital","StartTrigger","External","Dev3/PFI1");
clockC = addclock(s,"ScanClock","External","Dev3/PFI0");
ctr_dev3 = addoutput(s,'Dev3','ctr0','PulseGeneration');%this is output on terminal PFI4
s.NumDigitalTriggersPerRun = 20000;
ctr_dev3.Frequency = 1000; %strangely this is still needed otherwise the counter out and the clock drift away faster (I think by default the internal frequency is set to 100 on these DAQ counter's)
start(s);
I connect ctr_dev3 on ch1 of the scope and PFI0 on ch2 of the scope while it is also triggering the scope. PFI0 input is at 1kHz.
I see the two clocks slowly drift but after a while the two suddenly switch back to realign. And this back and forth is independent of NumDigitalTriggersPerRun.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeSimultaneous and Synchronized Operations についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by