I tried to improve this, I went did some test rides but I couldn't find anything wrong... like noises. Would be great if you could test this changes - on master branch now:stancecoke wrote: ↑Mar 05, 2018 3:31 amThe motor was noisy and drew much current without producing torque after a longer regen time.

Code: Select all

```
// read here the phase B current: FOC Id current
ui8_adc_id_current = UI8_ADC_MOTOR_PHASE_B_CURRENT;
// first, verify if motor current is positive or negative (motor or regen mode), if regen mode, we need to invert the logic for angle correction
// second, adjust ui8_angle_correction so the ui8_adc_id_current is zero (FOC principle)
if (ui8_adc_motor_current > ui8_adc_motor_current_offset)
{
if (ui8_adc_id_current > ADC_PHASE_B_CURRENT_ZERO_AMPS_FOC_MAX) { ui8_angle_correction++; }
else if (ui8_adc_id_current < ADC_PHASE_B_CURRENT_ZERO_AMPS_FOC_MIN) { ui8_angle_correction--; }
}
else if (ui8_adc_motor_current < ui8_adc_motor_current_offset)
{
if (ui8_adc_id_current > ADC_PHASE_B_CURRENT_ZERO_AMPS_FOC_MAX) { ui8_angle_correction--; }
else if (ui8_adc_id_current < ADC_PHASE_B_CURRENT_ZERO_AMPS_FOC_MIN) { ui8_angle_correction++; }
}
```