You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/03/30 08:56:16 UTC

[GitHub] [incubator-nuttx] raiden00pl opened a new pull request #3244: Improvements for libdsp and support for fixed16 libdsp implementation

raiden00pl opened a new pull request #3244:
URL: https://github.com/apache/incubator-nuttx/pull/3244


   ## Summary
   
   - libdsp: add _f32_ suffix to all libdsp data structures tht use float as a numerical type
   - libdsp: introduce libdsp-specific debug assertion (LIBDSP_DEBUGASSERT)
   - libs/libdsp/lib_transform.c: update descriptions
   - libdsp/lib_svm.c: return not saturated output from modulator, the current corection now takes float as an arguments
   - libdsp/lib_motor.c: remove maximum openloop speed limiter
   - libs/libdsp/lib_motor.c: refactor
   - libdsp/lib_pid.c: add anti-windup protection with decay coefficient and add interface to select anti-windup mechanism
   - boards/arm/stm32/stm32f334-disco/src/stm32_smps.c: update according to the previous change in the PI controller
   - libdsp/lib_foc.c: use better PI wind-up protection; add interface to run voltage controller without current controller; add separate interfaces to update base voltage and phase angle
   - libdsp/lib_observer.c: optimize and add some comments
   - include/dsp.h: add DIR_NONE definition
   - libdsp/lib_motor.c: remove reference to some unused data
   - libdsp: add Permanent Magnet Synchronous Motor (PMSM) model
   - libdsp/Kconfig: move configuration to menuconfig, add option to include vabc in FOC data
   - libdsp: add support for fixed16 libdsp
   
   ## Impact
   
   ## Testing
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] davids5 commented on a change in pull request #3244: Improvements for libdsp and support for fixed16 libdsp implementation

Posted by GitBox <gi...@apache.org>.
davids5 commented on a change in pull request #3244:
URL: https://github.com/apache/incubator-nuttx/pull/3244#discussion_r604108359



