Heater files
Dependents: LEX-Demo-Firmware-Logging LEX-Demo-Firmware-Logging
Diff: Heater.cpp
- Revision:
- 16:cd837b230b09
- Parent:
- 15:e7838491c104
- Child:
- 17:0bfed0e96927
diff -r e7838491c104 -r cd837b230b09 Heater.cpp --- a/Heater.cpp Wed Jul 24 09:47:45 2019 +0000 +++ b/Heater.cpp Wed Jul 24 14:29:44 2019 +0000 @@ -19,7 +19,7 @@ -Heater::Heater(int i_port, int v_port, PwmOut drive, float corr_grad, float corr_int, float R_ref) +Heater::Heater(int i_port, int v_port, PwmOut * drive, float corr_grad, float corr_int, float R_ref) :R_ref(R_ref),i_port(i_port),v_port(v_port),drive(drive),corr_grad(corr_grad),corr_int(corr_int) {} float Heater::R_to_T(float R) {return R*corr_grad + corr_int;} @@ -27,7 +27,7 @@ void Heater::output() { - pc.printf("%d,%f,%f,%f,%f\n",timer.read_ms(),R_ref,R,R_avg,drive.read()); + pc.printf("%d,%f,%f,%f,%f\n",timer.read_ms(),R_ref,R,R_avg,drive->read()); } void Heater::read() @@ -35,8 +35,8 @@ //Reads R and then resets the drive back to its previous value int i = 0; - float drive_prev = drive.read(); //Store previous value of drive - drive = 1; + float drive_prev = drive->read(); //Store previous value of drive + *drive = 1; wait_us(MEAS_DELAY); //Wait for ADC to settle adc.start_conversion(ALL_CH); while(adc_busy == 1) @@ -44,7 +44,7 @@ wait_us(1); i++; } - drive.write(drive_prev); + drive->write(drive_prev); adc.read_channels(); @@ -88,7 +88,7 @@ { read(); - drive.write(Kd * error + Ki * error_integrated); + drive->write(Kd * error + Ki * error_integrated); wait_ms(WAIT_DELAY); //Minimum duty cycle of 1% //pc.printf("%f,%f,%f\n",error,error_integrated,drive.read()); @@ -119,7 +119,8 @@ } 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);} -void Heater::Set_D(float D) {drive.write(D);} + +void Heater::Set_D(float D) {drive->write(D);} int Heater::Get_i() {return curr;} int Heater::Get_v() {return v;} @@ -127,6 +128,6 @@ float Heater::Get_R() {return R;} float Heater::Get_T() {return R_to_T(R);} -void Heater::turn_on () {drive = 1;} +void Heater::turn_on () {*drive = 1;} -void Heater::turn_off () {drive = 0;} +void Heater::turn_off () {*drive = 0;}