mirror of https://github.com/rusefi/bldc.git
Encoder position control fix
This commit is contained in:
parent
42c1b79a08
commit
cc17142264
|
@ -27,7 +27,7 @@
|
|||
|
||||
// Firmware version
|
||||
#define FW_VERSION_MAJOR 2
|
||||
#define FW_VERSION_MINOR 7
|
||||
#define FW_VERSION_MINOR 8
|
||||
|
||||
#include "datatypes.h"
|
||||
|
||||
|
|
|
@ -1848,8 +1848,13 @@ static void run_pid_control_pos(float dt) {
|
|||
}
|
||||
|
||||
// Compute error
|
||||
float angle = m_conf->foc_encoder_inverted ? encoder_read_deg() : 360.0 - encoder_read_deg();
|
||||
float error = utils_angle_difference(angle, m_pos_pid_set_pos);
|
||||
float angle = encoder_read_deg();
|
||||
float error = utils_angle_difference(m_pos_pid_set_pos, angle);
|
||||
|
||||
if (m_conf->foc_encoder_inverted) {
|
||||
error = -error;
|
||||
}
|
||||
|
||||
|
||||
// Compute parameters
|
||||
p_term = error * m_conf->p_pid_kp;
|
||||
|
|
Loading…
Reference in New Issue