Skip to content

Commit 217b6f5

Browse files
author
jenkie
committed
Add configurable temperature cutoff of motor power
1 parent e9ecf65 commit 217b6f5

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Arduino_Pedelec_Controller/Arduino_Pedelec_Controller.ino

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,12 @@ if (loadcell.is_ready()) //new conversion result from load cell available
866866
else
867867
{factor_volt=factor_volt*0.9997+0.0003;}
868868

869+
//Temperature cutoff
870+
#if defined(SUPPORT_THERMISTOR) && defined(SUPPORT_THERMISTOR_CUTOFF)
871+
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
872+
factor_volt=factor_volt*factor_temperature;
873+
#endif
874+
869875
//Throttle output-------------------------------------------------------------------------------------------------------
870876
#ifdef SUPPORT_MOTOR_GUESS
871877
throttle_write=map(pid_out*brake_stat*factor_volt,0,1023,motor_offset,motor_max) + spd/spd_idle*(motor_max-motor_offset);

Arduino_Pedelec_Controller/config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ const float thermistor_t0=0.00335401643; // 1/T0 of thermistor in 1/K
183183
const float thermistor_b=0.00025316455; // 1/beta of thermistor in 1/K
184184
const float thermistor_r=10; // r of thermistor in kOhm
185185

186+
//#define SUPPORT_THERMISTOR_CUTOFF //uncomment to use thermistor for temperature cutoff of motor power
187+
const int temperature_cutoff_start=100; //start of temperature cutoff (100% power)
188+
const int temperature_cutoff_stop=120; //stop of temperature cutoff in °C (0% power)
189+
186190
//#define SUPPORT_HX711 //uncomment this if you want to use a load cell with hx711 amplifier
187191
const byte hx711_data=20; //data pin of hx711 sensor
188192
const byte hx711_sck=21; //clock pin of hx711 sensor

0 commit comments

Comments
 (0)