diff --git a/src/main.c b/src/main.c index 5cfdb7c..0b764e3 100644 --- a/src/main.c +++ b/src/main.c @@ -849,13 +849,13 @@ static void add_surge(data *d) { if (d->surge_enable) { float surge_now = 0; - if (d->motor.duty_smooth > d->float_conf.surge_duty_start + 0.04) { + if (d->motor.duty_cycle > d->float_conf.surge_duty_start + 0.04) { surge_now = d->surge_angle3; beep_alert(d, 3, 1); - } else if (d->motor.duty_smooth > d->float_conf.surge_duty_start + 0.02) { + } else if (d->motor.duty_cycle > d->float_conf.surge_duty_start + 0.02) { surge_now = d->surge_angle2; beep_alert(d, 2, 1); - } else if (d->motor.duty_smooth > d->float_conf.surge_duty_start) { + } else if (d->motor.duty_cycle > d->float_conf.surge_duty_start) { surge_now = d->surge_angle; beep_alert(d, 1, 1); } diff --git a/src/motor_data.c b/src/motor_data.c index 41bdc44..4f9f223 100644 --- a/src/motor_data.c +++ b/src/motor_data.c @@ -24,8 +24,6 @@ #include void motor_data_reset(MotorData *m) { - m->duty_smooth = 0; - m->acceleration = 0; m->accel_idx = 0; for (int i = 0; i < 40; i++) { @@ -52,8 +50,7 @@ void motor_data_update(MotorData *m) { m->current = VESC_IF->mc_get_tot_current_directional_filtered(); m->braking = m->abs_erpm > 250 && sign(m->current) != m->erpm_sign; - m->duty_cycle = fabsf(VESC_IF->mc_get_duty_cycle_now()); - m->duty_smooth = m->duty_smooth * 0.9f + m->duty_cycle * 0.1f; + m->duty_cycle = m->duty_cycle * 0.9f + fabsf(VESC_IF->mc_get_duty_cycle_now()) * 0.1f; float current_acceleration = m->erpm - m->last_erpm; m->last_erpm = m->erpm; diff --git a/src/motor_data.h b/src/motor_data.h index 7901bd2..4fa1f0a 100644 --- a/src/motor_data.h +++ b/src/motor_data.h @@ -34,7 +34,6 @@ typedef struct { bool braking; float duty_cycle; - float duty_smooth; // an average calculated over last ACCEL_ARRAY_SIZE values float acceleration;