# Pulse Generator/Square Wave with Controllable Rise Time and Fall Time

**URL:** <https://forum.plexim.com/t/pulse-generator-square-wave-with-controllable-rise-time-and-fall-time/978>\
**Category:** PLECS\
**Tags:** generator, pulse, plecs-standalone\
**Created:** [March 5, 2021, 11:01am UTC](https://forum.plexim.com/t/pulse-generator-square-wave-with-controllable-rise-time-and-fall-time/978 "2021-03-05T11:01:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@Andrew](https://forum.plexim.com/u/Andrew)\
**Post date:** [March 5, 2021, 11:01am UTC](https://forum.plexim.com/t/pulse-generator-square-wave-with-controllable-rise-time-and-fall-time/978/1 "2021-03-05T11:01:54Z")

</div>

Hello,

How could a rectangular signal/square wave/pulse wave be generated in Plecs 4.1 in which the RISE TIME and the FALL TIME can be adjusted, besides the frequency, duty cycle, phase shift, lower and upper amplitude, as is shown in the figure below?

Thank you.  
Best regards.

 ![Square__Wave_with_Controllabe_Rise&Fall_Time.png](https://europe1.discourse-cdn.com/flex006/uploads/plecs/original/1X/73678a37272300729bfe2db161d0ef9e5d94c610.png)

 ![Pulse_Generator_Plecs_4.1.JPG](https://europe1.discourse-cdn.com/flex006/uploads/plecs/original/1X/861c996e86fab4bcfdf72e3c432e6f0b53fd3fcd.jpeg)

---

<div class="post-metadata">

**Author:** ![shichenseu](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@shichenseu](https://forum.plexim.com/u/shichenseu)\
**Post date:** [March 5, 2021, 10:27pm UTC](https://forum.plexim.com/t/pulse-generator-square-wave-with-controllable-rise-time-and-fall-time/978/2 "2021-03-05T22:27:27Z")

</div>

using C-script?

---

<div class="post-metadata">

**Author:** ![Andrew](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@Andrew](https://forum.plexim.com/u/Andrew)\
**Post date:** [March 6, 2021, 8:38am UTC](https://forum.plexim.com/t/pulse-generator-square-wave-with-controllable-rise-time-and-fall-time/978/3 "2021-03-06T08:38:00Z")

</div>

Any solution is welcome.

I would have liked it to be something of a block like Pulse Generator, but if there are other variants there is no upset or to say no.

---

<div class="post-metadata">

**Author:** ![wolfgang](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/wolfgang/32/7_2.png) [@wolfgang](https://forum.plexim.com/u/wolfgang)\
**Post date:** [March 10, 2021, 8:52am UTC](https://forum.plexim.com/t/pulse-generator-square-wave-with-controllable-rise-time-and-fall-time/978/4 "2021-03-10T08:52:17Z")

</div>

Here is an easy and efficient way to produce arbitrary periodic, piece-wise linear signals:

Use a Triangular Wave Generator to produce a rising sawtooth signal from 0 to 1 with the desired period.Use a 1D Look-Up Table to map the range [0, 1] to your desired signal shape. You’ll need to do some math in order to calculate the coordinates of the corner points from your input parameters. Set the parameter Locate discontinuities to on in order to ensure that a variable-step solver will make a simulation step at the important points.Wrap this into a masked subsystem as desired.
