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 2022/05/31 07:20:57 UTC

[GitHub] [incubator-nuttx-apps] raiden00pl commented on a diff in pull request #1174: industry/foc foc_ident: add the flux linkage identification

raiden00pl commented on code in PR #1174:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1174#discussion_r885286106


##########
industry/foc/float/foc_ident.c:
##########
@@ -331,6 +345,121 @@ int foc_ident_ind_run_f32(FAR struct foc_ident_f32_s *ident,
   return ret;
 }
 
+/****************************************************************************
+ * Name: foc_ident_fluxlink_run_f32
+ *
+ * Description:
+ *   Run flux linkage identification routine
+ *
+ * Input Parameter:
+ *   ident - pointer to FOC ident routine
+ *   in    - pointer to FOC routine input data
+ *   out   - pointer to FOC routine output data
+ *
+ ****************************************************************************/
+
+int foc_ident_fluxlink_run_f32(FAR struct foc_ident_f32_s *ident,
+                               FAR struct foc_routine_in_f32_s *in,
+                               FAR struct foc_routine_out_f32_s *out)
+{
+  int   ret  = FOC_ROUTINE_RUN_NOTDONE;
+  float curr_avg  = 0.0f;
+  float volt_avg  = 0.0f;
+  static float dir    = DIR_CW;
+  static float vq_sum = 0.0f;
+  static float vd_sum = 0.0f;
+  static float iq_sum = 0.0f;
+  static float id_sum = 0.0f;
+  static float vel = 0.0f;
+  static int aveg_sum  = 0;
+
+  if (ident->cfg.cb.angle != NULL)
+    {
+      /* Update openloop angle by angle callbacks */
+
+      out->angle = ident->cfg.cb.angle(ident->cfg.cb.priv_angle, vel, dir);
+    }
+
+  if (ident->cfg.cb.speed != NULL)
+    {
+      /* Update openloop speed by speed callbacks */
+
+      vel = ident->cfg.cb.speed(ident->cfg.cb.priv_speed,
+                                ident->cfg.flux_vel, vel);
+    }

Review Comment:
   Does this whole procedure make sense when callbacks are not defined ? If not, maybe we should check if callbacks are defined during the initialization of identification routine ? and return error if not defined. 
   Then here we can just add:
   
    DEBUGASSERT(ident->cfg.cb.zero != NULL);
   DEBUGASSERT(ident->cfg.cb.angle != NULL);
   DEBUGASSERT(ident->cfg.cb.speed != NULL);



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

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