Please take a minute to review and accept our Terms of Use.
Welcome to the PLECS User Forum, where you can ask questions and receive answers from other members of the community.

Many technical questions regarding PLECS are answered on the Technical Solutions page of our website. Tutorial videos, specific application examples, and pre-recorded webinars are available on our YouTube page. Please follow us on LinkedIn for the latest Plexim news.

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

0 votes
2,039 views
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.
asked Mar 5, 2021 by Andrew (22 points)

2 Answers

0 votes
using C-script?
answered Mar 6, 2021 by shichenseu (299 points)
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.
0 votes

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

  1. Use a Triangular Wave Generator to produce a rising sawtooth signal from 0 to 1 with the desired period.
  2. 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.
  3. Wrap this into a masked subsystem as desired.
answered Mar 10, 2021 by Wolfgang Hammer (397 points)
...