Skip to content

Commit

Permalink
Add configurable temperature cutoff of motor power
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkie committed Jun 30, 2018
1 parent e9ecf65 commit 217b6f5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Arduino_Pedelec_Controller/Arduino_Pedelec_Controller.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions Arduino_Pedelec_Controller/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 217b6f5

Please sign in to comment.