Digital signal "square" wave function with finite rise time

Is there a built in function for a non-ideal square wave with finite rise and fall times to approximate digital signals?

I know this should be possible with a piece-wise function but I though Mathematica is so extensive there may be a built in function.

• Can you give an example of that sort of square wave? Commented Jul 31, 2016 at 14:41
• Welcome! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign!
– user9660
Commented Jul 31, 2016 at 15:11
• @axk: depends on what you want to do with the waveform. For signal processing I would use a pure square wave feeding a 1st order filter. Everything is kept linear, so you can do either numerical simulation or Laplace calculations. Commented Jul 31, 2016 at 18:02
• I was thinking having a function that I can use in a differential equasion with DSolve to solve for voltages and currents in a simple buck converter type switching power supply.
– axk
Commented Aug 1, 2016 at 13:11

In absence of a specific example perhaps a clipped triangle wave would be of use?

Manipulate[
Plot[Clip[c*TriangleWave[x]], {x, 0, 3}],
{c, 1, 30}
]


Two more options using filtering, though not directly as a function.

FIR:

sq = Table[SquareWave[x], {x, 0, 4, 0.01}];

Manipulate[ListLinePlot @ LowpassFilter[sq, ω], {ω, 0.05, 0.5}]


IIR:

Manipulate[
ListLinePlot @ RecurrenceFilter[{{1, β}, {1}}, sq],
{β, -0.90, -0.1}
]


SquareWave is a built-in function:

Plot[(1 + SquareWave[x]) /2, {x, 0, 3}, ExclusionsStyle -> Dotted]


For finite rise and fall times, you could try FourierSinSeries (change the parameters if you need):

mysquarewave[x_] := Evaluate[FourierSinSeries[SquareWave[x], x, 10,
FourierParameters -> {1, 2 Pi}]];
Plot[(1 + mysquarewave[x]) /2, {x, 0, 3}]


• Yes, but if we consider OP's "finite rise and fall times", that's apparently not what s/he wants. (But OP should really clarify...) Commented Jul 31, 2016 at 17:06
• @J.M. I submitted my answer too early... Fixed it! Commented Jul 31, 2016 at 17:45
• I dunno... Gibbs might or might not be a problem for the second one. Commented Jul 31, 2016 at 17:45