Three methods to generate an intersective pwm: leading edge modulation, trailing edge modulation or centered modulation. The reference signal is a sine wave, not plotted. See Image:Pwm.svg for more information.
Created in maxima using the following code.

trailsignal(t) := t - floor(t);
leadsignal(t) := ceiling(t)-t;
centersignal(t) := 2*abs(t-floor(t-1/2)-1);
freq : 0.05;
sinesignal(t) := (1/2) + (499/1000)*sin(2*%pi*freq*t);
pwmlead(t) := (if(leadsignal(t) &gt; sinesignal(t)) then 0.0 else 1.0);
pwmtrail(t) := (if(trailsignal(t) &gt; sinesignal(t)) then 0.0 else 1.0);
pwmcenter(t) := (if(centersignal(t) &gt; sinesignal(t)) then 0.0 else 1.0);
load(draw);
draw(terminal=svg,file_name="Three_PWM_types",
    gr2d(yrange=[-0.25,1.25],nticks=20,grid=true,
        user_preamble="set mxtics;set format x "";
             set origin 0,0.67; set size 1,.3;set bmargin 0; 
             set tmargin 0",font="Times",
        ylabel="lead",ytics={0,1},axis_bottom=false,
        color=green,explicit(leadsignal(x),x,0,19),
        color=blue,explicit(pwmlead(x),x,0,19)),
    gr2d(yrange=[-0.25,1.25],nticks=20,grid=true,
        user_preamble="set mxtics;set format x "";
             set origin 0,0.37",font="Times",
        ylabel="trail",ytics={0,1},axis_bottom=false,
        color=green,explicit(trailsignal(x),x,0,19),
        color=blue,explicit(pwmtrail(x),x,0,19)),
    gr2d(yrange=[-0.25,1.25],nticks=20,grid=true,
        user_preamble="set mxtics;set format x "%1.0f T";
             set origin 0,.07",font="Times",
        ylabel="center",ytics={0,1},
        color=green,explicit(centersignal(x),x,0,19),
        color=blue,explicit(pwmcenter(x),x,0,19))
    );
Three_types.png
Three_types.png: Cyril BUTTAY
derivative work: Krishnavedala (talk)