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 2022/02/20 13:58:20 UTC
[incubator-nuttx] 01/04: libdsp: add one_by_p to motor_phy_params
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/incubator-nuttx.git
commit ca4790c4291a84979af7d9f43290dd126dccc52f
Author: raiden00pl <ra...@railab.me>
AuthorDate: Sat Feb 19 21:08:13 2022 +0100
libdsp: add one_by_p to motor_phy_params
---
include/dsp.h | 1 +
include/dspb16.h | 1 +
libs/libdsp/lib_motor.c | 1 +
libs/libdsp/lib_motor_b16.c | 1 +
4 files changed, 4 insertions(+)
diff --git a/include/dsp.h b/include/dsp.h
index c5c7f63..a1b4726 100644
--- a/include/dsp.h
+++ b/include/dsp.h
@@ -386,6 +386,7 @@ struct motor_phy_params_f32_s
float res; /* Phase-to-neutral resistance */
float ind; /* Average phase-to-neutral inductance */
float one_by_ind; /* Inverse phase-to-neutral inductance */
+ float one_by_p; /* Inverse number of motor pole pairs */
};
/* PMSM motor physcial parameters */
diff --git a/include/dspb16.h b/include/dspb16.h
index 3d0f292..41ce127 100644
--- a/include/dspb16.h
+++ b/include/dspb16.h
@@ -299,6 +299,7 @@ struct motor_phy_params_b16_s
*/
b16_t ind; /* Average phase-to-neutral inductance */
b16_t one_by_ind; /* Inverse phase-to-neutral inductance */
+ b16_t one_by_p; /* Inverse number of motor pole pairs */
};
/* PMSM motor physcial parameters */
diff --git a/libs/libdsp/lib_motor.c b/libs/libdsp/lib_motor.c
index dfc477d9..20959a8 100644
--- a/libs/libdsp/lib_motor.c
+++ b/libs/libdsp/lib_motor.c
@@ -372,6 +372,7 @@ void motor_phy_params_init(FAR struct motor_phy_params_f32_s *phy,
phy->res = res;
phy->ind = ind;
phy->one_by_ind = (1.0f / ind);
+ phy->one_by_p = (1.0f / poles);
}
/****************************************************************************
diff --git a/libs/libdsp/lib_motor_b16.c b/libs/libdsp/lib_motor_b16.c
index 1f466de..d7af168 100644
--- a/libs/libdsp/lib_motor_b16.c
+++ b/libs/libdsp/lib_motor_b16.c
@@ -324,6 +324,7 @@ void motor_phy_params_init_b16(FAR struct motor_phy_params_b16_s *phy,
phy->res = res;
phy->ind = ind;
phy->one_by_ind = b16divb16(b16ONE, ind);
+ phy->one_by_p = b16divb16(b16ONE, poles);
}
/****************************************************************************