Heater for threaded program
Dependents: LEX_Threaded_Programming
Diff: Heater.h
- Revision:
- 17:0bfed0e96927
- Parent:
- 16:cd837b230b09
- Child:
- 18:f5d26d3d532f
diff -r cd837b230b09 -r 0bfed0e96927 Heater.h --- a/Heater.h Wed Jul 24 14:29:44 2019 +0000 +++ b/Heater.h Thu Jul 25 16:20:01 2019 +0000 @@ -9,14 +9,18 @@ #define Heater_H #include "mbed.h" #include "ADS8568_ADC.h" +#include "FastPWM.h" -#define MEAS_DELAY 80 // measurement delay for ADC +#define MEAS_DELAY 50 // measurement delay for ADC #define WAIT_DELAY 5 // wait delay for ADC #define N_ROLL_AVG 1 // rolling average for R values #define ALL_CH 15 //value of convst bus to read all chanels simultaneosly -#define Kd 0.5f //proportional gain -#define Ki 1.0f //Integrator gain +#define Kp 30.0f //proportional gain +#define Ti 2 //Integration time +#define Kd 0.0f //Differentiator gain +#define WIND_UP_LIMIT 0.006f //Avoids integral windup on a sharp drop in T_ref +#define PWM_PERIOD 50 class Heater { @@ -28,7 +32,7 @@ * @param drive, the motor drive * @param R_ref, the target value for R */ - Heater(int i_port, int v_port, PwmOut * drive, float corr_grad, float corr_int, float R_ref = 1); + Heater(int i_port, int v_port, FastPWM * drive, float corr_grad, float corr_int, float R_ref = 1); //Public member functions @@ -67,11 +71,12 @@ float R; float R_ref; float error; + float error_diff; float error_integrated; int i_port; int v_port; - PwmOut * drive; + FastPWM * drive; //Heater correlations give temperature for a given resistance (assume linear relationship) float corr_grad;