Heater for threaded program
Dependents: LEX_Threaded_Programming
Diff: Heater.h
- Revision:
- 26:f6c98b05ee85
- Parent:
- 25:09a315a59956
--- a/Heater.h Mon Aug 19 07:55:38 2019 +0000 +++ b/Heater.h Tue Aug 27 07:51:30 2019 +0000 @@ -10,19 +10,11 @@ #include "mbed.h" #include "ADS8568_ADC.h" #include "FastPWM.h" +#include "memspcr.pb.h" -#define MEAS_DELAY 60 // 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 4.0f //proportional gain -#define Ti 0.5f //Integration time -#define Kd 0.1f //Differentiator gain #define WIND_UP_LIMIT 0.1f //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 10 //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 @@ -30,22 +22,16 @@ //This class provides the interface through which each heater can be controlled public: /** 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 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 + * @param thermal passes in all the information needed for the heater **/ - Heater(const int i_port, const int v_port, FastPWM * drive, FastPWM * guard, const float corr_grad, const float corr_int, float R_ref = 0); + Heater(const memspcr_ThermalConfiguration & ); //Public member functions void read(); //Updates the resistance and error values for the heater void update(); //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 output() const; //Prints the current state of the heater + void log() const; //Prints the current state of the heater void turn_on(); //Turns the heater on void turn_off(); //Turns the heater off @@ -68,23 +54,20 @@ protected: - + const memspcr_ThermalConfiguration thermal; int curr; //Latest current reading from ADC int v; //Latest voltage reading from ADC float R; //Latest resistance calculated from ADC current and voltage float R_ref; //Current referance for resistance float error; //R_ref - R - //float error_diff; //Differential error float error_integrated; //Integrated error - const int i_port; //ADC port which corresponds to current measurements - const int v_port; //ADC port which corresponds to voltage measurements + int i_port; //ADC port which corresponds to current measurements + 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; - const float corr_int; int log_count; };