Skip to content

Commit 1816e1e

Browse files
author
jenkie
committed
Reset PID integral on brake config-option
Use RESET_PID_ON_BRAKE to reset the pid regulator if you are braking or stop pedaling. If this config option is not active, the pid regulator will slowly ramp down instead, which gives you a faster kick-in of the motor if you release the brake or start pedaling again.
1 parent d46d569 commit 1816e1e

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Arduino_Pedelec_Controller/Arduino_Pedelec_Controller.ino

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,13 @@ void loop()
751751
if (power_set>curr_power_max*factor_speed)
752752
{power_set=curr_power_max*factor_speed;} //Maximum allowed power including Speed-Cutoff
753753
if ((((poti_stat<=throttle_stat)||(pedaling==false))&&(throttle_stat==0))||(brake_stat==0)) //integral part of PID regulator is slowly shrinked to 0 when you stop pedaling or brake
754+
{
755+
#ifdef RESET_PID_ON_BRAKE
756+
myPID.ResetIntegral();
757+
#else
754758
myPID.ShrinkIntegral();
759+
#endif
760+
}
755761
else
756762
{
757763
pid_set=power_set;

Arduino_Pedelec_Controller/config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ const int fixed_throttle_in_watts = 250; //number of watts to set as thr
129129
// #define SUPPORT_HRMI //uncomment if polar heart-rate monitor interface connected to i2c port
130130
#define SUPPORT_BRAKE //uncomment if brake switch connected
131131
// #define INVERT_BRAKE //uncomment if brake signal is low when not braking
132+
// #define RESET_PID_ON_BRAKE //uncomment to reset the pid regulator if you are braking or stop pedaling. If this config option is not active, the pid regulator will slowly ramp down instead, which gives you a faster kick-in of the motor if you release the brake or start pedaling again
132133
#define DETECT_BROKEN_SPEEDSENSOR //detect broken speed sensor and disable motor (useful for legalisation)
133134

134135

0 commit comments

Comments
 (0)