Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: LEX_Threaded_Programming
Revision 4:29ffcc7b410e, committed 2019-07-18
- Comitter:
- omatthews
- Date:
- Thu Jul 18 12:17:42 2019 +0000
- Parent:
- 3:313711a66929
- Child:
- 5:21442d9d19c5
- Child:
- 6:71d9c10fca4a
- Commit message:
- Final design before PWM
Changed in this revision
| Heater.cpp | Show annotated file Show diff for this revision Revisions of this file |
| Heater.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Heater.cpp Wed Jul 17 20:46:20 2019 +0000
+++ b/Heater.cpp Thu Jul 18 12:17:42 2019 +0000
@@ -27,24 +27,22 @@
void Heater::read()
{
//Reads R and then resets the drive back to its previous value
+
int i = 0;
int drive_prev = drive; //Store previous value of drive
drive = 1;
- wait_us(MEAS_DELAY); //Wait for ADC to settle
+ wait_us(50); //Wait for ADC to settle
adc.start_conversion(ALL_CH);
while(adc_busy == 1)
{
wait_us(1);
i++;
}
+ drive = drive_prev;
adc.read_channels();
-
- drive = drive_prev;
-
//pc.printf("conversion took %d us\n", i );
- i=0;
-
+ //i=0;
curr = adc.read_channel_result(i_port);
v = adc.read_channel_result(v_port);
@@ -94,7 +92,10 @@
}
}
-
+void Heater::ramp_T(int ramp_time, float T_final, float T_start)
+{
+ ramp_R(ramp_time, T_to_R(T_final), T_to_R(T_start));
+}
void Heater::Set_R_ref(float R) {R_ref = R;}
void Heater::Set_T_ref(float T_ref) {R_ref = T_to_R(T_ref);}
--- a/Heater.h Wed Jul 17 20:46:20 2019 +0000
+++ b/Heater.h Thu Jul 18 12:17:42 2019 +0000
@@ -10,8 +10,8 @@
#include "mbed.h"
#include "ADS8568_ADC.h"
-#define MEAS_DELAY 10 // measurement delay for ADC
-#define N_ROLL_AVG 3 // rolling average for R values
+#define MEAS_DELAY 50 // measurement delay for ADC
+#define N_ROLL_AVG 2 // rolling average for R values
#define ALL_CH 15 //value of convst bus to read all chanels simultaneosly
class Heater
@@ -30,7 +30,8 @@
void read();
void hold(int hold_time);
- void ramp_R(int ramp_time, float R_final, float R_start = 1.0);
+ void ramp_R(int ramp_time, float R_final, float R_start);
+ void ramp_T(int ramp_time, float T_final, float T_start);
//Conversions between temperature and resistance
float R_to_T(float R);