Have written below code, but outout is very fluctating and then clamped to either zero or highest.
This is general three gains Kp, Ki and Kd.
I think one reason might be: dimensions dont match on both sides . Though i am not sure of this.
1. kp has unit : (change in output)/celsius.
since Kp is proportional to D/A , where D= change in output which we take 0 to 100, since its relay method.
A= change in temperature.
2. ki = 1.2*Ku/Tu so its units: (change in output)/(celsius * second).
3. ki = 0.075*Ku*Tu so its units: (change in output * second)/(celsius).
4.While on left of equation , which is outout it is dimension less or percentage
I have checked another PID controller from another company they also used porportional band, ;
https://web-material3.yokogawa.com/IM05P01C31-01EN.pdfBut i dont get how to caculate it.
Defination sats: " It is amount of change in input (or deviation), as a percent of span, required to cause the control output to change from 0% to 100% "
For example in our test, with set point 70C, max goes to 78.6, minimum goes to 69.0,
sensor span is -200C to + 600C
How to calculate it?
is it : (78.6-69.0)*100/(600+200C) ??
void compute_pid_duty_cycle(void)
{
float32_t error;
float32_t temp_integral;
float32_t derivative;
/* get error */
error = setpoint_temperature - input_temperature;
if(first_time)
{
first_time = 0U;
previous_err = error;
}
/* integral error */
integral = integral + error; //dt = 1sec
temp_integral = integral * ki;
if(temp_integral > c_output_max) //integral windup up
{
temp_integral = c_output_max;
}
else if(temp_integral < c_output_min)
{
temp_integral = c_output_min;
}
else
{
}
/* differential error */
derivative = error - previous_err; //dt = 1seconds
/* Compute PID Output */
output_duty_cycle = (kp * error) + (temp_integral) + (kd * derivative);
if(output_duty_cycle > c_output_max)
{
output_duty_cycle = c_output_max;
}
else if(output_duty_cycle < c_output_min)
{
output_duty_cycle = c_output_min;
}
else
{
}
/* Remember some variables for next time */
previous_err = error;
} /* function ends here */