From ca4790c4291a84979af7d9f43290dd126dccc52f Mon Sep 17 00:00:00 2001 From: raiden00pl Date: Sat, 19 Feb 2022 21:08:13 +0100 Subject: [PATCH] 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 c5c7f6374a8..a1b4726221a 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 3d0f292a5d4..41ce1276fce 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 dfc477d99e4..20959a873dd 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 1f466de76a0..d7af1680d51 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); } /****************************************************************************