Attempt at PWM emulation