File tree Expand file tree Collapse file tree 3 files changed +5
-2
lines changed Expand file tree Collapse file tree 3 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -418,7 +418,8 @@ void BLDCMotor::move(float new_target) {
418
418
// angle set point
419
419
shaft_angle_sp = target;
420
420
// calculate velocity set point
421
- shaft_velocity_sp = P_angle ( shaft_angle_sp - shaft_angle );
421
+ shaft_velocity_sp = feed_forward_velocity + P_angle ( shaft_angle_sp - shaft_angle );
422
+ shaft_angle_sp = _constrain (shaft_angle_sp,-velocity_limit, velocity_limit);
422
423
// calculate the torque command - sensor precision: this calculation is ok, but based on bad value from previous calculation
423
424
current_sp = PID_velocity (shaft_velocity_sp - shaft_velocity); // if voltage torque control
424
425
// if torque controlled through voltage
Original file line number Diff line number Diff line change @@ -307,7 +307,8 @@ void StepperMotor::move(float new_target) {
307
307
// angle set point
308
308
shaft_angle_sp = target;
309
309
// calculate velocity set point
310
- shaft_velocity_sp = P_angle ( shaft_angle_sp - shaft_angle );
310
+ shaft_velocity_sp = feed_forward_velocity + P_angle ( shaft_angle_sp - shaft_angle );
311
+ shaft_angle_sp = _constrain (shaft_angle_sp, -velocity_limit, velocity_limit);
311
312
// calculate the torque command
312
313
current_sp = PID_velocity (shaft_velocity_sp - shaft_velocity); // if voltage torque control
313
314
// if torque controlled through voltage
Original file line number Diff line number Diff line change @@ -155,6 +155,7 @@ class FOCMotor
155
155
156
156
// state variables
157
157
float target; // !< current target value - depends of the controller
158
+ float feed_forward_velocity = 0 .0f ; // !< current feed forward velocity
158
159
float shaft_angle;// !< current motor angle
159
160
float electrical_angle;// !< current electrical angle
160
161
float shaft_velocity;// !< current motor velocity
You can’t perform that action at this time.
0 commit comments