inkscapeCartesianPlotFunction2D icon indicating copy to clipboard operation
inkscapeCartesianPlotFunction2D copied to clipboard

[Enhancement] Adding some PWM functions in the cartesianPlotFunction2D.py

Open jalinei opened this issue 3 years ago • 0 comments

Hi, Thanks for this amazing tool. We had to generate plots with PWM signals recently and it took us quite a long time to figure out how to define them from the squareWave function that is defined by default. Below are a suggestion of functions that may be quite useful to the electronics crowd.

def pwm(x, amplitude, offset, period, duty, deadtime, phase):
    return amplitude * (u(((x-phase) % period)) - u(((x-phase) % period) - period*(duty-deadtime))) + offset

def pwmComp(x, amplitude, offset, period, duty, deadtime, phase):
    return amplitude * (u(((x-(duty+phase)) % period)) - u(((x-(duty+phase)) % period) - period*((1-duty)-deadtime))) + offset

jalinei avatar Oct 19 '22 10:10 jalinei