After you initialize your PWM hardware and just change your PWM speed on the fly.
0 or 255 is your on or off setting and 1 to 254 is your variable speed.

for fanspeed=0 to 255 step 25
hpwm 1,fanspeed,20000 ' PWM Fan Duty Cycle @ 20,000 Hz
PAUSE 7 ' Delay speed ramp up
next