Heater for threaded program

Dependents:   LEX_Threaded_Programming

Committer:
omatthews
Date:
Tue Jul 23 10:06:17 2019 +0000
Revision:
13:8629d78fd93b
Parent:
11:785a0329f802
Working Bang Bang with PWM (needed to reduce period)

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 10:0e16d8430d66 13 #define MEAS_DELAY 40 // measurement delay for ADC
omatthews 11:785a0329f802 14 #define N_ROLL_AVG 5 // 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 7:59ece353eea2 19 //This class provides the interface through which each heater can be controlled
omatthews 0:4e33cc8171f4 20 public:
omatthews 0:4e33cc8171f4 21 /** Constructor
omatthews 7:59ece353eea2 22 * @param i_port, the port for the current in the ADC
omatthews 7:59ece353eea2 23 * @param v_port, the port for the voltage in the ADC
omatthews 7:59ece353eea2 24 * @param drive, the motor drive
omatthews 7:59ece353eea2 25 * @param R_ref, the target value for R
omatthews 0:4e33cc8171f4 26 */
omatthews 13:8629d78fd93b 27 Heater(int i_port, int v_port, PwmOut 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 7:59ece353eea2 33 void ramp_R(int ramp_time, float R_final, float R_start);
omatthews 7:59ece353eea2 34 void ramp_T(int ramp_time, float T_final, float T_start);
omatthews 11:785a0329f802 35 void output();
omatthews 7:59ece353eea2 36
omatthews 7:59ece353eea2 37 //Conversions between temperature and resistance
omatthews 7:59ece353eea2 38 float R_to_T(float R);
omatthews 7:59ece353eea2 39 float T_to_R(float T);
omatthews 1:4435d407d827 40
omatthews 1:4435d407d827 41
omatthews 2:7f15386fcc90 42
omatthews 2:7f15386fcc90 43 //Getters and setters
omatthews 7:59ece353eea2 44 void Set_T_ref(float T);
omatthews 7:59ece353eea2 45 void Set_R_ref(float R);
omatthews 2:7f15386fcc90 46 int Get_i();
omatthews 2:7f15386fcc90 47 int Get_v();
omatthews 0:4e33cc8171f4 48 float Get_R();
omatthews 7:59ece353eea2 49 float Get_T();
omatthews 7:59ece353eea2 50
omatthews 0:4e33cc8171f4 51
omatthews 1:4435d407d827 52 void turn_on();
omatthews 1:4435d407d827 53 void turn_off();
omatthews 0:4e33cc8171f4 54
omatthews 0:4e33cc8171f4 55
omatthews 0:4e33cc8171f4 56
omatthews 0:4e33cc8171f4 57 protected:
omatthews 0:4e33cc8171f4 58
omatthews 0:4e33cc8171f4 59
omatthews 2:7f15386fcc90 60 int curr;
omatthews 2:7f15386fcc90 61 int v;
omatthews 0:4e33cc8171f4 62 float R;
omatthews 7:59ece353eea2 63 float R_ref;
omatthews 1:4435d407d827 64
omatthews 0:4e33cc8171f4 65 int i_port;
omatthews 0:4e33cc8171f4 66 int v_port;
omatthews 13:8629d78fd93b 67 PwmOut drive;
omatthews 7:59ece353eea2 68
omatthews 7:59ece353eea2 69 //Heater correlations give temperature for a given resistance (assume linear relationship)
omatthews 7:59ece353eea2 70 float corr_grad;
omatthews 7:59ece353eea2 71 float corr_int;
omatthews 0:4e33cc8171f4 72
omatthews 0:4e33cc8171f4 73 };
omatthews 0:4e33cc8171f4 74
omatthews 8:5da71ae16115 75 #endif
omatthews 8:5da71ae16115 76