Sets ticks directly for heater test
Diff: Heater.cpp
- Revision:
- 2:7f15386fcc90
- Parent:
- 1:4435d407d827
- Child:
- 3:313711a66929
- Child:
- 7:59ece353eea2
diff -r 4435d407d827 -r 7f15386fcc90 Heater.cpp --- a/Heater.cpp Wed Jul 17 13:00:41 2019 +0000 +++ b/Heater.cpp Wed Jul 17 13:55:33 2019 +0000 @@ -21,7 +21,7 @@ :R_set(R_set),i_port(i_port),v_port(v_port),drive(drive){} -void Heater::read_R() +void Heater::read() { //Reads R and then resets the drive back to its previous value int i = 0; @@ -34,18 +34,23 @@ wait_us(1); i++; } + + drive = drive_prev; + adc.read_channels(); - drive = drive_prev; //pc.printf("conversion took %d us\n", i ); i=0; curr = adc.read_channel_result(i_port)/scale_factors[i_port]; v = adc.read_channel_result(v_port)/scale_factors[v_port]; - if (curr != 0) R = v/curr; + if (curr > 0) R = float(v)/float(curr); } + + + void Heater::hold(int hold_time) { int end_time = timer.read_ms() + hold_time; @@ -55,7 +60,7 @@ { drive = 1; wait_us(MEAS_DELAY); - read_R(); + read(); R_avg = ((N_ROLL_AVG-1)*R_avg + R)/N_ROLL_AVG; if (R_avg > R_set) { @@ -69,6 +74,9 @@ void Heater::Set_R_set(float R) {R_set = R;} +int Heater::Get_i() {return curr;} +int Heater::Get_v() {return v;} + float Heater::Get_R() {return R;} void Heater::turn_on () {drive = 1;}