Heater for threaded program

Dependents:   LEX_Threaded_Programming

Committer:
omatthews
Date:
Tue Aug 27 09:22:36 2019 +0000
Revision:
27:bb97231d1be9
Parent:
26:f6c98b05ee85
For Paul

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