fix(FOC): 修正大角度下会导致角度控制失控的问题
移除冗余的 `_electricalAngle` 函数,修正 `setPhaseVoltage` 中电气角度的计算方式 在定时器中断中增加实时角度更新,支持新增的无 PID 角度控制模式。
This commit is contained in:
@@ -12,7 +12,7 @@ PIDController::PIDController(float P, float I, float D, float ramp, float limit)
|
||||
,
|
||||
limit(limit) // PID控制器输出限幅
|
||||
,
|
||||
error_prev(0.0f), output_prev(0.0f), integral_prev(0.0f), timestamp_prev(0) {}
|
||||
error_prev(0.0f), output_prev(0.0f), integral_prev(0.0f) {}
|
||||
|
||||
// PID 控制器函数
|
||||
float PIDController::operator()(float error) {
|
||||
@@ -29,6 +29,7 @@ float PIDController::operator()(float error) {
|
||||
|
||||
// 将P,I,D三环的计算值加起来
|
||||
float output = proportional + integral + derivative;
|
||||
CAN0_transmiter.testfloat_union.f = D;
|
||||
output = _constrain(output, -limit, limit);
|
||||
|
||||
// 输出斜坡限制
|
||||
@@ -40,7 +41,7 @@ float PIDController::operator()(float error) {
|
||||
else if (output_rate < -output_ramp)
|
||||
output = output_prev - output_ramp * TIME_SLICE;
|
||||
}
|
||||
|
||||
CAN0_transmiter.testfloat_union.f = output;
|
||||
// 保存值(为了下一次循环)
|
||||
integral_prev = integral;
|
||||
output_prev = output;
|
||||
|
||||
Reference in New Issue
Block a user