Whatever the values the pid_out stays at 511
Oh, and clamp the output to 255 for the HPWM command.

You may want to use 10-bit PWM for finer control.