Program End Script - Estlcam

In estlcam, you can edit the “program end” text, which defines what the machine does once the program has ended. This is where I use the command M107, which turns off the pin for my spindle relay. This happens after the last toolpath has been complete and by default Estlcam raises the Z axis and returns the X and Y axes back to the origin point… and then runs the “program end” script. My issue is that when the toolpaths are done, it returns to the origin and the the spindle turns off and the program ends. When the program ends, the motors disengage allowing the spindle to fall down slowly to the workpiece. With the spindle still spinning a bit after it is turned off, it cuts slightly into the workpiece.

.
.
G01 X0.2012 Y-53.0919 F1270
G01 X77.6215 Y-76.2000 F1270
G00 Z5.0000 F480
G00 X0.0000 Y0.0000 F2100
M107
M300
M30

My wish would be to move the M107 and put it between the raising of the Z axis and the return X0 and Y0. This way, the spindle will have time to stop turning as it travels back to O,O.

Is there anyway to make this happen?

I don’t see what in your program is disengaging the steppers. My stepper remain engaged. You may just have a short stepper inactivity timeout , or there may be more code that is executed at the end of script that you did not post. If it a stepper timeout issue, you can set the timeout using an M18.

M18 S60  

This will keep your steppers engaged for 60 seconds after they stop moving. You can put anywhere in your script including your program end text.

If there is more g-code being executed that explicitly turns steppers off, you can use an M0 to pause the script for a specific amount of time.

M0 S30 Pausing for 30 seconds

This would be inserted after your M107.

Edit: I just checked the firmware. In configuration_Adv.h in the V1 maintained firmware, there is this line:

#define DEFAULT_STEPPER_DEACTIVE_TIME 1200

I assume the units are seconds, so by default, the steppers should remain engaged for 20 minutes. If your firmware is based on a version of V1 maintained firmware, then your script is explicitly turning off your steppers.

Here is my program end script. It says M30 is program end, which i believe disengages all axis motors. Correct?

image

I don’t know. According to the Marlin g-code reference, M30 deletes a SD file, but maybe without parameters it disengages the steppers. It would be very easy to test. If it is the command that is disengaging steppers you can either 1) remove it and let the inactivity timeout determine when the steppers are disengaged, or 2) you can use the M0 to pause before this command is executed.

I like the idea of using the M0 command! This way the program does not technically end until I press the button on the screen.

That is probably what I will do, thanks! I will update this thread to confirm this solution.

I took a look at the Marlin source and did some internet searches on the M30 g-code. On other machines/firmwares, it is a program end command, but in Marlin it is clearly used to delete an SD file. Here is the code:

void GcodeSuite::M30() {
  if (card.isMounted()) {
    card.closefile();
    card.removeFile(parser.string_arg);
  }
}

Even if the M0 works, I suspect the steppers are being disengaged by an M18 being delivered to your machine somewhere else. Note that the program you use to deliver your g-code to the machine can also insert commands at the end that will not appear in your g-code file. For example there is a separate end text area in Repetier-Host.

Interesting.

image

This is the end of the gcode on all my programs. No where is there any M18 command.

But how are you sending your g-code to your machine? As I said, there is an end text section on Repetier-Host that can deliver “extra” commands that will not appear in your file. And if the issue is an inactivity timeout, that M18 command can be anywhere in the file, not just at the end. Or it is possible that the M30 is generating some kind of error that is causing things to shut down, though I would expect to see an error message.

This screenshot is from Repetier-Host. I generate the gcode from Estlcam, then load it into Repetier-Host. I hit “Print” to begin the program. Is there some setting in Repetier-Host that implements an M18 command when the program finishes without it actually existing in the gcode?

The screenshot i mention is from my previous reply

In Repetier-Host, go to Config/Printer Setting. Select the Scripts tab. Select “End Code” from the “Script:” dropdown. This code will be inserted after your g-code file is executed.

Either the M0 or the M18 inactivity timeout will solve your problem, but it would be good to know that is shutting down your steppers.

image

I think I found the culprit. Perhaps I should uncheck this box?

2 Likes

Yes, you can uncheck that box. Now that I think about it, this was the issue in another topic on the forum. Also you should remove the M30 from your EstlCAM end code.

2 Likes

Thanks for the help, Ill test it out sometime and report back

1 Like