examples/foc: add controller IDLE mode
This commit is contained in:
parent
5eebfbb441
commit
cc189ef170
@ -531,6 +531,7 @@ static int foc_motor_setpoint(FAR struct foc_motor_f32_s *motor, uint32_t sp)
|
||||
#ifdef CONFIG_EXAMPLES_FOC_HAVE_IDENT
|
||||
case FOC_MMODE_IDENT_ONLY:
|
||||
#endif
|
||||
case FOC_MMODE_IDLE:
|
||||
{
|
||||
/* Do nothing */
|
||||
|
||||
@ -1005,6 +1006,11 @@ int foc_motor_init(FAR struct foc_motor_f32_s *motor,
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (motor->envp->cfg->mmode == FOC_MMODE_IDLE)
|
||||
{
|
||||
motor->ctrl_state = FOC_CTRL_STATE_IDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
motor->ctrl_state = FOC_CTRL_STATE_INIT;
|
||||
}
|
||||
|
@ -113,6 +113,7 @@ static void foc_help(void)
|
||||
#ifdef CONFIG_EXAMPLES_FOC_HAVE_IDENT
|
||||
PRINTF(" 5 - ident only\n");
|
||||
#endif
|
||||
PRINTF(" 6 - IDLE state\n");
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_FOC_HAVE_TORQ
|
||||
PRINTF(" [-r] torque [x1000]\n");
|
||||
@ -343,23 +344,23 @@ int validate_args(FAR struct args_s *args)
|
||||
|
||||
/* Example control mode */
|
||||
|
||||
if (
|
||||
if (args->cfg.mmode != FOC_MMODE_IDLE &&
|
||||
#ifdef CONFIG_EXAMPLES_FOC_HAVE_TORQ
|
||||
args->cfg.mmode != FOC_MMODE_TORQ &&
|
||||
args->cfg.mmode != FOC_MMODE_TORQ &&
|
||||
#endif
|
||||
#ifdef CONFIG_EXAMPLES_FOC_HAVE_VEL
|
||||
args->cfg.mmode != FOC_MMODE_VEL &&
|
||||
args->cfg.mmode != FOC_MMODE_VEL &&
|
||||
#endif
|
||||
#ifdef CONFIG_EXAMPLES_FOC_HAVE_POS
|
||||
args->cfg.mmode != FOC_MMODE_POS &&
|
||||
args->cfg.mmode != FOC_MMODE_POS &&
|
||||
#endif
|
||||
#ifdef CONFIG_EXAMPLES_FOC_HAVE_ALIGN
|
||||
args->cfg.mmode != FOC_MMODE_ALIGN_ONLY &&
|
||||
args->cfg.mmode != FOC_MMODE_ALIGN_ONLY &&
|
||||
#endif
|
||||
#ifdef CONFIG_EXAMPLES_FOC_HAVE_IDENT
|
||||
args->cfg.mmode != FOC_MMODE_IDENT_ONLY &&
|
||||
args->cfg.mmode != FOC_MMODE_IDENT_ONLY &&
|
||||
#endif
|
||||
1)
|
||||
1)
|
||||
{
|
||||
PRINTF("Invalid ctrl mode value %d s\n", args->cfg.mmode);
|
||||
goto errout;
|
||||
|
@ -79,6 +79,7 @@ enum foc_motor_mode_e
|
||||
#ifdef CONFIG_EXAMPLES_FOC_HAVE_IDENT
|
||||
FOC_MMODE_IDENT_ONLY = 5, /* Motor identification only */
|
||||
#endif
|
||||
FOC_MMODE_IDLE = 6, /* IDLE state */
|
||||
};
|
||||
|
||||
/* Controller state */
|
||||
|
Loading…
Reference in New Issue
Block a user