Heater for threaded program

Dependents:   LEX_Threaded_Programming

Committer:
omatthews
Date:
Wed Jul 17 20:46:20 2019 +0000
Revision:
3:313711a66929
Parent:
2:7f15386fcc90
Child:
4:29ffcc7b410e
Ramp added

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 0:4e33cc8171f4 12
omatthews 3:313711a66929 13 #define MEAS_DELAY 10 // measurement delay for ADC
omatthews 3:313711a66929 14 #define N_ROLL_AVG 3 // rolling average for R values
omatthews 1:4435d407d827 15 #define ALL_CH 15 //value of convst bus to read all chanels simultaneosly
omatthews 0:4e33cc8171f4 16
omatthews 0:4e33cc8171f4 17 class Heater
omatthews 0:4e33cc8171f4 18 {
omatthews 3:313711a66929 19 //This class provides the interface through which each heater can be controlled
omatthews 0:4e33cc8171f4 20 public:
omatthews 0:4e33cc8171f4 21 /** Constructor
omatthews 3:313711a66929 22 * @param i_port, the port for the current in the ADC
omatthews 3:313711a66929 23 * @param v_port, the port for the voltage in the ADC
omatthews 3:313711a66929 24 * @param drive, the motor drive
omatthews 3:313711a66929 25 * @param R_ref, the target value for R
omatthews 0:4e33cc8171f4 26 */
omatthews 3:313711a66929 27 Heater(int i_port, int v_port, DigitalOut drive, float corr_grad, float corr_int, float R_ref = 1);
omatthews 0:4e33cc8171f4 28
omatthews 0:4e33cc8171f4 29 //Public member functions
omatthews 0:4e33cc8171f4 30
omatthews 2:7f15386fcc90 31 void read();
omatthews 0:4e33cc8171f4 32 void hold(int hold_time);
omatthews 3:313711a66929 33 void ramp_R(int ramp_time, float R_final, float R_start = 1.0);
omatthews 3:313711a66929 34
omatthews 3:313711a66929 35 //Conversions between temperature and resistance
omatthews 3:313711a66929 36 float R_to_T(float R);
omatthews 3:313711a66929 37 float T_to_R(float T);
omatthews 1:4435d407d827 38
omatthews 1:4435d407d827 39
omatthews 2:7f15386fcc90 40
omatthews 2:7f15386fcc90 41 //Getters and setters
omatthews 3:313711a66929 42 void Set_T_ref(float T);
omatthews 3:313711a66929 43 void Set_R_ref(float R);
omatthews 2:7f15386fcc90 44 int Get_i();
omatthews 2:7f15386fcc90 45 int Get_v();
omatthews 0:4e33cc8171f4 46 float Get_R();
omatthews 3:313711a66929 47 float Get_T();
omatthews 3:313711a66929 48
omatthews 0:4e33cc8171f4 49
omatthews 1:4435d407d827 50 void turn_on();
omatthews 1:4435d407d827 51 void turn_off();
omatthews 0:4e33cc8171f4 52
omatthews 0:4e33cc8171f4 53
omatthews 0:4e33cc8171f4 54
omatthews 0:4e33cc8171f4 55 protected:
omatthews 0:4e33cc8171f4 56
omatthews 0:4e33cc8171f4 57
omatthews 2:7f15386fcc90 58 int curr;
omatthews 2:7f15386fcc90 59 int v;
omatthews 0:4e33cc8171f4 60 float R;
omatthews 3:313711a66929 61 float R_ref;
omatthews 1:4435d407d827 62
omatthews 0:4e33cc8171f4 63 int i_port;
omatthews 0:4e33cc8171f4 64 int v_port;
omatthews 0:4e33cc8171f4 65 DigitalOut drive;
omatthews 3:313711a66929 66
omatthews 3:313711a66929 67 //Heater correlations give temperature for a given resistance (assume linear relationship)
omatthews 3:313711a66929 68 float corr_grad;
omatthews 3:313711a66929 69 float corr_int;
omatthews 0:4e33cc8171f4 70
omatthews 0:4e33cc8171f4 71 };
omatthews 0:4e33cc8171f4 72
omatthews 0:4e33cc8171f4 73 #endif
omatthews 0:4e33cc8171f4 74