PWM/ RPM feedback loop

Im trying to create a feedback loop that looks at the error and adjust accordingly. Im not really sure how to go about this.

Maybe by using the PID library