grbl is a wonderful piece of software. One of the issues that lacks solution is the delay control when, instead of using the typical CNC spindle, one uses a servo to control a pen plotter. Here's a simple hack: download grbl, look for the gcode.c file and locate the following part:

// [4. Set spindle speed ]:
  if ((gc_state.spindle_speed != gc_block.values.s) || bit_istrue(gc_parser_flags,GC_PARSER_LASER_FORCE_SYNC)) {
    if (gc_state.modal.spindle != SPINDLE_DISABLE) {
      #ifdef VARIABLE_SPINDLE
        if (bit_isfalse(gc_parser_flags,GC_PARSER_LASER_ISMOTION)) {
          if (bit_istrue(gc_parser_flags,GC_PARSER_LASER_DISABLE)) {
             spindle_sync(gc_state.modal.spindle, 0.0);
          } else { spindle_sync(gc_state.modal.spindle, gc_block.values.s); }
        }
      #else
        spindle_sync(gc_state.modal.spindle, 0.0);
      #endif
    }
    gc_state.spindle_speed = gc_block.values.s; // Update spindle speed state.
  }

add the following line mc_dwell(0.2); (see below).

// [4. Set spindle speed ]:
  if ((gc_state.spindle_speed != gc_block.values.s) || bit_istrue(gc_parser_flags,GC_PARSER_LASER_FORCE_SYNC)) {
    if (gc_state.modal.spindle != SPINDLE_DISABLE) {
      #ifdef VARIABLE_SPINDLE
        if (bit_isfalse(gc_parser_flags,GC_PARSER_LASER_ISMOTION)) {
          if (bit_istrue(gc_parser_flags,GC_PARSER_LASER_DISABLE)) {
             spindle_sync(gc_state.modal.spindle, 0.0);
          } else { spindle_sync(gc_state.modal.spindle, gc_block.values.s); }
        }
      #else
        spindle_sync(gc_state.modal.spindle, 0.0);
      #endif
    }
    gc_state.spindle_speed = gc_block.values.s; // Update spindle speed state.

    mc_dwell(0.2); // add this line to set delay for servo motion (in mseconds !?)
  }

Compile the code and upload it. That's it.

Happy hacking!

P.S.

I'm using this spindle_control.c. Servo is controlled by M3 Sx where x take the values 0-255.

Created: 13-04-2022 [16:49]

Last updated: 23-01-2025 [00:04]


For attribution, please cite this page as:

Charters, T., "How to add a delay control to a pen plotter running grbl": https://nexp.pt/GRBLServoDelay.html (23-01-2025 [00:04])


(cc-by-sa) Tiago Charters - tiagocharters@nexp.pt