examples/foc: add controller IDLE mode
diff --git a/examples/foc/foc_motor_f32.c b/examples/foc/foc_motor_f32.c
index 134a0a3..733a2a0 100644
--- a/examples/foc/foc_motor_f32.c
+++ b/examples/foc/foc_motor_f32.c
@@ -531,6 +531,7 @@
#ifdef CONFIG_EXAMPLES_FOC_HAVE_IDENT
case FOC_MMODE_IDENT_ONLY:
#endif
+ case FOC_MMODE_IDLE:
{
/* Do nothing */
@@ -1005,6 +1006,11 @@
}
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;
}
diff --git a/examples/foc/foc_parseargs.c b/examples/foc/foc_parseargs.c
index f4e669a..fa4de58 100644
--- a/examples/foc/foc_parseargs.c
+++ b/examples/foc/foc_parseargs.c
@@ -113,6 +113,7 @@
#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 @@
/* 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;
diff --git a/examples/foc/foc_thr.h b/examples/foc/foc_thr.h
index f08a814..6298011 100644
--- a/examples/foc/foc_thr.h
+++ b/examples/foc/foc_thr.h
@@ -79,6 +79,7 @@
#ifdef CONFIG_EXAMPLES_FOC_HAVE_IDENT
FOC_MMODE_IDENT_ONLY = 5, /* Motor identification only */
#endif
+ FOC_MMODE_IDLE = 6, /* IDLE state */
};
/* Controller state */