Help PID with encoder

Finally my project works, but i cant find out Kp,Ki,Kd parameters and it fluctuates around setpoint.
So let me know how to get the parameter.
I want to set sampling time 20ms, is it correct ?
Thank you for ur help.

/////////// MOTOR PINS
#define encoder0PinA  2
#define encoder0PinB  4
#define motorPin1 5
#define motorPin2 6
volatile unsigned int encoder0Pos = 0;
//////////// 
double setpoint=5000,u=0;
double Kp=5, Ki=0.02, Kd=15;
double err,last_err,err_sum,err_del = 0;
double currentPoint;



unsigned long lastTime;
int SampleTime = 20;

void PIDCompute()
{
currentPoint = encoder0Pos;
unsigned long now = millis();
   double timeChange = (double)(now - lastTime);
  if(timeChange>=SampleTime)
   {
      err= setpoint - currentPoint;
      err_sum += (err * timeChange);
      err_del = (err - last_err) / timeChange;
      
   // Compute PID
   
      u+= Kp*err + Ki*err_sum + Kd*err_del;
      last_err = err;
      lastTime = now;
   }
   if (u>255) {u=255;}
   else if (u<-255) {u=-255;}
   
   
}
void setup() { 
  Serial.begin(115200);
  pinMode(3, OUTPUT);
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(encoder0PinA, INPUT); 
  digitalWrite(encoder0PinA, HIGH);       // turn on pullup resistor
  pinMode(encoder0PinB, INPUT); 
  digitalWrite(encoder0PinB, HIGH);       // turn on pullup resistor
  attachInterrupt(0, doEncoder, CHANGE);  // encoder pin on interrupt 0 - pin 2 


} 

void loop()
{
  
  PIDCompute();
  if(err > 0) {
  fwd();
            }
  else if(err <0){
  bwd();
              }
  else {u=0;}
  
}

////////////// Motor forward
void fwd()
{
digitalWrite(motorPin2,LOW);
analogWrite(motorPin1,abs(u));
}
//////////////Motor backward
void bwd()
{
digitalWrite(motorPin1,LOW);
analogWrite(motorPin2,abs(u));
}
////////////// Feedback Process
void doEncoder() {
  
  if (digitalRead(encoder0PinA) == digitalRead(encoder0PinB)) {
    encoder0Pos++;
  } else {
    encoder0Pos--;
  }
}