You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/10/29 02:40:33 UTC
(nuttx-apps) branch master updated (518b1aea6 -> 292b0cbc2)
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
from 518b1aea6 system/nxrecorder: add amr offload record support
new 8568439b8 examples/foc: configure acceleration and deceleration from command line
new 292b0cbc2 examples/foc: change the velocity ramp parameters scale to x1
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
examples/foc/Kconfig | 6 +++---
examples/foc/foc_cfg.h | 6 +++---
examples/foc/foc_main.c | 4 ++++
examples/foc/foc_motor_b16.c | 4 ++--
examples/foc/foc_motor_f32.c | 4 ++--
examples/foc/foc_parseargs.c | 20 +++++++++++++++++++-
6 files changed, 33 insertions(+), 11 deletions(-)
(nuttx-apps) 02/02: examples/foc: change the velocity ramp parameters scale to x1
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit 292b0cbc2839e8baf2e7df8ad718d1ff20fe9268
Author: raiden00pl <ra...@railab.me>
AuthorDate: Sun Oct 15 16:34:21 2023 +0200
examples/foc: change the velocity ramp parameters scale to x1
controlling the ramp with greather accuracy makes no practical sense
---
examples/foc/Kconfig | 6 +++---
examples/foc/foc_cfg.h | 6 +++---
examples/foc/foc_motor_b16.c | 4 ++--
examples/foc/foc_motor_f32.c | 4 ++--
4 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/examples/foc/Kconfig b/examples/foc/Kconfig
index f48d53db3..517c304bb 100644
--- a/examples/foc/Kconfig
+++ b/examples/foc/Kconfig
@@ -568,15 +568,15 @@ config EXAMPLES_FOC_IDQ_KI
endif #EXAMPLES_FOC_CONTROL_PI
config EXAMPLES_FOC_RAMP_THR
- int "FOC velocity ramp threshold [x1000]"
+ int "FOC velocity ramp threshold [x1]"
default 0
config EXAMPLES_FOC_RAMP_ACC
- int "FOC velocity ramp acc [x1000]"
+ int "FOC velocity ramp acc [x1]"
default 0
config EXAMPLES_FOC_RAMP_DEC
- int "FOC velocity ramp dec [x1000]"
+ int "FOC velocity ramp dec [x1]"
default 0
config EXAMPLES_FOC_HAVE_ALIGN
diff --git a/examples/foc/foc_cfg.h b/examples/foc/foc_cfg.h
index b8b0bad24..d2e8632cb 100644
--- a/examples/foc/foc_cfg.h
+++ b/examples/foc/foc_cfg.h
@@ -116,7 +116,7 @@
/* Velocity ramp configuration */
-#define RAMP_CFG_THR (CONFIG_EXAMPLES_FOC_RAMP_THR / 1000.0f)
+#define RAMP_CFG_THR (CONFIG_EXAMPLES_FOC_RAMP_THR / 1.0f)
#ifdef CONFIG_EXAMPLES_FOC_STATE_USE_MODEL_PMSM
@@ -237,8 +237,8 @@ struct foc_thr_cfg_s
#endif
#ifdef CONFIG_EXAMPLES_FOC_HAVE_VEL
uint32_t velmax; /* Velocity max (x1000) */
- uint32_t acc; /* Acceleration (x1000) */
- uint32_t dec; /* Deceleration (x1000) */
+ uint32_t acc; /* Acceleration (x1) */
+ uint32_t dec; /* Deceleration (x1) */
#endif
#ifdef CONFIG_EXAMPLES_FOC_HAVE_POS
uint32_t posmax; /* Position max (x1000) */
diff --git a/examples/foc/foc_motor_b16.c b/examples/foc/foc_motor_b16.c
index 06e79555f..64f26240c 100644
--- a/examples/foc/foc_motor_b16.c
+++ b/examples/foc/foc_motor_b16.c
@@ -307,8 +307,8 @@ static int foc_motor_configure(FAR struct foc_motor_b16_s *motor)
ret = foc_ramp_init_b16(&motor->ramp,
motor->per,
ftob16(RAMP_CFG_THR),
- ftob16((motor->envp->cfg->acc / 1000.0f)),
- ftob16((motor->envp->cfg->dec / 1000.0f)));
+ ftob16((motor->envp->cfg->acc / 1.0f)),
+ ftob16((motor->envp->cfg->dec / 1.0f)));
if (ret < 0)
{
PRINTF("ERROR: foc_ramp_init failed %d\n", ret);
diff --git a/examples/foc/foc_motor_f32.c b/examples/foc/foc_motor_f32.c
index 795b5e82c..95026e9d7 100644
--- a/examples/foc/foc_motor_f32.c
+++ b/examples/foc/foc_motor_f32.c
@@ -307,8 +307,8 @@ static int foc_motor_configure(FAR struct foc_motor_f32_s *motor)
ret = foc_ramp_init_f32(&motor->ramp,
motor->per,
RAMP_CFG_THR,
- (motor->envp->cfg->acc / 1000.0f),
- (motor->envp->cfg->dec / 1000.0f));
+ (motor->envp->cfg->acc / 1.0f),
+ (motor->envp->cfg->dec / 1.0f));
if (ret < 0)
{
PRINTF("ERROR: foc_ramp_init failed %d\n", ret);
(nuttx-apps) 01/02: examples/foc: configure acceleration and deceleration from command line
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit 8568439b8070057f26f937e54aa887d3d7754f0d
Author: raiden00pl <ra...@railab.me>
AuthorDate: Fri Oct 13 21:12:44 2023 +0200
examples/foc: configure acceleration and deceleration from command line
---
examples/foc/foc_cfg.h | 4 ++--
examples/foc/foc_main.c | 4 ++++
examples/foc/foc_motor_b16.c | 4 ++--
examples/foc/foc_motor_f32.c | 4 ++--
examples/foc/foc_parseargs.c | 20 +++++++++++++++++++-
5 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/examples/foc/foc_cfg.h b/examples/foc/foc_cfg.h
index 9edb488ad..b8b0bad24 100644
--- a/examples/foc/foc_cfg.h
+++ b/examples/foc/foc_cfg.h
@@ -117,8 +117,6 @@
/* Velocity ramp configuration */
#define RAMP_CFG_THR (CONFIG_EXAMPLES_FOC_RAMP_THR / 1000.0f)
-#define RAMP_CFG_ACC (CONFIG_EXAMPLES_FOC_RAMP_ACC / 1000.0f)
-#define RAMP_CFG_DEC (CONFIG_EXAMPLES_FOC_RAMP_DEC / 1000.0f)
#ifdef CONFIG_EXAMPLES_FOC_STATE_USE_MODEL_PMSM
@@ -239,6 +237,8 @@ struct foc_thr_cfg_s
#endif
#ifdef CONFIG_EXAMPLES_FOC_HAVE_VEL
uint32_t velmax; /* Velocity max (x1000) */
+ uint32_t acc; /* Acceleration (x1000) */
+ uint32_t dec; /* Deceleration (x1000) */
#endif
#ifdef CONFIG_EXAMPLES_FOC_HAVE_POS
uint32_t posmax; /* Position max (x1000) */
diff --git a/examples/foc/foc_main.c b/examples/foc/foc_main.c
index 071618a29..2d1c89cf2 100644
--- a/examples/foc/foc_main.c
+++ b/examples/foc/foc_main.c
@@ -107,6 +107,10 @@ struct args_s g_args =
.posmax = CONFIG_EXAMPLES_FOC_SETPOINT_MAX,
# endif
#endif
+#ifdef CONFIG_EXAMPLES_FOC_HAVE_VEL
+ .acc = CONFIG_EXAMPLES_FOC_RAMP_ACC,
+ .dec = CONFIG_EXAMPLES_FOC_RAMP_DEC,
+#endif
#ifdef CONFIG_EXAMPLES_FOC_HAVE_IDENT
.ident_res_ki = CONFIG_EXAMPLES_FOC_IDENT_RES_KI,
.ident_res_curr = CONFIG_EXAMPLES_FOC_IDENT_RES_CURRENT,
diff --git a/examples/foc/foc_motor_b16.c b/examples/foc/foc_motor_b16.c
index 1ceda71a3..06e79555f 100644
--- a/examples/foc/foc_motor_b16.c
+++ b/examples/foc/foc_motor_b16.c
@@ -307,8 +307,8 @@ static int foc_motor_configure(FAR struct foc_motor_b16_s *motor)
ret = foc_ramp_init_b16(&motor->ramp,
motor->per,
ftob16(RAMP_CFG_THR),
- ftob16(RAMP_CFG_ACC),
- ftob16(RAMP_CFG_ACC));
+ ftob16((motor->envp->cfg->acc / 1000.0f)),
+ ftob16((motor->envp->cfg->dec / 1000.0f)));
if (ret < 0)
{
PRINTF("ERROR: foc_ramp_init failed %d\n", ret);
diff --git a/examples/foc/foc_motor_f32.c b/examples/foc/foc_motor_f32.c
index 3c7536345..795b5e82c 100644
--- a/examples/foc/foc_motor_f32.c
+++ b/examples/foc/foc_motor_f32.c
@@ -307,8 +307,8 @@ static int foc_motor_configure(FAR struct foc_motor_f32_s *motor)
ret = foc_ramp_init_f32(&motor->ramp,
motor->per,
RAMP_CFG_THR,
- RAMP_CFG_ACC,
- RAMP_CFG_ACC);
+ (motor->envp->cfg->acc / 1000.0f),
+ (motor->envp->cfg->dec / 1000.0f));
if (ret < 0)
{
PRINTF("ERROR: foc_ramp_init failed %d\n", ret);
diff --git a/examples/foc/foc_parseargs.c b/examples/foc/foc_parseargs.c
index 1c8c6adc4..1db84a928 100644
--- a/examples/foc/foc_parseargs.c
+++ b/examples/foc/foc_parseargs.c
@@ -76,6 +76,8 @@ static struct option g_long_options[] =
#endif
#ifdef CONFIG_EXAMPLES_FOC_HAVE_VEL
{ "vel", required_argument, 0, 'v' },
+ { "acc", required_argument, 0, 'a' },
+ { "dec", required_argument, 0, 'd' },
#endif
#ifdef CONFIG_EXAMPLES_FOC_HAVE_POS
{ "pos", required_argument, 0, 'x' },
@@ -157,6 +159,10 @@ static void foc_help(FAR struct args_s *args)
#endif
#ifdef CONFIG_EXAMPLES_FOC_HAVE_VEL
PRINTF(" [-v] velocity [x1000]\n");
+ PRINTF(" [-a] acceleration [x1000] (default: %" PRId32 ")\n",
+ args->cfg.acc);
+ PRINTF(" [-d] deceleration [x1000] (default: %" PRId32 ")\n",
+ args->cfg.dec);
#endif
#ifdef CONFIG_EXAMPLES_FOC_HAVE_POS
PRINTF(" [-x] position [x1000]\n");
@@ -238,7 +244,7 @@ void parse_args(FAR struct args_s *args, int argc, FAR char **argv)
while (1)
{
- c = getopt_long(argc, argv, "ht:f:m:o:r:v:x:s:j:", g_long_options,
+ c = getopt_long(argc, argv, "ht:f:m:o:r:v:a:d:x:s:j:", g_long_options,
&option_index);
if (c == -1)
@@ -388,6 +394,18 @@ void parse_args(FAR struct args_s *args, int argc, FAR char **argv)
args->cfg.velmax = atoi(optarg);
break;
}
+
+ case 'a':
+ {
+ args->cfg.acc = atoi(optarg);
+ break;
+ }
+
+ case 'd':
+ {
+ args->cfg.dec = atoi(optarg);
+ break;
+ }
#endif
#ifdef CONFIG_EXAMPLES_FOC_HAVE_POS