File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -393,6 +393,9 @@ void BLDCMotor::loopFOC() {
393393// - if target is not set it uses motor.target value
394394void BLDCMotor::move (float new_target) {
395395
396+ // set internal target variable
397+ if (_isset (new_target)) target = new_target;
398+
396399 // downsampling (optional)
397400 if (motion_cnt++ < motion_downsample) return ;
398401 motion_cnt = 0 ;
@@ -410,8 +413,6 @@ void BLDCMotor::move(float new_target) {
410413
411414 // if disabled do nothing
412415 if (!enabled) return ;
413- // set internal target variable
414- if (_isset (new_target)) target = new_target;
415416
416417 // calculate the back-emf voltage if KV_rating available U_bemf = vel*(1/KV)
417418 if (_isset (KV_rating)) voltage_bemf = shaft_velocity/(KV_rating*_SQRT3)/_RPM_TO_RADS;
Original file line number Diff line number Diff line change @@ -283,6 +283,9 @@ void StepperMotor::loopFOC() {
283283// - if target is not set it uses motor.target value
284284void StepperMotor::move (float new_target) {
285285
286+ // set internal target variable
287+ if (_isset (new_target) ) target = new_target;
288+
286289 // downsampling (optional)
287290 if (motion_cnt++ < motion_downsample) return ;
288291 motion_cnt = 0 ;
@@ -301,8 +304,6 @@ void StepperMotor::move(float new_target) {
301304 // if disabled do nothing
302305 if (!enabled) return ;
303306
304- // set internal target variable
305- if (_isset (new_target) ) target = new_target;
306307
307308 // calculate the back-emf voltage if KV_rating available U_bemf = vel*(1/KV)
308309 if (_isset (KV_rating)) voltage_bemf = shaft_velocity/(KV_rating*_SQRT3)/_RPM_TO_RADS;
You can’t perform that action at this time.
0 commit comments