Skip to content

Commit 0fb6f1f

Browse files
author
jenkie
committed
Bugfix BBS PAS without brake sensor
was always braking if no brake was configured
1 parent e758944 commit 0fb6f1f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Arduino_Pedelec_Controller/Arduino_Pedelec_Controller.ino

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,8 @@ if (loadcell.is_ready()) //new conversion result from load cell available
603603
#else
604604
brake_stat = digitalRead(brake_in);
605605
#endif
606+
#else
607+
brake_stat = true;
606608
#endif
607609
#ifdef SUPPORT_FIRST_AID_MENU
608610
if (first_aid_ignore_break)
@@ -745,6 +747,10 @@ if (loadcell.is_ready()) //new conversion result from load cell available
745747

746748

747749
//Power control-------------------------------------------------------------------------------------------------------------
750+
#ifdef SUPPORT_BBS
751+
if ((millis()-bbs_pausestart)<BBS_GEARCHANGEPAUSE) //activate brake for specified pause time to allow for gear change
752+
brake_stat=0;
753+
#endif
748754
power_throttle = throttle_stat / 1023.0 * curr_power_max; //power currently set by throttle
749755

750756
#if CONTROL_MODE == CONTROL_MODE_TORQUE //human power control mode
@@ -816,11 +822,6 @@ if (loadcell.is_ready()) //new conversion result from load cell available
816822
{factor_volt=factor_volt*0.9997+0.0003;}
817823

818824
//Throttle output-------------------------------------------------------------------------------------------------------
819-
#ifdef SUPPORT_BBS
820-
if (millis()-bbs_pausestart<BBS_GEARCHANGEPAUSE) //activate brake for specified pause time to allow for gear change
821-
brake_stat=0;
822-
#endif
823-
824825
#ifdef SUPPORT_MOTOR_GUESS
825826
throttle_write=map(pid_out*brake_stat*factor_volt,0,1023,motor_offset,motor_max) + spd/spd_idle*(motor_max-motor_offset);
826827
throttle_write=constrain(throttle_write,0,motor_max);

0 commit comments

Comments
 (0)