Heater for threaded program

Dependents:   LEX_Threaded_Programming_V3

Committer:
intrinseca
Date:
Wed Aug 28 15:38:11 2019 +0000
Revision:
29:dd66aa2a4925
Parent:
26:f6c98b05ee85
Review comments

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 12:8a048f111140 15
omatthews 20:2d34a03ae57e 16 #define WIND_UP_LIMIT 0.1f //The change in error which turns off the integral term
omatthews 18:f5d26d3d532f 17
omatthews 0:4e33cc8171f4 18
omatthews 0:4e33cc8171f4 19 class Heater
omatthews 0:4e33cc8171f4 20 {
omatthews 7:59ece353eea2 21 //This class provides the interface through which each heater can be controlled
omatthews 0:4e33cc8171f4 22 public:
omatthews 0:4e33cc8171f4 23 /** Constructor
omatthews 26:f6c98b05ee85 24 * @param thermal passes in all the information needed for the heater
omatthews 18:f5d26d3d532f 25 **/
omatthews 26:f6c98b05ee85 26 Heater(const memspcr_ThermalConfiguration & );
omatthews 0:4e33cc8171f4 27
omatthews 0:4e33cc8171f4 28 //Public member functions
omatthews 0:4e33cc8171f4 29
omatthews 18:f5d26d3d532f 30 void read(); //Updates the resistance and error values for the heater
omatthews 25:09a315a59956 31 void update(); //Holds R_ref for hold_time miliseconds
omatthews 18:f5d26d3d532f 32 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
omatthews 26:f6c98b05ee85 33 void log() const; //Prints the current state of the heater
omatthews 18:f5d26d3d532f 34 void turn_on(); //Turns the heater on
omatthews 18:f5d26d3d532f 35 void turn_off(); //Turns the heater off
omatthews 7:59ece353eea2 36
omatthews 18:f5d26d3d532f 37
omatthews 25:09a315a59956 38
omatthews 1:4435d407d827 39
omatthews 1:4435d407d827 40
omatthews 2:7f15386fcc90 41
omatthews 2:7f15386fcc90 42 //Getters and setters
omatthews 25:09a315a59956 43 void Set_ref(float R);
omatthews 15:e7838491c104 44 void Set_D(float D);
omatthews 18:f5d26d3d532f 45 int Get_i() const;
omatthews 18:f5d26d3d532f 46 int Get_v() const;
omatthews 18:f5d26d3d532f 47 float Get_R() const;
omatthews 7:59ece353eea2 48
omatthews 0:4e33cc8171f4 49
omatthews 18:f5d26d3d532f 50
omatthews 0:4e33cc8171f4 51
omatthews 0:4e33cc8171f4 52
omatthews 0:4e33cc8171f4 53
omatthews 0:4e33cc8171f4 54 protected:
omatthews 0:4e33cc8171f4 55
omatthews 26:f6c98b05ee85 56 const memspcr_ThermalConfiguration thermal;
omatthews 18:f5d26d3d532f 57 int curr; //Latest current reading from ADC
omatthews 18:f5d26d3d532f 58 int v; //Latest voltage reading from ADC
omatthews 18:f5d26d3d532f 59 float R; //Latest resistance calculated from ADC current and voltage
omatthews 18:f5d26d3d532f 60 float R_ref; //Current referance for resistance
omatthews 18:f5d26d3d532f 61 float error; //R_ref - R
omatthews 18:f5d26d3d532f 62 float error_integrated; //Integrated error
omatthews 1:4435d407d827 63
omatthews 26:f6c98b05ee85 64 int i_port; //ADC port which corresponds to current measurements
omatthews 26:f6c98b05ee85 65 int v_port; //ADC port which corresponds to voltage measurements
omatthews 18:f5d26d3d532f 66 FastPWM * drive; //Pointer to the driver
omatthews 20:2d34a03ae57e 67 FastPWM * guard; //Pointer to the guard
omatthews 16:cd837b230b09 68
omatthews 7:59ece353eea2 69 //Heater correlations give temperature for a given resistance (assume linear relationship)
omatthews 25:09a315a59956 70 int log_count;
omatthews 0:4e33cc8171f4 71
omatthews 0:4e33cc8171f4 72 };
omatthews 0:4e33cc8171f4 73
omatthews 19:fccdd7127f94 74 #endif