Controlled Source Output Function

The controlled source elements take an output function parameter. The output function takes the inputs, if any, as parameters (which will be a, b, etc. for a voltage-controlled source, or i for a current-controlled source). You can also specify t for the current simulation time, pi for π, and e for e (unless there is an input e).

The function can use arithmetic like a+b, a*b, a^2/(b-1), etc. It can also use functions like sin(x), cos(x), abs(x), exp(x), log(x), sqrt(x), tan(x), mod(x,y), max(x,y,...), and min(x,y,...).

The tri(x) function is like sin(x), but generates a triangle waveform.

The saw(x) function is like sin(x), but generates a sawtooth waveform.

The step(x) function is 0 if x < 0, and 1 otherwise. The step(x,y) function is 1 if 0 < x < y, and 0 otherwise.

The clamp(x,lo,hi) function is equal to min(max(x, lo), hi).

The select(x,a,b) function is equal to b if x is greater than zero, and a otherwise.

The pwl(x,x0,y0,x1,y1,x2,y2,...,xn,yn) function is short for piece-wise linear, and works as follows. If x < x0, then the result is y0. If x0 < x < x1, then the result is a linear interpolation between y0 and y1. If x1 < x < x2, the result is a linear interpolation between y1 and y2, etc. If x > xn, then the result is yn. For example, in the simplest case, pwl(t,0,0,.1,5) is a waveform that starts at 0 at time 0 and then ramps to 5 over 100ms, then stays at 5.

Examples: