summaryrefslogtreecommitdiffhomepage
path: root/digital/asserv/src/asserv/motor_model.host.c
diff options
context:
space:
mode:
Diffstat (limited to 'digital/asserv/src/asserv/motor_model.host.c')
-rw-r--r--digital/asserv/src/asserv/motor_model.host.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/digital/asserv/src/asserv/motor_model.host.c b/digital/asserv/src/asserv/motor_model.host.c
index 37171c32..f87e7db6 100644
--- a/digital/asserv/src/asserv/motor_model.host.c
+++ b/digital/asserv/src/asserv/motor_model.host.c
@@ -77,6 +77,18 @@ void motor_model_step (struct motor_t *m)
+ h * m->m.i_G * m->m.i_G * m->m.ro_G / m->m.J
* (m->m.Kt * m->i - m->m.Rf * m->o);
th_ = m->th + h * m->o;
+ /* Test for limits overflow, I have no proof it works right for the
+ * moment, only suspicions. */
+ if (th_ < m->m.th_min)
+ {
+ th_ = m->m.th_min;
+ o_ = 0.0;
+ }
+ else if (th_ > m->m.th_max)
+ {
+ th_ = m->m.th_max;
+ o_ = 0.0;
+ }
/* Ok, now store this step. */
m->i = i_;
m->o = o_;