casainho wrote: ↑May 02, 2018 8:41 am

I am pretty sure this is due to the filtering on the added Stancecoke code

The PAS timeout has nothing to do with the filtering. The candence is immediately set to zero, if the PAS counter is bigger than PAS_ABSOLUTE_MIN_CADENCE_PWM_CYCLE_TICKS.

Code: Select all

```
if (ui16_pas1_counter > ((uint16_t) PAS_ABSOLUTE_MIN_CADENCE_PWM_CYCLE_TICKS))
{
ui16_pas1_pwm_cycles_ticks = (uint16_t) PAS_ABSOLUTE_MIN_CADENCE_PWM_CYCLE_TICKS;
ui16_pas1_counter = 0;
ui16_pas1_on_time_counter = 0;
ui16_pas1_off_time_counter = 0;
ui8_pas1_direction = 1;
PAS_act=3;
#if (EBIKE_THROTTLE_TYPE == EBIKE_THROTTLE_TYPE_TORQUE_SENSOR)
ui8_torque_sensor_throttle_processed_value = 0;
#endif
}
```

Code: Select all

```
if (ui16_pas1_pwm_cycles_ticks >= ((uint16_t) PAS_ABSOLUTE_MIN_CADENCE_PWM_CYCLE_TICKS)) { ui8_pas1_cadence_rpm = 0; }
else
{
f_temp = ((float) ui16_pas1_pwm_cycles_ticks) * ((float) PAS_NUMBER_MAGNETS) * 0.000064;
// avoid division by 0
if (f_temp != 0) { ui8_pas1_cadence_rpm = (uint8_t) (60.0 / f_temp); }
else { ui8_pas1_cadence_rpm = 60; }
if (ui8_pas1_cadence_rpm > ((uint8_t) PAS_MAX_CADENCE_RPM))
{
ui8_pas1_cadence_rpm = ((uint8_t) PAS_MAX_CADENCE_RPM);
}
}
```

If the cadence is zero, the current target is zero also.

Code: Select all

```
ui8_temp = (uint8_t) (map ((uint32_t) ui8_pas1_cadence_rpm,
(uint32_t) 0,
(uint32_t) PAS_MAX_CADENCE_RPM,
(uint32_t) 0,
(uint32_t) 255));
#if !defined(EBIKE_THROTTLE_TYPE_THROTTLE_PAS_ASSIST_LEVEL_PAS_ONLY)
ui8_temp = ui8_max (ui8_throttle_value_filtered, ui8_temp); // use the max value from throttle or pas cadence
#endif
f_temp = (float) (((float) ui8_temp) * f_get_assist_level ());
#if !defined(EBIKE_THROTTLE_TYPE_THROTTLE_PAS_ASSIST_LEVEL_PAS_ONLY)
ui8_throttle_pas_target_value = (uint8_t) f_temp;
#else
ui8_temp = ui8_max (ui8_throttle_value_filtered, (uint8_t) f_temp); // use the max value from throttle or (pas cadence * assist level)
#endif
ui8_target_current = (uint16_t) (map ((uint32_t) ui8_temp,
(uint32_t) 0, // min input value
(uint32_t) 255, // max input value
(uint32_t) 0, // min output battery current value
(uint32_t) ui8_battery_controller_max_current)); // max output battery current value
```

The delay for power cut off after stop pedaling is influenced by the parameters:

- PAS_ABSOLUTE_MIN_CADENCE_PWM_CYCLE_TICKS

- PWM_DUTY_CYCLE_RAMP_DOWN_INVERSE_STEP

I wonder that there's no PI-controller for the battery-current in the recent code any longer?!

regards

stancecoke