From 4ad2fc60a8e0f2467ac5f99d5760560ac53808b2 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 29 Aug 2019 20:24:09 -0400 Subject: [PATCH] Reset vel_integrator_current when going into closed loop mode --- Firmware/MotorControl/axis.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Firmware/MotorControl/axis.cpp b/Firmware/MotorControl/axis.cpp index a2bae293..98d790bd 100644 --- a/Firmware/MotorControl/axis.cpp +++ b/Firmware/MotorControl/axis.cpp @@ -302,6 +302,10 @@ bool Axis::run_sensorless_control_loop() { bool Axis::run_closed_loop_control_loop() { // To avoid any transient on startup, we intialize the setpoint to be the current position controller_.pos_setpoint_ = encoder_.pos_estimate_; + + // Avoid integrator windup issues + controller_.vel_integrator_current_ = 0.0f; + set_step_dir_active(config_.enable_step_dir); run_control_loop([this]() { // Note that all estimators are updated in the loop prefix in run_control_loop