From 11:00 PM CDT Friday, Nov 8 - 2:30 PM CDT Saturday, Nov 9, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From 11:00 PM CDT Friday, Nov 8 - 2:30 PM CDT Saturday, Nov 9, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
03-09-2023 02:07 PM
Sorry hate to ask this question here but I got no answers yet from Matlab.
Is there a way to generate retriggerable pulses from NiDAQ using Matlab? Has anyone attempted it?
So far i can generate output pulses using
addtrigger, addcounter
So I add an external triggert to PFI0
That also acts as a clock
Then I add a counter with output connected to PFI4
The problem is that I have to specify frequency and duty cycle. And if I do that then that stated frequency is not exact as the input especially if my input has a frequency noise. And so on the scope I see the two pulse trains i.e., input clock and the counter output slowly edge away from each other at some slow rate but not slow enough for my purpose.
But I looked up NiDAQ manual and they have what is called retriggerable pulse generation which perhaps will solve my problem.
Thanks
Solved! Go to Solution.
03-10-2023 07:00 AM
How can I post this to Matlab sub-community on the NI community?
03-10-2023 11:20 AM - edited 03-10-2023 11:21 AM
I don't think there is a MATLAB community on NI Forums. Any question related to MATLAB is best addressed by MATLAB community.
FYI - MATLAB added support for NI DAQ by using DAQmx drivers and abstracting a lot of advanced operations from the driver, even if DAQmx is capable, if MATLAB did not expose this, you cannot do it in MATLAB.
You can switch to Python or C# if MATLAB is limiting you from leveraging all the features of NI DAQ hardware.
03-11-2023 03:41 PM - edited 03-11-2023 03:44 PM
Thank you Santo
So maybe I should change the subject title slightly because I have some new insight and need help with this problem which is a continuation of what I have asked.
I am trying to generate on USB DAQ's 6218 and (also separately tried 6211 & 6366) a counter output that is synchronized to input clock.
So I am following the example of Ext Trigg Pulse Train.vi
However, what I find is that I cannot use an external source in the timing module. I have to use implicit type and that puts the counter output of out sync with my ext clock and trigger inputs (which are identical signals from an external generator).
So my question is for these devices,
"is there any other trick I can do to get trigger or clock synchronous to counter output"
or ...
"can I get a triggered pulse output on any output terminals that is synchronous to external clock with a delay on USB 6218, or 6211 or 6366 devices?"
I absolutely would prefer a delayed output
03-11-2023 09:56 PM - edited 03-11-2023 10:08 PM
I'm not sure I understand exactly what timing and pulse behavior you want. My best guess is that you want to create a single output pulse of your own that is delayed from an incoming pulse that triggers it. DAQmx definitely supports this, but I don't know whether Matlab does.
Just be aware that if a new triggering pulse arrives before your previous output pulse has finished, it will be ignored. The prior pulse must finish before the counter re-arms to be able to react to the next trigger *after* that.
Sorry, but I'm no help with how to do this through the Matlab API. Or even *whether* you can -- I know it has limitations and doesn't give access to all of the features in DAQmx.
Or do you want the incoming pulse to trigger a series of output pulses? Unless you have prior and exact knowledge of the incoming pulse rate, you can't really expect your output pulses to stay in sync.
-Kevin P
03-11-2023 10:21 PM - edited 03-11-2023 10:28 PM
Hi Kevin
You wrote
"Sorry, but I'm no help with how to do this through the Matlab API. Or even *whether* you can -- I know it has limitations and doesn't give access to all of the features in DAQmx."
>I have given up on Matlab for now so I am working with LabView. I have this issue when trying it out on a LabView vi code.
>And yes I want the second part that you mention i.e
"Or do you want the incoming pulse to trigger a series of output pulses? "
> Yes that is what I need except I want every trigger to output a counter pulse i.e., a pulse-per-trigger
> The output pulse I need should be smaller in width than that of the incoming pulse so that every trigger outputs a pulse
"Unless you have prior and exact knowledge of the incoming pulse rate, you can't really expect your output pulses to stay in sync."
> Hmm, okay I see. So like in a function generator where each trigger pulse can trigger an output pulse with an on-demand delay, I cannot get this functionality from a DAQ? I find that hard to understand
> I know kind of exactly what is the incoming PRF but it has fluctuations. PRF is e.g., 1000 Hz but when I read it, I see it is fluctuating between 1.00015 k and 1.000167 k.
> I tried to assign that rate to the daq object but it did not help. I still see the counter not in sync with input and it drifts
> Isn't 'retriggerable output' supposed to do that?
Thank you
03-12-2023 04:41 PM
If you could share a timing diagram of the pulses and DAQ behavior, it will help resolve misunderstanding/ambiguity.
03-12-2023 05:10 PM - edited 03-12-2023 05:11 PM
The first part of what I said will apply, but I now note that I wasn't careful to talk about making it retriggerable. Attached is a simple example to generate a 100 microsec output pulse delayed by 200 microsec.from an incoming ~1 kHz triggering pulse. It is a very slight modification of one of the shipping examples for pulse generation.
Note that with the 62xx devices you'll need to set 'initial delay on retrigger?' to False to prevent an error. They don't support the ability to configure that property. With 63xx devices, if you set 'initial delay on retrigger?' to True, low time is never used. Only 'initial delay' and ''Pulse Duration'.
To make all delays equal when 'initial delay on retrigger?' is False, set 'low time' equal to 'initial delay' for both kinds of devices.
Caveat: I'm pretty sure I've verified these behaviors for 63xx devices. I probably haven't verified them on 62xx devices, I'm going by what I *think* I know to be true.
-Kevin P
03-13-2023 05:36 AM
Oops, *now* it's attached...
-Kevin P
03-13-2023 06:58 AM - edited 03-13-2023 06:59 AM
Santhosh
The vi is attached.
It is a version of one available in the examples. The only difference is that I added a timing module because I wanted to have it externally triggered.
But Kevin's suggested vi above is different and I shall try that soon and provide an update.
Thanks