From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

# LabVIEW

cancel
Showing results for
Search instead for
Did you mean:

## How can I create a pulse train with varying pulse widths?

I'm trying to create a finite pulse train that varies its duty cycle. I was hoping there was a clever way to do this neatly. I've attached a very rough picture of the train I'm hoping to make, with the pulse widths defined with t, the delay between pulses d, and a total of N+1 pulses. Thanks!

Edit: My current method is to use the pulse train function, and actually create 2N+1 pulses, stacking the "double length" pulses.

Message 1 of 5
(2,173 Views)

## Re: How can I create a pulse train with varying pulse widths?

This pseudo code should do the trick.

pulse train (time,t,d)

cycle=floor(time/d)

timeintocycle=time-cycle*d

if timeintocycle<=(cycle+1)*t return high else return low

end function

Message 2 of 5
(2,138 Views)

## Re: How can I create a pulse train with varying pulse widths?

I wound up just building the first short pulse, and then the train of longer pulses, and sticking them together. I attached a screenshot of the code I went with.

Message 3 of 5
(2,117 Views)

## Re: How can I create a pulse train with varying pulse widths?

Hey don't go overboard with the gratitude.

Message 4 of 5
(2,104 Views)

## Re: How can I create a pulse train with varying pulse widths?

Like going overboard with the local variables. None of those are necessary.
Message 5 of 5
(2,100 Views)