diff --git a/Arduino_Pedelec_Controller/Arduino_Pedelec_Controller.ino b/Arduino_Pedelec_Controller/Arduino_Pedelec_Controller.ino index c954c17..bf20190 100644 --- a/Arduino_Pedelec_Controller/Arduino_Pedelec_Controller.ino +++ b/Arduino_Pedelec_Controller/Arduino_Pedelec_Controller.ino @@ -866,6 +866,12 @@ if (loadcell.is_ready()) //new conversion result from load cell available else {factor_volt=factor_volt*0.9997+0.0003;} +//Temperature cutoff +#if defined(SUPPORT_THERMISTOR) && defined(SUPPORT_THERMISTOR_CUTOFF) + float factor_temperature=constrain(1-(temperature_thermistor-temperature_cutoff_start)/(temperature_cutoff_stop-temperature_cutoff_start),0,1); //linear decrease of maximum power for temperatures higher than temperature_cutoff_start + factor_volt=factor_volt*factor_temperature; +#endif + //Throttle output------------------------------------------------------------------------------------------------------- #ifdef SUPPORT_MOTOR_GUESS throttle_write=map(pid_out*brake_stat*factor_volt,0,1023,motor_offset,motor_max) + spd/spd_idle*(motor_max-motor_offset); diff --git a/Arduino_Pedelec_Controller/config.h b/Arduino_Pedelec_Controller/config.h index 014b635..e742fd9 100644 --- a/Arduino_Pedelec_Controller/config.h +++ b/Arduino_Pedelec_Controller/config.h @@ -183,6 +183,10 @@ const float thermistor_t0=0.00335401643; // 1/T0 of thermistor in 1/K const float thermistor_b=0.00025316455; // 1/beta of thermistor in 1/K const float thermistor_r=10; // r of thermistor in kOhm +//#define SUPPORT_THERMISTOR_CUTOFF //uncomment to use thermistor for temperature cutoff of motor power +const int temperature_cutoff_start=100; //start of temperature cutoff (100% power) +const int temperature_cutoff_stop=120; //stop of temperature cutoff in °C (0% power) + //#define SUPPORT_HX711 //uncomment this if you want to use a load cell with hx711 amplifier const byte hx711_data=20; //data pin of hx711 sensor const byte hx711_sck=21; //clock pin of hx711 sensor