Just replace the condition :

If pwm_signal = 0 then
Pwm_signal =Pwm_signal
Endif

With:

If pwm_signal >1000 then pwm_signal = 0


Cheers

Al.