FMradio
Member level 3
Hey guys!
I am working on a servo motor drive so far its working great but now I am facing a problem related to PID parameter values
Servo loop time = 5ms
Encoder PPR = 1000
Motor RPM (max) = 4200
Kp = 5, Ki = 1, Kd = 3 (signed int16)
Motor (signed int16)
Here is my Servo Controlling Algorithm
Servo loop:
Error = reference position – encoder position
If(Error > 1023) Error = 1023
Else if(Error <-1023) Error = 1023
Motor = PID (Error);
If(Motor > 1023) Motor = 1023
Else if(Motor <-1023) Motor = 1023
Goto Servo loop;
Now my Problem is that I can’t increase the range of my PID parameters values, I have seen in a Ready Made Servo drive it takes in the PID values up to 16bits more flexible better for precise tuning & It can take a small servo loop time up to 125u seconds , here in my case lets assume
Error = 1023; (maxium)
in PID
P = Error x Kp; // 1023 x 5 = 5115
I = summation f(Error) x Ki; // it will grow with time “Servo loop time”
D = difference of Errors x Kd
Motor = P + I + D // it will saturated
Here if I reduce my servo loop time then the integrator will sum up the error more quickly right and I can’t go below Ki=1 (minimum), & if I make Ki > 1 Motor starts oscillating. “Stuck”
& if I increase Kp then P=32 will exceed 32000 again it will saturated (signed int16)
Similarly with Kd,
I am not using any floating variables in order to minimize the computation cost,
now whats the solution??
I am working on a servo motor drive so far its working great but now I am facing a problem related to PID parameter values
Servo loop time = 5ms
Encoder PPR = 1000
Motor RPM (max) = 4200
Kp = 5, Ki = 1, Kd = 3 (signed int16)
Motor (signed int16)
Here is my Servo Controlling Algorithm
Servo loop:
Error = reference position – encoder position
If(Error > 1023) Error = 1023
Else if(Error <-1023) Error = 1023
Motor = PID (Error);
If(Motor > 1023) Motor = 1023
Else if(Motor <-1023) Motor = 1023
Goto Servo loop;
Now my Problem is that I can’t increase the range of my PID parameters values, I have seen in a Ready Made Servo drive it takes in the PID values up to 16bits more flexible better for precise tuning & It can take a small servo loop time up to 125u seconds , here in my case lets assume
Error = 1023; (maxium)
in PID
P = Error x Kp; // 1023 x 5 = 5115
I = summation f(Error) x Ki; // it will grow with time “Servo loop time”
D = difference of Errors x Kd
Motor = P + I + D // it will saturated
Here if I reduce my servo loop time then the integrator will sum up the error more quickly right and I can’t go below Ki=1 (minimum), & if I make Ki > 1 Motor starts oscillating. “Stuck”
& if I increase Kp then P=32 will exceed 32000 again it will saturated (signed int16)
Similarly with Kd,
I am not using any floating variables in order to minimize the computation cost,
now whats the solution??