Heater for threaded program
Dependents: LEX_Threaded_Programming_V3
Heater.h@34:294adcc3e4b2, 2019-09-20 (annotated)
- Committer:
- justinbuckland
- Date:
- Fri Sep 20 14:53:54 2019 +0000
- Revision:
- 34:294adcc3e4b2
- Parent:
- 32:34921454e932
- Child:
- 35:5acf01897ed6
Added board UID, ADC->Ohms resistance cal table; Added pressure control
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
omatthews | 0:4e33cc8171f4 | 1 | /*------------------------------------------------------------------------------ |
omatthews | 0:4e33cc8171f4 | 2 | Library header file for heater operations |
omatthews | 0:4e33cc8171f4 | 3 | Date: 16/07/2018 |
omatthews | 0:4e33cc8171f4 | 4 | |
omatthews | 0:4e33cc8171f4 | 5 | |
omatthews | 0:4e33cc8171f4 | 6 | ------------------------------------------------------------------------------*/ |
omatthews | 0:4e33cc8171f4 | 7 | |
omatthews | 0:4e33cc8171f4 | 8 | #ifndef Heater_H |
omatthews | 0:4e33cc8171f4 | 9 | #define Heater_H |
omatthews | 0:4e33cc8171f4 | 10 | #include "mbed.h" |
omatthews | 0:4e33cc8171f4 | 11 | #include "ADS8568_ADC.h" |
omatthews | 17:0bfed0e96927 | 12 | #include "FastPWM.h" |
omatthews | 26:f6c98b05ee85 | 13 | #include "memspcr.pb.h" |
omatthews | 0:4e33cc8171f4 | 14 | |
omatthews | 0:4e33cc8171f4 | 15 | |
omatthews | 0:4e33cc8171f4 | 16 | class Heater |
omatthews | 0:4e33cc8171f4 | 17 | { |
omatthews | 7:59ece353eea2 | 18 | //This class provides the interface through which each heater can be controlled |
omatthews | 30:055d856f05b5 | 19 | public: |
omatthews | 30:055d856f05b5 | 20 | /** Constructor |
omatthews | 30:055d856f05b5 | 21 | * @param thermal passes in all the control information needed for the heater |
omatthews | 30:055d856f05b5 | 22 | * @param i_port is the ADC port relating to the current read |
omatthews | 30:055d856f05b5 | 23 | * @param v_port is the ADC port relating to the voltage read |
omatthews | 30:055d856f05b5 | 24 | * @param * drive is a pointer to the main heater |
omatthews | 30:055d856f05b5 | 25 | * @param * guard is a pointer to the guard heater |
omatthews | 30:055d856f05b5 | 26 | **/ |
omatthews | 31:7c6f05326c4d | 27 | Heater(const int i_port, const int v_port, FastPWM * drive, FastPWM * guard, ADS8568_ADC * adc, DigitalIn adc_busy, const memspcr_ThermalConfiguration & thermal = memspcr_ThermalConfiguration_init_zero); |
omatthews | 0:4e33cc8171f4 | 28 | |
justinbuckland | 32:34921454e932 | 29 | |
omatthews | 30:055d856f05b5 | 30 | //Public member functions |
omatthews | 30:055d856f05b5 | 31 | |
justinbuckland | 32:34921454e932 | 32 | void read(); //Updates the resistance and error values for the heater |
justinbuckland | 32:34921454e932 | 33 | void update(); //Holds R_ref for hold_time miliseconds |
omatthews | 30:055d856f05b5 | 34 | void turn_on(); //Turns the heater on |
omatthews | 30:055d856f05b5 | 35 | void turn_off(); //Turns the heater off |
omatthews | 25:09a315a59956 | 36 | |
justinbuckland | 32:34921454e932 | 37 | //Getters and setters |
omatthews | 30:055d856f05b5 | 38 | void Set_ref(float R); |
omatthews | 30:055d856f05b5 | 39 | void Set_D(float D); |
omatthews | 31:7c6f05326c4d | 40 | int Get_D() const; |
omatthews | 30:055d856f05b5 | 41 | int Get_i() const; |
omatthews | 30:055d856f05b5 | 42 | int Get_v() const; |
omatthews | 30:055d856f05b5 | 43 | float Get_R() const; |
omatthews | 31:7c6f05326c4d | 44 | float Get_R_ref() const; |
omatthews | 31:7c6f05326c4d | 45 | float Get_error() const; |
omatthews | 31:7c6f05326c4d | 46 | float Get_error_integrated() const; |
omatthews | 0:4e33cc8171f4 | 47 | |
omatthews | 30:055d856f05b5 | 48 | protected: |
omatthews | 16:cd837b230b09 | 49 | |
omatthews | 30:055d856f05b5 | 50 | const memspcr_ThermalConfiguration thermal; |
omatthews | 30:055d856f05b5 | 51 | int curr; //Latest current reading from ADC |
omatthews | 30:055d856f05b5 | 52 | int v; //Latest voltage reading from ADC |
omatthews | 30:055d856f05b5 | 53 | float R; //Latest resistance calculated from ADC current and voltage |
omatthews | 30:055d856f05b5 | 54 | float R_ref; //Current referance for resistance |
omatthews | 30:055d856f05b5 | 55 | float error; //R_ref - R |
omatthews | 30:055d856f05b5 | 56 | float error_integrated; //Integrated error |
omatthews | 31:7c6f05326c4d | 57 | ADS8568_ADC * adc; |
omatthews | 31:7c6f05326c4d | 58 | DigitalIn adc_busy; |
omatthews | 30:055d856f05b5 | 59 | int i_port; //ADC port which corresponds to current measurements |
omatthews | 30:055d856f05b5 | 60 | int v_port; //ADC port which corresponds to voltage measurements |
omatthews | 30:055d856f05b5 | 61 | FastPWM * drive; //Pointer to the driver |
omatthews | 30:055d856f05b5 | 62 | FastPWM * guard; //Pointer to the guard |
omatthews | 30:055d856f05b5 | 63 | |
omatthews | 0:4e33cc8171f4 | 64 | }; |
omatthews | 30:055d856f05b5 | 65 | |
omatthews | 19:fccdd7127f94 | 66 | #endif |