Autotune PID code question


hi,
i have high temp furnace need control temperature ramp , final temperature.
i use arduino pid , autotune libraries mega1280 board, due slow furnace reaction, not sure how auto tune works, not sure implement 2 files combination right way.
can @ code below (simplified version) or show clean, net pid autotune implementation example (not demo artificial signal)?

here simplified code works, not sure of implementation,
especially of pid setting 'settunings(kp, ki, kd);'.
do have call  (getkp();) p,i,d autotune , set each cycle, or set automatically autotune?


as shown in code, desired ramp achieved calculating new set-point each cycle based on set rate , elapsed time, , limiting set-point final flat set-point constrain command.
so next question is: how autotune work ramp, changing set-point?


code: [select]

#include <pid_autotune_v0.h>
#include <pid_v1.h>

//in pid.h library
pid temp_set(&input, &output, &oven_setpoint, configs.pid_p, configs.pid_i, configs.pid_d, direct);

void setup()
{
.
.

}

void loop()
{

set_oven_temp(oven_target, oven_rate, kp, ki, kd)

}

//this function run time interrupt or in loop.
void set_oven_temp(double oven_target, double rate, double kp, double ki, double kd)
{
  //read current temperature thermocouple lookup table
  input = get_oven_temperature();
  
//for ramp calculation, elapsed time since start in sec.
  elapsed_time =  (millis() - oven_start_time) / 1000;
  
//the constrain upper value hold temperature @ final target set point.
  oven_setpoint  = constrain(rate * elapsed_time , 0, configs.oven_target);
  
temp_set.settunings(oven_temp_set.getkp(),oven_temp_set.getki(),oven_temp_set.getkd());
 
 temp_set.compute();  //output = kp * error + ki * errsum + kd * (error-prev_error);

  //normalize pid_output amps.set (100a)
  double output_current =
 
set_power(output / 255 * amps_set)  ; //pid in %);       //set output current
}


thanks
samtal

   


please not cross-post.  other thread removed.



Arduino Forum > Using Arduino > Programming Questions > Autotune PID code question


arduino

Comments