Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Retriggerable pulse generation with matlab

Solved!
Go to solution

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

0 Kudos
Message 1 of 16
(1,149 Views)

How can I post this to Matlab sub-community on the NI community?

0 Kudos
Message 2 of 16
(1,126 Views)

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.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
Message 3 of 16
(1,117 Views)

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

0 Kudos
Message 4 of 16
(1,102 Views)

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

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 5 of 16
(1,086 Views)

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

 

0 Kudos
Message 6 of 16
(1,078 Views)

If you could share a timing diagram of the pulses and DAQ behavior, it will help resolve misunderstanding/ambiguity.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 7 of 16
(1,065 Views)

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

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 8 of 16
(1,061 Views)

Oops, *now* it's attached...

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 9 of 16
(1,030 Views)

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

0 Kudos
Message 10 of 16
(1,025 Views)