Heater files
Dependents: LEX-Demo-Firmware-Logging LEX-Demo-Firmware-Logging
Diff: Heater.h
- Revision:
- 19:fccdd7127f94
- Parent:
- 18:f5d26d3d532f
- Child:
- 20:e2a504521b46
- Child:
- 22:2d34a03ae57e
diff -r f5d26d3d532f -r fccdd7127f94 Heater.h --- a/Heater.h Sun Jul 28 11:49:57 2019 +0000 +++ b/Heater.h Tue Jul 30 21:32:49 2019 +0000 @@ -11,17 +11,18 @@ #include "ADS8568_ADC.h" #include "FastPWM.h" -#define MEAS_DELAY 50 // measurement delay for ADC -#define WAIT_DELAY 3 // wait delay for ADC +#define MEAS_DELAY 50 // measurement delay for ADC in us +#define WAIT_DELAY 3 // wait delay for ADC in ms #define N_ROLL_AVG 1 // rolling average for R values #define ALL_CH 15 //value of convst bus to read all chanels simultaneosly #define Kp 30.0f //proportional gain -#define Ti 1.0f //Integration time +#define Ti 0.75f //Integration time #define Kd 0.0f //Differentiator gain -#define WIND_UP_LIMIT 0.005f //The change in error which turns off the integral term -#define PWM_PERIOD 5 //Period of Pwm for the motor -#define LOG_LIM 100 //Period of Pwm for the motor +#define WIND_UP_LIMIT 0.01f //The change in error which turns off the integral term +#define PWM_PERIOD 5 //Period of Pwm for the motor in us +#define LOG_LIM 100 //Number of reads before the result is logged +#define GUARD_PWM_RATIO 0.25 //Ratio of guard duty cycle to heater duty cycle class Heater @@ -31,25 +32,26 @@ /** Constructor * @param i_port, the current port in the ADC * @param v_port, the voltage port in the ADC - * @param * drive, a pointer to the motor drive + * @param * drive, a pointer to the heater drive + * @param * guard, a pointer to the guard * @param * corr_grad, the gradient of the linear relationship between resistance and temperature * @param * corr_int, the intercept of the linear relationship between resistance and temperature * @param R_ref (default value 1), optional parameter sets the target value for R **/ - Heater(const int i_port, const int v_port, FastPWM * drive, const float corr_grad, const float corr_int, float R_ref = 1); + Heater(const int i_port, const int v_port, FastPWM * drive, FastPWM * guard, const float corr_grad, const float corr_int, float R_ref = 1); //Public member functions void read(); //Updates the resistance and error values for the heater void hold(const int hold_time); //Holds R_ref for hold_time miliseconds void ramp_R(const int ramp_time, const float R_final, const float R_start); //Ramps for ramp_time miliseconds from R_start to R_final - void ramp_T(const int ramp_time, const float T_final, const float T_start); //Same as above but with T + void ramp_T(const int ramp_time, const float T_final, const float T_start); //Same as above but with T (T is in degrees celcius) void output() const; //Prints the current state of the heater void turn_on(); //Turns the heater on void turn_off(); //Turns the heater off - //Linear conversions between temperature and resistance + //Linear conversions between temperature and resistance. Note that temperature is always in celcius float R_to_T(const float R) const; float T_to_R(const float T) const; @@ -83,6 +85,7 @@ const int i_port; //ADC port which corresponds to current measurements const int v_port; //ADC port which corresponds to voltage measurements FastPWM * drive; //Pointer to the driver + FastPWM * guard; //Pointer to the guard //Heater correlations give temperature for a given resistance (assume linear relationship) const float corr_grad; @@ -90,5 +93,4 @@ }; -#endif - \ No newline at end of file +#endif \ No newline at end of file