PWM control not working

Maybe this will help. It’s something I put together quite a while ago.