You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enable SUPPORT_TORQUE_THROTTLE to use pedal force as starting aid
(similar to thumb throttle). The motor will be powered if the torque is
more than torque_throttle_min and will be at full power at
torque_throttle_full.
double torque=0.0; //cyclist's torque in Nm (averaged over one pedal revolution)
264
+
double torque_instant=0.0; //cyclist's torque in Nm (live)
264
265
double power_human=0.0; //cyclist's power
265
266
double wh_human=0;
266
267
#ifdef SUPPORT_XCELL_RT
@@ -643,6 +644,7 @@ if (loadcell.is_ready()) //new conversion result from load cell available
643
644
power=current*voltage;
644
645
645
646
#ifdef SUPPORT_XCELL_RT
647
+
torque_instant=(analogRead(option_pin)-torque_zero); //multiplication constant for THUN X-CELL RT is approx. 1Nm/count
646
648
if (readtorque==true)
647
649
{
648
650
torque=0.0;
@@ -756,6 +758,14 @@ if (loadcell.is_ready()) //new conversion result from load cell available
756
758
#if CONTROL_MODE == CONTROL_MODE_TORQUE //human power control mode
757
759
#ifdef SUPPORT_XCELL_RT
758
760
power_poti = poti_stat/102300.0* curr_power_poti_max*power_human*(1+spd/20.0); //power_poti_max is in this control mode interpreted as percentage. Example: power_poti_max=200 means; motor power = 200% of human power
761
+
#ifdef SUPPORT_TORQUE_THROTTLE //we want to trigger throttle just by pedal torque
762
+
if (abs(torque_instant)>torque_throttle_min) //we are above the threshold to trigger throttle
763
+
{
764
+
double power_torque_throttle = abs(torque_instant/torque_throttle_full*poti_stat/1023*curr_power_max); //translate torque_throttle_full to maximum power
765
+
power_throttle = max(power_throttle,power_torque_throttle); //decide if thumb throttle or torque throttle are higher
766
+
power_throttle = constrain(power_throttle,0,curr_power_max); //constrain throttle value to maximum power
0 commit comments