#if CONTROL_MODE == CONTROL_MODE_TORQUE //human power control mode
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU_V1) || defined(SUPPORT_SEMPU)
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
#ifdef SUPPORT_TORQUE_THROTTLE //we want to trigger throttle just by pedal torque
if (abs(torque_instant)>torque_throttle_min) //we are above the threshold to trigger throttle
{
double power_torque_throttle = abs(torque_instant/torque_throttle_full*poti_stat/1023*curr_power_max); //translate torque_throttle_full to maximum power
power_throttle = max(power_throttle,power_torque_throttle); //decide if thumb throttle or torque throttle are higher
power_throttle = constrain(power_throttle,0,curr_power_max); //constrain throttle value to maximum power
}
#endif
....
power_poti = min(power_poti,thermal_limit+(curr_power_max-thermal_limit)*constrain(spd/thermal_safe_speed,0,1)); //thermal limiting
if ((power_throttle) > (power_poti)) //IF power set by throttle IS GREATER THAN power set by poti (throttle override)
{
myPID.SetTunings(pid_p_throttle,pid_i_throttle,0); //THEN throttle mode: throttle sets power with "agressive" p and i parameters power_set=throttle_stat/1023.0*power_max;
power_set = power_throttle;
}
else //ELSE poti mode: poti sets power with "soft" p and i parameters
{
myPID.SetTunings(pid_p,pid_i,0);
power_set = power_poti;
}