Robotino3 PI controller
Contents
Discrete PI controller
a) is the PI controller in continuous time domain form.
b) is the approximation of the integral by a discrete sum.
c) is the resulting discretised PI controller.
d) is the discretised PI control law time shift back one interval.
e) is derived by subtracting d) from c). e) is the so called velocity form of the discretised PI controller.
Implementation in Robotino's microcontroller
//K - proportional gain //Ki - gain //ss - speed set-point //y - actual speed //u - control signal //ud - decay factor to bring u down to zero in the case that err and ss are both 0 already //up - u(t-1) //ep - err(t-1) float err = ss - y; float u; if( 0 == Ki ) { u = K * err; // There is no integral term } else { u = up + K * (err - ep) + Ki * err; } if( 0 == ss && 0 == y ) { u = 0; } up = u; ep = err; if( u > 255.0f ) u = 255.0f; else if( u < -255.0f ) u = -255.0f;
Parameterisation
The default parameters are:
Name | Value |
---|---|
K | 0.4 |
Ki | 0.01 |
With these parameters we get a response like shown in the figure. Speed set-point is 1000 encoder ticks per motor revolution per sampling period of 1kHz.
Robotino 2 firmware
The PI controller outlined above is implemented starting with firmware version 1.4.0. The openrobotino1 API (and Robotino View 2.x) support setting parameters kp, ki, kd for the controller in terms of an 8bit value range 0-255. To combine this with the new controller implementation we choose the following transformation:
K = 0.01 * kp Ki = 0.001 * ki kd is ignored