Skip to content

Commit 0b53813

Browse files
authored
Merge pull request #267 from simplefoc/FEAT_velocity_feadforward
inital implementation of the velocity feed forward
2 parents 7009b48 + 1df9470 commit 0b53813

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/BLDCMotor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ void BLDCMotor::move(float new_target) {
422422
shaft_angle_sp = target;
423423
// calculate velocity set point
424424
shaft_velocity_sp = feed_forward_velocity + P_angle( shaft_angle_sp - shaft_angle );
425-
shaft_angle_sp = _constrain(shaft_angle_sp,-velocity_limit, velocity_limit);
425+
shaft_velocity_sp = _constrain(shaft_velocity_sp,-velocity_limit, velocity_limit);
426426
// calculate the torque command - sensor precision: this calculation is ok, but based on bad value from previous calculation
427427
current_sp = PID_velocity(shaft_velocity_sp - shaft_velocity); // if voltage torque control
428428
// if torque controlled through voltage

src/StepperMotor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ void StepperMotor::move(float new_target) {
311311
shaft_angle_sp = target;
312312
// calculate velocity set point
313313
shaft_velocity_sp = feed_forward_velocity + P_angle( shaft_angle_sp - shaft_angle );
314-
shaft_angle_sp = _constrain(shaft_angle_sp, -velocity_limit, velocity_limit);
314+
shaft_velocity_sp = _constrain(shaft_velocity_sp, -velocity_limit, velocity_limit);
315315
// calculate the torque command
316316
current_sp = PID_velocity(shaft_velocity_sp - shaft_velocity); // if voltage torque control
317317
// if torque controlled through voltage
@@ -440,4 +440,4 @@ float StepperMotor::angleOpenloop(float target_angle){
440440
open_loop_timestamp = now_us;
441441

442442
return Uq;
443-
}
443+
}

0 commit comments

Comments
 (0)