FERSAT-ZAD7-PID_Refactoring/Code/main/pid_reg.cpp
void PID_Init(PID_Handle_t *hpid, float Kp, float Ki, float Kd, float V, float Ts) {
    if (hpid == NULL) {
        return; /* failure */
    }

    if (Ts <= 0.0f || V <= 0.0f) {
        return; /* Failure */
    }

    /* Set coefficients */
  	hpid->Kp = Kp;
  	hpid->Ki = Ki;
  	hpid->Kd = Kd;
  	hpid->Ts = Ts;
    hpid->V  = V;
  
    hpid->up0 = 0.0f;  
    hpid->ui0 = 0.0f;  
    hpid->ui1 = 0.0f;  
    hpid->ud0 = 0.0f;  
    hpid->ud1 = 0.0f;  
    hpid->u0  = 0.0f;   
    hpid->e0  = 0.0f;
    hpid->e1  = 0.0f;
  
    return; /* Success */
}
/**
 * Initialize PID regulator
 * 
 * PID_Handle_t *hpid - PID regulator handle. Regulator has Parrarel structure. 
 *    See documentation folder for more info.
 * float Kp - Proportional coefficient
 * float Ki - Integral coefficient
 * float Kd - Derivative coefficient
 * float V  - Low pass coefficint in derivative term (typ. 5 to 20).
 *    Higher the value, lower the cutt-off frequency.
 * float Ts - Sample time in seconds
 * 
 * This function can be called when the User wants to change some coefficients.
 * But the function will also reset the Integral part of the controller to 
 * zero.
 * 
 * */
Initialize PID regulator

PID_Handle_t *hpid - PID regulator handle. Regulator has Parrarel structure.
See documentation folder for more info.
float Kp - Proportional coefficient
float Ki - Integral coefficient
float Kd - Derivative coefficient
float V  - Low pass coefficint in derivative term (typ.

This function can be called when the User wants to change some coefficients.
But the function will also reset the Integral part of the controller to
zero.
Initialize PID regulator PID_Handle_t * hpid - PID regulator handle . Regulator has Parrarel structure . See documentation folder for more info . float Kp - Proportional coefficient float Ki - Integral coefficient float Kd - Derivative coefficient float V - Low pass coefficint in derivative term ( typ . This function can be called when the User wants to change some coefficients . But the function will also reset the Integral part of the controller to zero .
void PID_Init(PID_Handle_t *hpid, float Kp, float Ki, float Kd, float V, float Ts) {
    if (hpid == NULL) {
        return; 
    }
    if (Ts <= 0.0f || V <= 0.0f) {
        return; 
    }
  	hpid->Kp = Kp;
  	hpid->Ki = Ki;
  	hpid->Kd = Kd;
  	hpid->Ts = Ts;
    hpid->V  = V;
    hpid->up0 = 0.0f;  
    hpid->ui0 = 0.0f;  
    hpid->ui1 = 0.0f;  
    hpid->ud0 = 0.0f;  
    hpid->ud1 = 0.0f;  
    hpid->u0  = 0.0f;   
    hpid->e0  = 0.0f;
    hpid->e1  = 0.0f;
    return; 
}
void PID_Init ( PID_Handle_t * hpid , float Kp , float Ki , float Kd , float V , float Ts ) { if ( hpid == NULL ) { return ; } if ( Ts <= 0.0f || V <= 0.0f ) { return ; } hpid -> Kp = Kp ; hpid -> Ki = Ki ; hpid -> Kd = Kd ; hpid -> Ts = Ts ; hpid -> V = V ; hpid -> up0 = 0.0f ; hpid -> ui0 = 0.0f ; hpid -> ui1 = 0.0f ; hpid -> ud0 = 0.0f ; hpid -> ud1 = 0.0f ; hpid -> u0 = 0.0f ; hpid -> e0 = 0.0f ; hpid -> e1 = 0.0f ; return ; }
Initialize PID regulator
Initialize PID regulator
/* failure */ /* Failure */ /* Set coefficients */ /* Success */