Heater for threaded program
Dependents: LEX_Threaded_Programming_V3
Diff: Heater.h
- Revision:
- 30:055d856f05b5
- Parent:
- 26:f6c98b05ee85
- Child:
- 31:7c6f05326c4d
diff -r 88d9088ddb8a -r 055d856f05b5 Heater.h --- a/Heater.h Tue Aug 27 15:04:29 2019 +0000 +++ b/Heater.h Thu Aug 29 16:07:56 2019 +0000 @@ -13,63 +13,58 @@ #include "memspcr.pb.h" -#define ALL_CH 15 //value of convst bus to read all chanels simultaneosly #define WIND_UP_LIMIT 0.1f //The change in error which turns off the integral term class Heater { //This class provides the interface through which each heater can be controlled - public: - /** Constructor - * @param thermal passes in all the information needed for the heater - **/ - Heater(const memspcr_ThermalConfiguration & ); - - //Public member functions +public: + /** Constructor + * @param thermal passes in all the control information needed for the heater + * @param i_port is the ADC port relating to the current read + * @param v_port is the ADC port relating to the voltage read + * @param * drive is a pointer to the main heater + * @param * guard is a pointer to the guard heater + **/ + Heater(const int i_port, const int v_port, FastPWM * drive, FastPWM * guard, const memspcr_ThermalConfiguration & thermal = memspcr_ThermalConfiguration_init_zero); - 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 log() const; //Prints the current state of the heater - void turn_on(); //Turns the heater on - void turn_off(); //Turns the heater off - - + //Public member functions + + void read(); //Updates the resistance and error values for the heater + void update(); //Holds R_ref for hold_time miliseconds + void log() const; //Prints the current state of the heater + void turn_on(); //Turns the heater on + void turn_off(); //Turns the heater off - - - //Getters and setters - void Set_ref(float R); - void Set_D(float D); - int Get_i() const; - int Get_v() const; - float Get_R() const; - - + //Getters and setters + void Set_ref(float R); + void Set_D(float D); + int Get_i() const; + int Get_v() const; + float Get_R() const; + + + + - - - 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_integrated; //Integrated error - - 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 +protected: - //Heater correlations give temperature for a given resistance (assume linear relationship) - int log_count; - + 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_integrated; //Integrated error + + 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 + }; - + #endif \ No newline at end of file