pid

Performs proportional integral derivative (PID) processing for each input matrix data array.

Syntax

DSP style:

typedef struct {
    Ipp32f A0;
    Ipp32f A1;
    Ipp32f A2;
    Ipp32f state[3];
    Ipp32f Kp;
    Ipp32f Ki;
    Ipp32f Kd;
} ippsq_pid_instance_f32;

void ippsq_pid_init_f32 (ippsq_pid_instance_f32 *S, int32_t resetStateFlag);

void ippsq_pid_reset_f32 (ippsq_pid_instance_f32 *S);

float32_t ippsq_pid_f32 (ippsq_pid_instance_f32 *S, float32_t in);

typedef struct {
    Ipp16s A0;
    Ipp32s A1;
    Ipp16s state[3];
    Ipp16s Kp;
    Ipp16s Ki;
    Ipp16s Kd;
} ippsq_pid_instance_q15;

void ippsq_pid_init_q15 (ippsq_pid_instance_q15 *S, int32_t resetStateFlag);

void ippsq_pid_reset_q15 (ippsq_pid_instance_q15 *S);

q15_t ippsq_pid_q15 (ippsq_pid_instance_q15 *S, q15_t in);

typedef struct {
    Ipp32s A0;
    Ipp32s A1;
    Ipp32s A2;
    Ipp32s state[3];
    Ipp32s Kp;
    Ipp32s Ki;
    Ipp32s Kd;
} ippsq_pid_instance_q31;

void ippsq_pid_init_q31 (ippsq_pid_instance_q31 *S, int32_t resetStateFlag);

void ippsq_pid_reset_q31 (ippsq_pid_instance_q31 *S);

q31_t ippsq_pid_q31 (ippsq_pid_instance_q31 *S, q31_t in);

Include Files

dsp.h

Parameters

resetStateFlag

Reset flag.

in

Input value.

Kp

Proportional coefficient.

Ki

Integral coefficient.

Kd

Derivative coefficient.

state

Array containing delay line values.

Description

These functions use feedback control loop for automatic process regulation. Each function type (f32, q15, q31) has its own state structure, which must be initialized with the corresponding initialization function. Before calling the ippsq_pid_init function, initialize the Kp, Ki and Kd coefficients. The initialization function copies arguments into the state structure and, if resetStateFlag is equal to 1, sets the internal state array to zero. To reset the internal state array, use the ippsq_pid_reset function.

The ippsq_pid function performs PID processing for each input value in:

Y(n) = y(n-1) + Kp*(x(n)-x(n-1)) + Ki*x(n) + Kd*(x(n)–2*x(n-1)+x(n-2))

where

x(n) = in

The figure below schematically shows the function's algorithm:



Example

ex_dsqpid.c

For more complete information about compiler optimizations, see our Optimization Notice.