Difference between revisions of "Robotino3 PI controller"

From RobotinoWiki
(Implementation in Robotino's microcontroller)
(Robotino 2 firmware)
 
(2 intermediate revisions by the same user not shown)
Line 37: Line 37:
  
 
if( 0 == ss && 0 == y )
 
if( 0 == ss && 0 == y )
{
 
u *= ud; //we scale down u to bring it to zero in this situation
 
}
 
 
if( u < 1.0f && u > -1.0f )
 
 
{
 
{
 
u = 0;
 
u = 0;
Line 61: Line 56:
 
|-
 
|-
 
|K
 
|K
|8
+
|0.4
 
|-
 
|-
 
|Ki
 
|Ki
|0.25
 
|-
 
|ud
 
 
|0.01
 
|0.01
 
|}
 
|}
Line 75: Line 67:
  
 
==Robotino 2 firmware==
 
==Robotino 2 firmware==
The PI controller outlined above is implemented starting with firmware version 1.4.0. Both APIs (openrobotino1 and robotino-api2) currently support setting parameters kp, ki, kd for the controller. To combine this with the new controller implementation we choose the following transformation:
+
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:
 
<pre>
 
<pre>
K = 0.1 * kp
+
K = 0.01 * kp
Ki = 0.01 * ki
+
Ki = 0.001 * ki
ud = 1/kd if kd>0 else ud=1
+
kd is ignored
 
 
default values:
 
kp = 80
 
ki = 25
 
kd = 100
 
 
</pre>
 
</pre>

Latest revision as of 17:42, 16 October 2012

Discrete PI controller

Pi controller discrete formula.png

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.

PI controller response

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