industry/foc/foc_ident: make the Ki resistance measurement parameter configurable
The hardcoded parameter may not be suitable for various types of motors
This commit is contained in:
parent
5862b9d15c
commit
8d61a10a74
@ -386,6 +386,10 @@ config EXAMPLES_FOC_IDENT_RES_CURRENT
|
|||||||
int "FOC motor ident resistance current (x1000)"
|
int "FOC motor ident resistance current (x1000)"
|
||||||
default 0
|
default 0
|
||||||
|
|
||||||
|
config EXAMPLES_FOC_IDENT_RES_KI
|
||||||
|
int "FOC motor ident resistance Ki (x1000)"
|
||||||
|
default 50
|
||||||
|
|
||||||
config EXAMPLES_FOC_IDENT_IND_VOLTAGE
|
config EXAMPLES_FOC_IDENT_IND_VOLTAGE
|
||||||
int "FOC motor ident inductance voltage (x1000)"
|
int "FOC motor ident inductance voltage (x1000)"
|
||||||
default 0
|
default 0
|
||||||
|
@ -88,6 +88,9 @@
|
|||||||
# if (CONFIG_EXAMPLES_FOC_IDENT_RES_CURRENT == 0)
|
# if (CONFIG_EXAMPLES_FOC_IDENT_RES_CURRENT == 0)
|
||||||
# error
|
# error
|
||||||
# endif
|
# endif
|
||||||
|
# if (CONFIG_EXAMPLES_FOC_IDENT_RES_KI == 0)
|
||||||
|
# error
|
||||||
|
# endif
|
||||||
# if (CONFIG_EXAMPLES_FOC_IDENT_IND_VOLTAGE == 0)
|
# if (CONFIG_EXAMPLES_FOC_IDENT_IND_VOLTAGE == 0)
|
||||||
# error
|
# error
|
||||||
# endif
|
# endif
|
||||||
|
@ -989,6 +989,8 @@ int foc_motor_init(FAR struct foc_motor_b16_s *motor,
|
|||||||
ident_cfg.per = motor->per;
|
ident_cfg.per = motor->per;
|
||||||
ident_cfg.res_current = ftob16(CONFIG_EXAMPLES_FOC_IDENT_RES_CURRENT /
|
ident_cfg.res_current = ftob16(CONFIG_EXAMPLES_FOC_IDENT_RES_CURRENT /
|
||||||
1000.0f);
|
1000.0f);
|
||||||
|
ident_cfg.res_ki = ftob16(CONFIG_EXAMPLES_FOC_IDENT_RES_KI /
|
||||||
|
1000.0f);
|
||||||
ident_cfg.ind_volt = ftob16(CONFIG_EXAMPLES_FOC_IDENT_IND_VOLTAGE /
|
ident_cfg.ind_volt = ftob16(CONFIG_EXAMPLES_FOC_IDENT_IND_VOLTAGE /
|
||||||
1000.0f);
|
1000.0f);
|
||||||
ident_cfg.res_steps = (CONFIG_EXAMPLES_FOC_NOTIFIER_FREQ *
|
ident_cfg.res_steps = (CONFIG_EXAMPLES_FOC_NOTIFIER_FREQ *
|
||||||
|
@ -972,6 +972,7 @@ int foc_motor_init(FAR struct foc_motor_f32_s *motor,
|
|||||||
|
|
||||||
ident_cfg.per = motor->per;
|
ident_cfg.per = motor->per;
|
||||||
ident_cfg.res_current = (CONFIG_EXAMPLES_FOC_IDENT_RES_CURRENT / 1000.0f);
|
ident_cfg.res_current = (CONFIG_EXAMPLES_FOC_IDENT_RES_CURRENT / 1000.0f);
|
||||||
|
ident_cfg.res_ki = (CONFIG_EXAMPLES_FOC_IDENT_RES_KI / 1000.0f);
|
||||||
ident_cfg.ind_volt = (CONFIG_EXAMPLES_FOC_IDENT_IND_VOLTAGE / 1000.0f);
|
ident_cfg.ind_volt = (CONFIG_EXAMPLES_FOC_IDENT_IND_VOLTAGE / 1000.0f);
|
||||||
ident_cfg.res_steps = (CONFIG_EXAMPLES_FOC_NOTIFIER_FREQ * \
|
ident_cfg.res_steps = (CONFIG_EXAMPLES_FOC_NOTIFIER_FREQ * \
|
||||||
CONFIG_EXAMPLES_FOC_IDENT_RES_SEC / 1000);
|
CONFIG_EXAMPLES_FOC_IDENT_RES_SEC / 1000);
|
||||||
|
@ -41,6 +41,7 @@ struct foc_routine_ident_cfg_b16_s
|
|||||||
{
|
{
|
||||||
b16_t per; /* Routine period in sec */
|
b16_t per; /* Routine period in sec */
|
||||||
b16_t res_current; /* Resistance measurement current */
|
b16_t res_current; /* Resistance measurement current */
|
||||||
|
b16_t res_ki; /* Resistance measurement Ki */
|
||||||
b16_t ind_volt; /* Inductance measurement current */
|
b16_t ind_volt; /* Inductance measurement current */
|
||||||
int res_steps; /* Resistance measurement steps */
|
int res_steps; /* Resistance measurement steps */
|
||||||
int ind_steps; /* Inductance measurement steps */
|
int ind_steps; /* Inductance measurement steps */
|
||||||
|
@ -83,6 +83,7 @@ struct foc_routine_ident_cfg_f32_s
|
|||||||
#endif
|
#endif
|
||||||
float per; /* Routine period in sec */
|
float per; /* Routine period in sec */
|
||||||
float res_current; /* Resistance measurement current */
|
float res_current; /* Resistance measurement current */
|
||||||
|
float res_ki; /* Resistance measurement Ki */
|
||||||
float ind_volt; /* Inductance measurement voltage */
|
float ind_volt; /* Inductance measurement voltage */
|
||||||
int res_steps; /* Resistance measurement steps */
|
int res_steps; /* Resistance measurement steps */
|
||||||
int ind_steps; /* Inductance measurement steps */
|
int ind_steps; /* Inductance measurement steps */
|
||||||
|
@ -39,7 +39,6 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#define IDENT_PI_KP (ftob16(0.0f))
|
#define IDENT_PI_KP (ftob16(0.0f))
|
||||||
#define IDENT_PI_KI (ftob16(0.05f))
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data Types
|
* Private Data Types
|
||||||
@ -169,7 +168,8 @@ int foc_ident_res_run_b16(FAR struct foc_ident_b16_s *ident,
|
|||||||
|
|
||||||
if (ident->cntr == 0)
|
if (ident->cntr == 0)
|
||||||
{
|
{
|
||||||
pi_controller_init_b16(&ident->pi, IDENT_PI_KP, IDENT_PI_KI);
|
DEBUGASSERT(ident->cfg.res_ki > 0);
|
||||||
|
pi_controller_init_b16(&ident->pi, IDENT_PI_KP, ident->cfg.res_ki);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PI saturation */
|
/* PI saturation */
|
||||||
@ -427,6 +427,12 @@ int foc_routine_ident_cfg_b16(FAR foc_routine_b16_t *r, FAR void *cfg)
|
|||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (i->cfg.res_ki <= 0)
|
||||||
|
{
|
||||||
|
ret = -EINVAL;
|
||||||
|
goto errout;
|
||||||
|
}
|
||||||
|
|
||||||
if (i->cfg.res_current <= 0 || i->cfg.ind_volt <= 0)
|
if (i->cfg.res_current <= 0 || i->cfg.ind_volt <= 0)
|
||||||
{
|
{
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
|
@ -39,7 +39,6 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#define IDENT_PI_KP (0.0f)
|
#define IDENT_PI_KP (0.0f)
|
||||||
#define IDENT_PI_KI (0.05f)
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data Types
|
* Private Data Types
|
||||||
@ -194,7 +193,8 @@ int foc_ident_res_run_f32(FAR struct foc_ident_f32_s *ident,
|
|||||||
|
|
||||||
if (ident->cntr == 0)
|
if (ident->cntr == 0)
|
||||||
{
|
{
|
||||||
pi_controller_init(&ident->pi, IDENT_PI_KP, IDENT_PI_KI);
|
DEBUGASSERT(ident->cfg.res_ki > 0.0f);
|
||||||
|
pi_controller_init(&ident->pi, IDENT_PI_KP, ident->cfg.res_ki);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PI saturation */
|
/* PI saturation */
|
||||||
@ -576,6 +576,12 @@ int foc_routine_ident_cfg_f32(FAR foc_routine_f32_t *r, FAR void *cfg)
|
|||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (i->cfg.res_ki <= 0.0f)
|
||||||
|
{
|
||||||
|
ret = -EINVAL;
|
||||||
|
goto errout;
|
||||||
|
}
|
||||||
|
|
||||||
if (i->cfg.res_current <= 0.0f || i->cfg.ind_volt <= 0.0f
|
if (i->cfg.res_current <= 0.0f || i->cfg.ind_volt <= 0.0f
|
||||||
#ifdef CONFIG_INDUSTRY_FOC_IDENT_FLUX
|
#ifdef CONFIG_INDUSTRY_FOC_IDENT_FLUX
|
||||||
|| i->cfg.flux_curr <= 0.0f
|
|| i->cfg.flux_curr <= 0.0f
|
||||||
|
Loading…
Reference in New Issue
Block a user