Skip to content

Commit f6a8a68

Browse files
committed
motion: fix brake/direction setting when S command is sent.
spindle_on command is also used for setting the spindle speed via S code. Setting the S code does not mean the brake or direction should be changed if M3/M4 is not active. Ultimately we should have a separate set_spindle_speed_command to make this cleaner
1 parent ef17bb8 commit f6a8a68

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/emc/motion/command.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,12 +1609,14 @@ void emcmotCommandHandler_locked(void *arg, long servo_period)
16091609
emcmotStatus->spindle_status[n].speed = emcmotCommand->vel;
16101610
emcmotStatus->spindle_status[n].css_factor = emcmotCommand->ini_maxvel;
16111611
emcmotStatus->spindle_status[n].xoffset = emcmotCommand->acc;
1612-
if (emcmotCommand->vel >= 0) {
1613-
emcmotStatus->spindle_status[n].direction = 1;
1614-
} else {
1615-
emcmotStatus->spindle_status[n].direction = -1;
1616-
}
1617-
emcmotStatus->spindle_status[n].brake = 0; //disengage brake
1612+
if (emcmotCommand->state) {
1613+
if (emcmotCommand->vel >= 0) {
1614+
emcmotStatus->spindle_status[n].direction = 1;
1615+
} else {
1616+
emcmotStatus->spindle_status[n].direction = -1;
1617+
}
1618+
emcmotStatus->spindle_status[n].brake = 0; //disengage brake
1619+
}
16181620
apply_spindle_limits(&emcmotStatus->spindle_status[n]);
16191621
}
16201622
emcmotStatus->atspeed_next_feed = emcmotCommand->wait_for_spindle_at_speed;

0 commit comments

Comments
 (0)