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

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

    /* Set coefficients */
	hpid->Kp = Kp;
	hpid->Ki = Ki;
	hpid->Kd = Kd;
	hpid->Ts = Ts;

    /* Set starting input and output values */
	hpid->e0 = 0.0f;
	hpid->e1 = 0.0f;
	hpid->u0 = 0.0f;
    hpid->integral = 0.0f;

    return; /* Success */
}
/**
 * Initialize PID regulator
 * 
 * PID_Handle_t *hpid - PID regulator handle
 * float Kp - Proportional coefficient
 * float Ki - Integral coefficient
 * float Kd - Derivative coefficient
 * 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



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 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 Ts) {
    if (hpid == NULL) {
        return; 
    }
    if (Ts <= 0.0f) {
        return; 
    }
	hpid->Kp = Kp;
	hpid->Ki = Ki;
	hpid->Kd = Kd;
	hpid->Ts = Ts;
	hpid->e0 = 0.0f;
	hpid->e1 = 0.0f;
	hpid->u0 = 0.0f;
    hpid->integral = 0.0f;
    return; 
}
void PID_Init ( PID_Handle_t * hpid , float Kp , float Ki , float Kd , float Ts ) { if ( hpid == NULL ) { return ; } if ( Ts <= 0.0f ) { return ; } hpid -> Kp = Kp ; hpid -> Ki = Ki ; hpid -> Kd = Kd ; hpid -> Ts = Ts ; hpid -> e0 = 0.0f ; hpid -> e1 = 0.0f ; hpid -> u0 = 0.0f ; hpid -> integral = 0.0f ; return ; }
Initialize PID regulator
Initialize PID regulator
/* failure */ /* Failure */ /* Set coefficients */ /* Set starting input and output values */ /* Success */