M109 not returning?

  • Ok, so as I get things dialed in after my conversion from RAMPs, it's time to start cleaning up the little things.

    In my post print gcode scripts, I use M109 to set the hot end temp to 50c and hold until it reaches that point. Once it does, the next line of gcode is to set the temp to 0 via M104 and then finally a M81 to shut down the printer.

    What I am seeing is the firmware never returning after the M109, it stays at 50c indefinitely. I've checked my gcode and it appears fine, I see M109 is supported by reprapfirmware. M109 is used to heat up the hot end and then print afterwards, so I know M109 does return at least in that scenario. Is there a particular reason why using M109 for cool down before turning off power is hanging?

    I would expect that after the hot end reaches 50c, it would move on to the next line of gcode, then proceed on. But it appears to be waiting indefinitely at 50c, never proceeding on.

    Here's my post print gcode.

    M117 Print Complete. Finalizing job.
    ;M42 P4 S255
    ;M42 P5 S255
    ;M42 P6 S0
    M140 S0 ;heated bed heater off (if you have it)
    M104 T0 S0 ;extruder heater off
    G91 ;relative positioning
    G1 E-1 F300 ;retract the filament a bit before lifting the nozzle to release some of the pressure
    G1 Z+0.5 ; Move the head up a bit
    G28 X0 ; Moxe X to min
    G90 ;absolute positioning ; Move platform out
    M84 ;steppers off
    M109 T0 S50
    M104 T0 S0
    M81 ; Turn off the power supply
    M117 Printer Ready. ;{profile_string}
    ;M42 P4 S128
    ;M42 P5 S128
    ;M42 P6 S128

  • Ok, I figured it out.

    Marlin outputs the temps while M109 is heating up. Since I am using Octoprint to run my print jobs, it is timing out during the cool down because there is no output from the firmware until the temp is within a few degrees of the target, then M105 replies start coming back. Octoprint is assuming a timeout and dumping the connection, that leaves the last command received by the firmware the M109 and why none of the remaining gcode is run because Octoprint bailed.

    I tried putting M109 and M140 into long running commands, but the default time for is still too short. I can bump the timeouts way up to avoid the issue, and will for a short term fix.

    Is there any reason why the temp is not sent via the serial connection during M109?
    I found the following discussion, but I don't see that anything came of it. I could send a PR for the change if desired. It would be very useful to see the temp during heat up via the serial connection.


Log in to reply