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.

0 Kudos
Message 1 of 5

This pseudo code should do the trick.


pulse train (time,t,d)



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

end function



0 Kudos
Message 2 of 5

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.

0 Kudos
Message 3 of 5

Hey don't go overboard with the gratitude.

0 Kudos
Message 4 of 5
Like going overboard with the local variables. None of those are necessary.
0 Kudos
Message 5 of 5