From 8c4fb92e6337ef4c67c968f21a1a766ebd42e488 Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Tue, 15 Dec 2020 16:11:51 -0800 Subject: [PATCH] fix ACIM estimator source for current controller --- Firmware/MotorControl/axis.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Firmware/MotorControl/axis.cpp b/Firmware/MotorControl/axis.cpp index 15eaa3d5..363c75bb 100644 --- a/Firmware/MotorControl/axis.cpp +++ b/Firmware/MotorControl/axis.cpp @@ -313,14 +313,18 @@ bool Axis::start_closed_loop_control() { motor_.current_control_.Idq_setpoint_src_.connect_to(&motor_.Idq_setpoint_); motor_.current_control_.Vdq_setpoint_src_.connect_to(&motor_.Vdq_setpoint_); + bool is_acim = motor_.config_.motor_type == Motor::MOTOR_TYPE_ACIM; + // phase OutputPort* phase_src = sensorless_mode ? &sensorless_estimator_.phase_ : &encoder_.phase_; - motor_.current_control_.phase_src_.connect_to(phase_src); acim_estimator_.rotor_phase_src_.connect_to(phase_src); - + OutputPort* stator_phase_src = is_acim ? &acim_estimator_.stator_phase_ : phase_src; + motor_.current_control_.phase_src_.connect_to(stator_phase_src); + // phase vel OutputPort* phase_vel_src = sensorless_mode ? &sensorless_estimator_.phase_vel_ : &encoder_.phase_vel_; - motor_.phase_vel_src_.connect_to(phase_vel_src); - motor_.current_control_.phase_vel_src_.connect_to(phase_vel_src); acim_estimator_.rotor_phase_vel_src_.connect_to(phase_vel_src); + OutputPort* stator_phase_vel_src = is_acim ? &acim_estimator_.stator_phase_vel_ : phase_vel_src; + motor_.phase_vel_src_.connect_to(stator_phase_vel_src); + motor_.current_control_.phase_vel_src_.connect_to(stator_phase_vel_src); if (sensorless_mode) { // Make the final velocity of the loĉk-in spin the setpoint of the