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/02/13 11:37:26 UTC
[GitHub] [incubator-nuttx] raiden00pl commented on a change in pull request #5479: lib_observer: add nolinear fluxlink observer
raiden00pl commented on a change in pull request #5479:
URL: https://github.com/apache/incubator-nuttx/pull/5479#discussion_r805320061
##########
File path: libs/libdsp/lib_observer.c
##########
@@ -495,6 +504,190 @@ void motor_sobserver_div(FAR struct motor_observer_f32_s *o,
so->angle_prev = angle;
}
+/****************************************************************************
+ * Name: motor_observer_nfo_init
+ *
+ * Description:
+ * Initialize motor nolinear fluxlink observer.
+ *
+ * Input Parameters:
+ * smo - pointer to the nolinear fluxlink observer private data
+ * kslide - SMO gain
+ * err_max - linear region upper limit
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void motor_observer_nfo_init(FAR struct motor_observer_nfo_f32_s *nfo)
+{
+ LIBDSP_DEBUGASSERT(smo != NULL);
+
+ /* Reset structure */
+
+ memset(nfo, 0, sizeof(struct motor_observer_nfo_f32_s));
+}
+
+/****************************************************************************
+ * Name: motor_observer_nfo
+ *
+ * Description:
+ * nolinear fluxlink observer.
+ * REFERENCE: http://cas.ensmp.fr/~praly/Telechargement/Journaux/
+ * 2010-IEEE_TPEL-Lee-Hong-Nam-Ortega-Praly-Astolfi.pdf
+ *
+ * Input Parameters:
+ * o - (in/out) pointer to the common observer data
+ * i_ab - (in) inverter alpha-beta current
+ * v_ab - (in) inverter alpha-beta voltage
+ * phy - (in) pointer to the motor physical parameters
+ * gain - (in) dynamic observer gain
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void motor_observer_nfo(FAR struct motor_observer_f32_s *o,
+ FAR ab_frame_f32_t *i_ab, FAR ab_frame_f32_t *v_ab,
+ FAR struct motor_phy_params_f32_s *phy, float gain)
+{
+ FAR struct motor_observer_nfo_f32_s *nfo =
+ (FAR struct motor_observer_nfo_f32_s *)o->ao;
+ float angle;
+ float err;
+ float x1_dot;
+ float x2_dot;
+
+ float l_ia = (3.0 / 2.0) * phy->ind * i_ab->a;
+ float l_ib = (3.0 / 2.0) * phy->ind * i_ab->b;
+ float r_ia = (3.0 / 2.0) * phy->res * i_ab->a;
+ float r_ib = (3.0 / 2.0) * phy->res * i_ab->b;
+
+ err = SQ(phy->flux_link) - (SQ(nfo->x1 - l_ia) + SQ(nfo->x2 - l_ib));
+
+ /* Forcing this term to stay negative helps convergence according to
+ * http://cas.ensmp.fr/Publications/Publications/Papers/
+ * ObserverPermanentMagnet.pdf and
+ * https://arxiv.org/pdf/1905.00833.pdf
+ */
+
+ if (err > 0.0)
+ {
+ err = 0.0;
+ }
+
+ x1_dot = -r_ia + v_ab->a + gain * (nfo->x1 - l_ia) * err;
+ x2_dot = -r_ib + v_ab->b + gain * (nfo->x2 - l_ib) * err;
+ nfo->x1 += x1_dot * o->per;
+ nfo->x2 += x2_dot * o->per;
+
+ NAN_ZERO(nfo->x1);
+ NAN_ZERO(nfo->x2);
+
+ /* Prevent the magnitude from getting too low
+ * as that makes the angle very unstable.
+ */
+
+ if (vector2d_mag(nfo->x1, nfo->x2) < (phy->flux_link * 0.5))
+ {
+ nfo->x1 *= 1.1;
+ nfo->x2 *= 1.1;
+ }
+
+ angle = fast_atan2(nfo->x2 - l_ib, nfo->x1 - l_ia);
Review comment:
I was wondering how to bring together software atan2 and hardware accelerated atan2 (eg. CORDIC). Probably in the future we should divide angle observers logic into a few stages, where one separate stage is atan2 calculation. But this is a topic for another day
##########
File path: libs/libdsp/lib_observer.c
##########
@@ -495,6 +504,190 @@ void motor_sobserver_div(FAR struct motor_observer_f32_s *o,
so->angle_prev = angle;
}
+/****************************************************************************
+ * Name: motor_observer_nfo_init
+ *
+ * Description:
+ * Initialize motor nolinear fluxlink observer.
+ *
+ * Input Parameters:
+ * smo - pointer to the nolinear fluxlink observer private data
+ * kslide - SMO gain
+ * err_max - linear region upper limit
Review comment:
```suggestion
* nfo - pointer to the nolinear fluxlink observer private data
```
--
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