Heater for threaded program

Dependents:   LEX_Threaded_Programming_V3

Committer:
justinbuckland
Date:
Wed Sep 04 10:18:17 2019 +0000
Revision:
32:34921454e932
Parent:
31:7c6f05326c4d
Child:
34:294adcc3e4b2
PC output format updated

Who changed what in which revision?

UserRevisionLine numberNew 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 31:7c6f05326c4d 15 //TODO Put these in the configuration file
omatthews 12:8a048f111140 16
omatthews 18:f5d26d3d532f 17
omatthews 31:7c6f05326c4d 18 #define WIND_UP_LIMIT 0.002f //The change in error which turns off the integral term
omatthews 31:7c6f05326c4d 19 #define PWM_LIMIT 0.6f
omatthews 0:4e33cc8171f4 20
omatthews 0:4e33cc8171f4 21 class Heater
omatthews 0:4e33cc8171f4 22 {
omatthews 7:59ece353eea2 23 //This class provides the interface through which each heater can be controlled
omatthews 30:055d856f05b5 24 public:
omatthews 30:055d856f05b5 25 /** Constructor
omatthews 30:055d856f05b5 26 * @param thermal passes in all the control information needed for the heater
omatthews 30:055d856f05b5 27 * @param i_port is the ADC port relating to the current read
omatthews 30:055d856f05b5 28 * @param v_port is the ADC port relating to the voltage read
omatthews 30:055d856f05b5 29 * @param * drive is a pointer to the main heater
omatthews 30:055d856f05b5 30 * @param * guard is a pointer to the guard heater
omatthews 30:055d856f05b5 31 **/
omatthews 31:7c6f05326c4d 32 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 33
justinbuckland 32:34921454e932 34
omatthews 30:055d856f05b5 35 //Public member functions
omatthews 30:055d856f05b5 36
justinbuckland 32:34921454e932 37 void read(); //Updates the resistance and error values for the heater
justinbuckland 32:34921454e932 38 void update(); //Holds R_ref for hold_time miliseconds
omatthews 30:055d856f05b5 39 void turn_on(); //Turns the heater on
omatthews 30:055d856f05b5 40 void turn_off(); //Turns the heater off
omatthews 25:09a315a59956 41
justinbuckland 32:34921454e932 42 //Getters and setters
omatthews 30:055d856f05b5 43 void Set_ref(float R);
omatthews 30:055d856f05b5 44 void Set_D(float D);
omatthews 31:7c6f05326c4d 45 int Get_D() const;
omatthews 30:055d856f05b5 46 int Get_i() const;
omatthews 30:055d856f05b5 47 int Get_v() const;
omatthews 30:055d856f05b5 48 float Get_R() const;
omatthews 31:7c6f05326c4d 49 float Get_R_ref() const;
omatthews 31:7c6f05326c4d 50 float Get_error() const;
omatthews 31:7c6f05326c4d 51 float Get_error_integrated() const;
omatthews 0:4e33cc8171f4 52
omatthews 30:055d856f05b5 53 protected:
omatthews 16:cd837b230b09 54
omatthews 30:055d856f05b5 55 const memspcr_ThermalConfiguration thermal;
omatthews 30:055d856f05b5 56 int curr; //Latest current reading from ADC
omatthews 30:055d856f05b5 57 int v; //Latest voltage reading from ADC
omatthews 30:055d856f05b5 58 float R; //Latest resistance calculated from ADC current and voltage
omatthews 30:055d856f05b5 59 float R_ref; //Current referance for resistance
omatthews 30:055d856f05b5 60 float error; //R_ref - R
omatthews 30:055d856f05b5 61 float error_integrated; //Integrated error
omatthews 31:7c6f05326c4d 62 ADS8568_ADC * adc;
omatthews 31:7c6f05326c4d 63 DigitalIn adc_busy;
omatthews 30:055d856f05b5 64 int i_port; //ADC port which corresponds to current measurements
omatthews 30:055d856f05b5 65 int v_port; //ADC port which corresponds to voltage measurements
omatthews 30:055d856f05b5 66 FastPWM * drive; //Pointer to the driver
omatthews 30:055d856f05b5 67 FastPWM * guard; //Pointer to the guard
omatthews 30:055d856f05b5 68
omatthews 0:4e33cc8171f4 69 };
omatthews 30:055d856f05b5 70
omatthews 19:fccdd7127f94 71 #endif