##########
File path: include/dspb16.h
##########
@@ -0,0 +1,480 @@
+/****************************************************************************
+ * include/dspb16.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __INCLUDE_DSPB16_H
+#define __INCLUDE_DSPB16_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/compiler.h>
+
+#include <stddef.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdbool.h>
+#include <fixedmath.h>
+
+#include <assert.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Disable DEBUGASSERT macro if LIBDSP debug is not enabled */
+
+#ifdef CONFIG_LIBDSP_DEBUG
+#  ifndef CONFIG_DEBUG_ASSERTIONS
+#    warning "Need CONFIG_DEBUG_ASSERTIONS to work properly"
+#  endif
+#  define LIBDSP_DEBUGASSERT(x) DEBUGASSERT(x)
+#else
+#  undef LIBDSP_DEBUGASSERT
+#  define LIBDSP_DEBUGASSERT(x)
+#endif
+
+#ifndef CONFIG_LIBDSP_PRECISION
+#  define CONFIG_LIBDSP_PRECISION 0
+#endif
+
+/* Phase rotation direction */
+
+#define DIR_NONE_B16 ftob16(0.0f)
+#define DIR_CW_B16   ftob16(1.0f)
+#define DIR_CCW_B16  ftob16(-1.0f)
+
+/* Some math constants ******************************************************/
+
+#define SQRT3_BY_TWO_B16     ftob16(0.866025f)
+#define SQRT3_BY_THREE_B16   ftob16(0.57735f)
+#define ONE_BY_SQRT3_B16     ftob16(0.57735f)
+#define TWO_BY_SQRT3_B16     ftob16(1.15470f)
+
+/* Some lib constants *******************************************************/
+
+/* Motor electrical angle is in range 0.0 to 2*PI */
+
+#define MOTOR_ANGLE_E_MAX_B16    (b16TWOPI)
+#define MOTOR_ANGLE_E_MIN_B16    (0)
+#define MOTOR_ANGLE_E_RANGE_B16  (MOTOR_ANGLE_E_MAX_B16 - MOTOR_ANGLE_E_MIN_B16)
+
+/* Motor mechanical angle is in range 0.0 to 2*PI */
+
+#define MOTOR_ANGLE_M_MAX_B16    (b16TWOPI)
+#define MOTOR_ANGLE_M_MIN_B16    (0)
+#define MOTOR_ANGLE_M_RANGE_B16  (MOTOR_ANGLE_M_MAX_B16 - MOTOR_ANGLE_M_MIN_B16)
+
+/* Some useful macros *******************************************************/
+
+/****************************************************************************
+ * Name: LP_FILTER_B16
+ *
+ * Description:
+ *   Simple single-pole digital low pass filter:
+ *     Y(n) = (1-beta)*Y(n-1) + beta*X(n) = (beta * (Y(n-1) - X(n)))
+ *
+ *     filter - (0.0 - 1.0) where 1.0 gives unfiltered values
+ *     filter = T * (2*PI) * f_c
+ *
+ *     phase shift = -arctan(f_in/f_c)
+ *
+ *     T    - period at which the digital filter is being calculated
+ *     f_in - input frequency of the filter
+ *     f_c  - cutoff frequency of the filter
+ *
+ * REFERENCE: https://www.embeddedrelated.com/showarticle/779.php
+ *
+ ****************************************************************************/
+
+#define LP_FILTER_B16(val, sample, filter) val -= (b16mulb16(filter, (val - sample)))
+
+/****************************************************************************
+ * Name: SVM3_BASE_VOLTAGE_GET_B16
+ *
+ * Description:
+ *  Get maximum voltage for SVM3 without overmodulation
+ *
+ *  Notes:
+ *   max possible phase voltage for 3-phase power inwerter:

Review comment:
       ```suggestion
    *   max possible phase voltage for 3-phase power inverter:
   ```

##########
File path: libs/libdsp/Kconfig
##########
@@ -30,4 +30,7 @@ config LIBDSP_PRECISION
 		1 - a little better precision than above, but slowest

Review comment:
       @raiden00pl - I know is is from the original, but can you add more context here? (above what????)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] raiden00pl commented on a change in pull request #3244: Improvements for libdsp and support for fixed16 libdsp implementation

Posted by GitBox <gi...@apache.org>.
raiden00pl commented on a change in pull request #3244:
URL: https://github.com/apache/incubator-nuttx/pull/3244#discussion_r604254627



##########
File path: include/dspb16.h
##########
@@ -0,0 +1,480 @@
+/****************************************************************************
+ * include/dspb16.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __INCLUDE_DSPB16_H
+#define __INCLUDE_DSPB16_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/compiler.h>
+
+#include <stddef.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdbool.h>
+#include <fixedmath.h>
+
+#include <assert.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Disable DEBUGASSERT macro if LIBDSP debug is not enabled */
+
+#ifdef CONFIG_LIBDSP_DEBUG
+#  ifndef CONFIG_DEBUG_ASSERTIONS
+#    warning "Need CONFIG_DEBUG_ASSERTIONS to work properly"
+#  endif
+#  define LIBDSP_DEBUGASSERT(x) DEBUGASSERT(x)
+#else
+#  undef LIBDSP_DEBUGASSERT
+#  define LIBDSP_DEBUGASSERT(x)
+#endif
+
+#ifndef CONFIG_LIBDSP_PRECISION
+#  define CONFIG_LIBDSP_PRECISION 0
+#endif
+
+/* Phase rotation direction */
+
+#define DIR_NONE_B16 ftob16(0.0f)
+#define DIR_CW_B16   ftob16(1.0f)
+#define DIR_CCW_B16  ftob16(-1.0f)
+
+/* Some math constants ******************************************************/
+
+#define SQRT3_BY_TWO_B16     ftob16(0.866025f)
+#define SQRT3_BY_THREE_B16   ftob16(0.57735f)
+#define ONE_BY_SQRT3_B16     ftob16(0.57735f)
+#define TWO_BY_SQRT3_B16     ftob16(1.15470f)
+
+/* Some lib constants *******************************************************/
+
+/* Motor electrical angle is in range 0.0 to 2*PI */
+
+#define MOTOR_ANGLE_E_MAX_B16    (b16TWOPI)
+#define MOTOR_ANGLE_E_MIN_B16    (0)
+#define MOTOR_ANGLE_E_RANGE_B16  (MOTOR_ANGLE_E_MAX_B16 - MOTOR_ANGLE_E_MIN_B16)
+
+/* Motor mechanical angle is in range 0.0 to 2*PI */
+
+#define MOTOR_ANGLE_M_MAX_B16    (b16TWOPI)
+#define MOTOR_ANGLE_M_MIN_B16    (0)
+#define MOTOR_ANGLE_M_RANGE_B16  (MOTOR_ANGLE_M_MAX_B16 - MOTOR_ANGLE_M_MIN_B16)
+
+/* Some useful macros *******************************************************/
+
+/****************************************************************************
+ * Name: LP_FILTER_B16
+ *
+ * Description:
+ *   Simple single-pole digital low pass filter:
+ *     Y(n) = (1-beta)*Y(n-1) + beta*X(n) = (beta * (Y(n-1) - X(n)))
+ *
+ *     filter - (0.0 - 1.0) where 1.0 gives unfiltered values
+ *     filter = T * (2*PI) * f_c
+ *
+ *     phase shift = -arctan(f_in/f_c)
+ *
+ *     T    - period at which the digital filter is being calculated
+ *     f_in - input frequency of the filter
+ *     f_c  - cutoff frequency of the filter
+ *
+ * REFERENCE: https://www.embeddedrelated.com/showarticle/779.php
+ *
+ ****************************************************************************/
+
+#define LP_FILTER_B16(val, sample, filter) val -= (b16mulb16(filter, (val - sample)))
+
+/****************************************************************************
+ * Name: SVM3_BASE_VOLTAGE_GET_B16
+ *
+ * Description:
+ *  Get maximum voltage for SVM3 without overmodulation
+ *
+ *  Notes:
+ *   max possible phase voltage for 3-phase power inwerter:

Review comment:
       done




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] raiden00pl commented on pull request #3244: Improvements for libdsp and support for fixed16 libdsp implementation

Posted by GitBox <gi...@apache.org>.
raiden00pl commented on pull request #3244:
URL: https://github.com/apache/incubator-nuttx/pull/3244#issuecomment-811661288


   CI failed on files not related to this PR. Other tests have passed, so it seems that PR is good for merge.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #3244: Improvements for libdsp and support for fixed16 libdsp implementation

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged pull request #3244:
URL: https://github.com/apache/incubator-nuttx/pull/3244


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] raiden00pl commented on a change in pull request #3244: Improvements for libdsp and support for fixed16 libdsp implementation

Posted by GitBox <gi...@apache.org>.
raiden00pl commented on a change in pull request #3244:
URL: https://github.com/apache/incubator-nuttx/pull/3244#discussion_r604260731



##########
File path: libs/libdsp/Kconfig
##########
@@ -30,4 +30,7 @@ config LIBDSP_PRECISION
 		1 - a little better precision than above, but slowest

Review comment:
       I updated this comment. Is it ok ?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org