From 7b7db6750635c85d2ee9a013db01a9b3661f41ee Mon Sep 17 00:00:00 2001 From: Benjamin Vedder Date: Thu, 7 Aug 2014 19:52:07 +0200 Subject: [PATCH] Some flux integrator fixes and current gain adjustment --- mcconf/mcconf_outrunner1.h | 2 +- mcconf/mcconf_outrunner2.h | 2 +- mcconf/mcconf_rccar1.h | 2 +- mcconf/mcconf_sten.h | 2 +- mcpwm.c | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mcconf/mcconf_outrunner1.h b/mcconf/mcconf_outrunner1.h index 92d65b72..8f5c7bd9 100644 --- a/mcconf/mcconf_outrunner1.h +++ b/mcconf/mcconf_outrunner1.h @@ -52,7 +52,7 @@ #define MCPWM_PID_MIN_RPM 1200.0 // Minimum allowed RPM // Current control parameters -#define MCPWM_CURRENT_CONTROL_GAIN 0.0036 // Current controller error gain +#define MCPWM_CURRENT_CONTROL_GAIN 0.0046 // Current controller error gain #define MCPWM_CURRENT_CONTROL_MIN 1.0 // Minimum allowed current // Hall sensor diff --git a/mcconf/mcconf_outrunner2.h b/mcconf/mcconf_outrunner2.h index ba496ba8..fb9cff6e 100644 --- a/mcconf/mcconf_outrunner2.h +++ b/mcconf/mcconf_outrunner2.h @@ -51,7 +51,7 @@ #define MCPWM_PID_MIN_RPM 900.0 // Minimum allowed RPM // Current control parameters -#define MCPWM_CURRENT_CONTROL_GAIN 0.0036 // Current controller error gain +#define MCPWM_CURRENT_CONTROL_GAIN 0.0046 // Current controller error gain #define MCPWM_CURRENT_CONTROL_MIN 1.0 // Minimum allowed current #endif /* MCCONF_OUTRUNNER2_H_ */ diff --git a/mcconf/mcconf_rccar1.h b/mcconf/mcconf_rccar1.h index f256f095..cd0c0cc8 100644 --- a/mcconf/mcconf_rccar1.h +++ b/mcconf/mcconf_rccar1.h @@ -58,7 +58,7 @@ #define MCPWM_PID_MIN_RPM 950.0 // Minimum allowed RPM // Current control parameters -#define MCPWM_CURRENT_CONTROL_GAIN 0.0036 // Current controller error gain +#define MCPWM_CURRENT_CONTROL_GAIN 0.0046 // Current controller error gain #define MCPWM_CURRENT_CONTROL_MIN 1.0 // Minimum allowed current #endif /* MCCONF_RCCAR1_H_ */ diff --git a/mcconf/mcconf_sten.h b/mcconf/mcconf_sten.h index 2bd50c51..63a5d5b8 100644 --- a/mcconf/mcconf_sten.h +++ b/mcconf/mcconf_sten.h @@ -56,7 +56,7 @@ #define MCPWM_PID_MIN_RPM 1200.0 // Minimum allowed RPM // Current control parameters -#define MCPWM_CURRENT_CONTROL_GAIN 0.0036 // Current controller error gain +#define MCPWM_CURRENT_CONTROL_GAIN 0.0046 // Current controller error gain #define MCPWM_CURRENT_CONTROL_MIN 0.05 // Minimum allowed current #endif /* MCCONF_STEN_H_ */ diff --git a/mcpwm.c b/mcpwm.c index c9c9e803..e3f8915d 100644 --- a/mcpwm.c +++ b/mcpwm.c @@ -1434,10 +1434,10 @@ void mcpwm_adc_int_handler(void *p, uint32_t flags) { if (has_commutated) { limit = rpm_dep.cycle_int_limit_running * 0.0005; } else { - limit = rpm_dep.cycle_int_limit * 0.0005; + limit = rpm_dep.cycle_int_limit * 0.0002; } - if ((cycle_integrator >= MCPWM_CYCLE_INT_LIMIT_START * 0.0005 || pwm_cycles_sum > last_pwm_cycles_sum / 3.0 || !has_commutated) + if ((cycle_integrator >= (MCPWM_CYCLE_INT_LIMIT_START * 0.0005) || pwm_cycles_sum > last_pwm_cycles_sum / 3.0 || !has_commutated) && cycle_integrator >= limit) { commutate(); cycle_integrator = CYCLE_INT_START;