@@ -505,6 +505,22 @@ void emcmotCommandHandler_locked(void *arg, long servo_period)
505505 if (GET_MOTION_TELEOP_FLAG ()) {
506506 axis_jog_abort_all (0 );
507507 } else if (GET_MOTION_COORD_FLAG ()) {
508+ /* If motion was being held waiting for spindle at-speed, the
509+ operator most likely aborted because the machine sat idle
510+ with no obvious reason. Tell them why, loudly. A wait that
511+ never released after a spindle stop almost always means
512+ spindle.N.at-speed is not wired, or does not go true once the
513+ spindle has actually stopped. */
514+ if (MOTION_ID_VALID (emcmotInternal -> coord_tp .spindle .waiting_for_atspeed )) {
515+ for (spindle_num = 0 ; spindle_num < emcmotConfig -> numSpindles ; spindle_num ++ ) {
516+ if (emcmotStatus -> spindle_status [spindle_num ].state == 0 && !emcmotStatus -> spindle_status [spindle_num ].at_speed ) {
517+ reportError (_ ("Aborted while waiting for spindle %d at-speed after a spindle stop. "
518+ "Check that spindle.%d.at-speed is connected and goes true once the spindle has stopped." ),
519+ spindle_num , spindle_num );
520+ break ;
521+ }
522+ }
523+ }
508524 tpAbort (& emcmotInternal -> coord_tp );
509525 } else {
510526 for (joint_num = 0 ; joint_num < ALL_JOINTS ; joint_num ++ ) {
@@ -528,6 +544,8 @@ void emcmotCommandHandler_locked(void *arg, long servo_period)
528544 SET_JOINT_FAULT_FLAG (joint , 0 );
529545 }
530546 emcmotStatus -> paused = 0 ;
547+ /* Drop any pending at-speed barrier so it can't strand a later move. */
548+ emcmotStatus -> atspeed_next_feed = 0 ;
531549 break ;
532550
533551 case EMCMOT_JOG_ABORT :
@@ -1452,6 +1470,14 @@ void emcmotCommandHandler_locked(void *arg, long servo_period)
14521470 }
14531471 }
14541472
1473+ /* A probe is a feed-type move, so honor any pending at-speed
1474+ barrier just like G1: wait for spindle.N.at-speed (spin-up after
1475+ M3, or stop after M5) before the probe starts. */
1476+ if (emcmotStatus -> atspeed_next_feed ) {
1477+ issue_atspeed = 1 ;
1478+ emcmotStatus -> atspeed_next_feed = 0 ;
1479+ }
1480+
14551481 /* append it to the emcmotInternal->coord_tp */
14561482 tpSetId (& emcmotInternal -> coord_tp , emcmotCommand -> id );
14571483 if (-1 == tpAddLine (& emcmotInternal -> coord_tp ,
@@ -1461,7 +1487,7 @@ void emcmotCommandHandler_locked(void *arg, long servo_period)
14611487 emcmotCommand -> ini_maxvel ,
14621488 emcmotCommand -> acc ,
14631489 emcmotStatus -> enables_new ,
1464- 0 ,
1490+ issue_atspeed ,
14651491 -1 ,
14661492 emcmotCommand -> tag )) {
14671493 reportError (_ ("can't add probe move" ));
@@ -1656,6 +1682,10 @@ void emcmotCommandHandler_locked(void *arg, long servo_period)
16561682 * (emcmot_hal_data -> spindle [n ].spindle_orient ) = 0 ;
16571683 emcmotStatus -> spindle_status [n ].orient_state = EMCMOT_ORIENT_NONE ;
16581684 }
1685+ /* Optionally make the spindle stop an at-speed barrier: the next feed
1686+ move waits until at-speed reflects the stopped state. Safe when
1687+ unwired since at-speed defaults to 1 (see motion.c). */
1688+ emcmotStatus -> atspeed_next_feed = emcmotCommand -> wait_for_spindle_at_speed ;
16591689 break ;
16601690
16611691 case EMCMOT_SPINDLE_ORIENT :
0 commit comments