Block: PID



PIC




Inports


In

Control error input



Init

Value which is loaded at initialization function call



Enable

Enable == 0: Deactivation of block; Out set to 0

Enable 0->1: Preload of integral part

Enable == 1: Activation of block






Outports


Out






Mask Parameters


Kp

Proportional Factor



Ki

Integral Factor



Kd

Derivative Factor



fc

Cutoff frequency of realization low pass



ts_fact

Multiplication factor of base sampling time (in integer format)




Description:

PID controller:

G(s) = Kp + Ki/s + Kd*s/(s/(2*pi*fc) + 1)

Each fixed point implementation uses the next higher integer datatype for the integrational value storage variable.

A rising flank at the Enable inport will preload the integrational part with the value present on the Init inport.

Transfer function (zero-order hold discretization method):

                   --1--        --z---1---
G (z) =   KP + KITsz - 1 + KD ωc z- e- ωcTs

FiP8 bug: When using the TI compiler the step response of the derivative part doesn’t return to zero, but generates an overflow at zero crossing if the derivative parameter value is too high.

Developer note: For the fixed point implementations the source code of block PIDLimit is used.

Implementations:
FiP8 8 Bit Fixed Point Implementation
FiP16 16 Bit Fixed Point Implementation
FiP32 32 Bit Fixed Point Implementation
Float32 32 Bit Floating Point Implementation
Float64 64 Bit Floating Point Implementation

Implementation: FiP8


Name FiP8
ID 3248
Revision 1.0
C filename PID_FiP8.c
H filename PID_FiP8.h

8 Bit Fixed Point Implementation



Controller Parameters


b0

Integral coefficient



b1

Proportional coefficient



b0d

Derivational coefficient b0



b1d

Derivational coefficient b1



a0d

Derivational coefficient a0



sfrb0

Shift factor for PI coefficient b0



sfrb1

Shift factor for PI coefficient b1



sfrd

Shift factor for D coefficients b0d and b1d



in_old

Input value of previous cycle



i_old

Integrator value of previous cycle



d_old

Derivative value of previous cycle



enable_old

Enable value of previous cycle




Data Structure:

typedef struct { 
     uint16        ID; 
     int8          *In; 
     int8          *Init; 
     int8          *Enable; 
     int8          Out; 
     int8          b0; 
     int8          b1; 
     int8          b0d; 
     int8          b1d; 
     int8          a0d; 
     int8          sfrb0; 
     int8          sfrb1; 
     int8          sfrd; 
     int8          in_old; 
     int16         i_old; 
     int8          d_old; 
     int8          enable_old; 
} PID_FIP8;

Implementation: FiP16


Name FiP16
ID 3249
Revision 1.0
C filename PID_FiP16.c
H filename PID_FiP16.h

16 Bit Fixed Point Implementation



Controller Parameters


b0

Integral coefficient



b1

Proportional coefficient



b0d

Derivational coefficient b0



b1d

Derivational coefficient b1



a0d

Derivational coefficient a0



sfrb0

Shift factor for PI coefficient b0



sfrb1

Shift factor for PI coefficient b1



sfrd

Shift factor for D coefficients b0d and b1d



in_old

Input value of previous cycle



i_old

Integrator value of previous cycle



d_old

Derivative value of previous cycle



enable_old

Enable value of previous cycle




Data Structure:

typedef struct { 
     uint16        ID; 
     int16         *In; 
     int16         *Init; 
     int8          *Enable; 
     int16         Out; 
     int16         b0; 
     int16         b1; 
     int16         b0d; 
     int16         b1d; 
     int16         a0d; 
     int8          sfrb0; 
     int8          sfrb1; 
     int8          sfrd; 
     int16         in_old; 
     int32         i_old; 
     int16         d_old; 
     int8          enable_old; 
} PID_FIP16;

Implementation: FiP32


Name FiP32
ID 3250
Revision 1.0
C filename PID_FiP32.c
H filename PID_FiP32.h

32 Bit Fixed Point Implementation



Controller Parameters


b0

Integral coefficient



b1

Proportional coefficient



b0d

Derivational coefficient b0



b1d

Derivational coefficient b1



a0d

Derivational coefficient a0



sfrb0

Shift factor for PI coefficient b0



sfrb1

Shift factor for PI coefficient b1



sfrd

Shift factor for D coefficients b0d and b1d



in_old

Input value of previous cycle



i_old

Integrator value of previous cycle



d_old

Derivative value of previous cycle



enable_old

Enable value of previous cycle




Data Structure:

typedef struct { 
     uint16        ID; 
     int32         *In; 
     int32         *Init; 
     int8          *Enable; 
     int32         Out; 
     int32         b0; 
     int32         b1; 
     int32         b0d; 
     int32         b1d; 
     int32         a0d; 
     int8          sfrb0; 
     int8          sfrb1; 
     int8          sfrd; 
     int32         in_old; 
     int64         i_old; 
     int32         d_old; 
     int8          enable_old; 
} PID_FIP32;

Implementation: Float32


Name Float32
ID 3251
Revision 0.1
C filename PID_Float32.c
H filename PID_Float32.h

32 Bit Floating Point Implementation



Controller Parameters


b0

Integral coefficient



b1

Proportional coefficient



b0d

Derivational coefficient b0



b1d

Derivational coefficient b1



a0d

Derivational coefficient a0



in_old

Input value of previous cycle



i_old

Integrator value of previous cycle



d_old

Derivative value of previous cycle



enable_old

Enable value of previous cycle




Data Structure:

typedef struct { 
     uint16        ID; 
     float32       *In; 
     float32       *Init; 
     int8          *Enable; 
     float32       Out; 
     float32       b0; 
     float32       b1; 
     float32       b0d; 
     float32       b1d; 
     float32       a0d; 
     float32       in_old; 
     float32       i_old; 
     float32       d_old; 
     int8          enable_old; 
} PID_FLOAT32;

Implementation: Float64


Name Float64
ID 3252
Revision 0.1
C filename PID_Float64.c
H filename PID_Float64.h

64 Bit Floating Point Implementation



Controller Parameters


b0

Integral coefficient



b1

Proportional coefficient



b0d

Derivational coefficient b0



b1d

Derivational coefficient b1



a0d

Derivational coefficient a0



in_old

Input value of previous cycle



i_old

Integrator value of previous cycle



d_old

Derivative value of previous cycle



enable_old

Enable value of previous cycle




Data Structure:

typedef struct { 
     uint16        ID; 
     float64       *In; 
     float64       *Init; 
     int8          *Enable; 
     float64       Out; 
     float64       b0; 
     float64       b1; 
     float64       b0d; 
     float64       b1d; 
     float64       a0d; 
     float64       in_old; 
     float64       i_old; 
     float64       d_old; 
     int8          enable_old; 
} PID_FLOAT64;