Makergear M2: Slic3r Start and End G-Code Routines

Being that type of guy, my Start and End G-Code routines are somewhat more elaborate than usual…

The Start routine handles homing, which is more dangerous than you might think, and wiping the drool off the nozzle:

;-- Slic3r Start G-Code for M2 starts --
;  Ed Nisley KE4NZU - March 2013
M140 S[first_layer_bed_temperature]	; start bed heating
G90				; absolute coordinates
G21				; millimeters
M83				; relative extrusion distance
M84				; disable stepper current
G4 S3			; allow Z stage to freefall to the floor
G28 X0			; home X
G92 X-95		; set origin to 0 = center of plate
G1 X0 F30000    ; origin = clear clamps on Y
G28 Y0			; home Y
G92 Y-125		; set origin to 0 = center of plate
G1 Y-122 F30000    ; set up for prime near front edge
G28 Z0			; home Z
G92 Z1.0		; set origin to measured z offset
M190 S[first_layer_bed_temperature]	; wait for bed to finish heating
M109 S[first_layer_temperature]		; set extruder temperature and wait
G1 Z0.0 F2500	; plug extruder on plate
G1 E10 F300		; prime to get pressure
G1 Z5 F2500		; rise above blob
G1 Y-115 F30000	; move away
G1 Z0.0 F2500	; dab nozzle to remove outer snot
G4 P1			; pause to clear
G1 Z0.1			; clear bed for travel
;-- Slic3r Start G-Code ends --

The fundamental problem with homing is that you don’t know where the nozzle stands in relation to the build platform and the bulldog clips clamping the glass plate to the aluminum heater. If you simply home X and Y with Z unchanged, you will eventually plow the nozzle directly across a clip. Trust me on this, you do not want to do that.

So Line 7 disables the stepper motors. In an ideal world, the Z axis stage would then free-fall to the bottom of the chassis during the 4 second pause produced by the G4 S3 instruction. In the real world, that works most of the time, but the platform sometimes sticks where it is. You don’t want to home the Z axis to the top of its travel, because that will eventually crunch the nozzle into those clips, so I plan to add a bottom limit switch so I can drive the platform to a known location away from everything else.

The default M2 Start G-Code puts the XY origin at the front left side of the platform, following the RepRap convention. Maybe it’s just me, but having the origin in the middle of the platform makes more sense for my objects; most of my OpenSCAD models are more-or-less symmetric, so putting the XY origin at their center works well. Ultimately, it doesn’t matter as long as you’re consistent, but my Start G-Code doesn’t produce the same results as the Makergear setup.

Line 9 homes the X axis and Line 10 sets the coordinate to -95. The X axis home position is about 5 mm from the left edge of the glass plate, so the nozzle has about 195 mm of travel to the right edge of the 200 mm plate. The X=0 origin will be in the middle of the printable range, with -95 mm to the left limit (the home position) and +95 to the right edge; the nozzle can travel another 30 mm beyond the right edge to about +125. Line 11 puts the nozzle in the middle of its travel at X=0.

Line 12 homes the Y axis and Line 13 sets the coordinate to -125. The Y axis home position is almost exactly on the front edge of the 250 mm glass plate, so the Y=0 origin is centered on the plate. The nozzle can travel an additional 10 mm off the rear edge of the plate. Note that you must position the nozzle somewhere on the X axis that avoids the bulldog clips; any of X=±95 or X=0 will work. Line 14 puts the nozzle in the middle of the plate at Y=0; it’s already at X=0, so the plate is now centered.

Line 15 homes the Z axis. I’ve set the limit switch so that the home position leaves exactly 1.0 mm between the nozzle and the glass plate, which I find easier to measure than the Makergear suggestion of 0.1 mm. Of course, that’s because I have a Starret taper gauge in my tool cabinet. Use what you have, but use it consistently.

Line 16 sets the Z axis coordinate position to +1.0 mm, matching the measured height, so that Z=0 corresponds to the nozzle exactly kissing the glass plate. The Makergear defaults put Z=0 about 0.1 mm above the platform; I’d rather apply model- and material-dependent offsets to “natural” machine positions.

All of that ignores Z axis backlash. Some preliminary guesstimates put that around 0.1 mm, far better than my Sherline, but still large with respect to the layer thickness. I need more measurements of that, plus some measurements of the actual glass flatness. I think the glass bows upward by about 0.1 mm in the middle, but that requires better probing that will be easier under LinuxCNC control where I can do automated platform mapping.

With the nozzle parked 1.0 mm over the platform, the next two lines wait for everything to reach the proper temperature. I preheat the platform and crank up the extruder temperature before starting the program , so these steps don’t take too long.

However, the nozzle cools off as the drool contacts the much colder platform (it’s heated to 70 °C, but that’s cooler than 150-ish °C by a considerable margin) and the PID loop struggles to reheat it. I think that’s due to the default I term being only 0.1, which reduces integral windup during preheating, but also slows recovery from a sudden thermal load. It helps to preheat the nozzle about 10 °C over the desired temperature, then let it cool during this step.

M2 - Wipe blobs on glass platform

M2 – Wipe blobs on glass platform

Line 19 uses Nophead’s trick (which I cannot find now) of planting the nozzle on the plate at Z=0.0 to reduce drool, although I do that after the nozzle reaches extruding temperature. The drool forms a blob on the platform as the nozzle heats, but the nozzle punches directly through it on the way to Z=0.0.

Line 20 runs 10 mm of filament into the hot end to pressurize the extruder. Some of the molten goo oozes out around the nozzle, enlarging the blob on the glass plate. The object of the game is to leave all that behind: having a generous contact patch on the glass helps.

The larger blob on the left of the picture (at Y=-125) comes from that process.

Line 21 starts the wiping dance:

  • Raise the nozzle above the blob to Z=5 mm
  • Move away from the blob by 5 mm. I’ll probably change this to move in the +X direction.
  • Tap the nozzle on the platform, so (almost all of) the molten PLA slides away from the orifice
  • Get 0.1 mm of clearance from the platform, directly over the new blob
  • Scoot off to print a Skirt extrusion around the object

The smaller, rather flat, blob on the right comes from the nozzle tap. A thin hair may stretch from the blob to the start of the skirt, but it doesn’t amount to much.

Sometimes, of course, the blobs don’t adhere to the glass plate and accompany the nozzle to the start of the skirt. By the conservation of perversity, that’s also when the skirt starts on the far side of the origin, so the blob smears all over the object’s first layers. The Makergear wipe process extrudes the waste filament over the side of the plate, then shears it off as the nozzle returns to the surface; I’ll try blending that in with my startup sequence at some point.

My slic3r configuration extrudes at least 15 mm of filament into the skirt, giving the extruder plenty of time to reach a steady state before starting the actual object. Generally that’s far more than enough filament, but sometimes … well, it’s a good idea to watch what’s going on.

On the other end of the printing process, the End G-Code routine handles shutdown with the object on the platform:

;-- Slic3r End G-Code for M2 starts --
;  Ed Nisley KE4NZU - March 2013
M104 S0		; drop extruder temperature
M140 S0		; drop bed temperature
M106 S0		; bed fan off
G1 Z195	F2500	; lower bed
G1 X0 Y0 F30000	; center nozzle
M84     	; disable motors
;-- Slic3r End G-Code ends --

Line 3 begins turning the heaters and bed fan off. I’ve unplugged the fan for now, so Line 5 is just for completeness.

Line 6 lowers the bed to the bottom under power, because that’s faster that a free fall and it’s guaranteed to work.

With the object safely out of the way, Line 7 centers the nozzle over the platform.

Finally, Line 8 turns off the steppers off; the platform drops another few millimeters

Then everything cools down. Because I run the platform at well above PLA’s glass transition temperature, it must cool for quite a while until the object stiffens up.



  1. #1 by Jason Doege on 2013-04-14 - 14:19

    I think you might have had something like this on your Thing-o-matic: does it make sense to mount a wiper made out of some high temperature but flexible material just off the build plate? Maybe make it like an ink-jet printer: go off the build plate and squirt out a bit of material to get things moving and normalized, pass over the wiper and then go start printing the skirt.

    • #2 by Ed on 2013-04-14 - 14:28

      go off the build plate and squirt

      That’s what the default M2 Start G-Code does: moves the nozzle far off the platform, squirts, then comes back across the glass plate at Z=0 to shear off the strand. It makes a good deal of sense, although not with the thing sitting on my desk in the living room… [grin]

      pass over the wiper

      Part of that gets wrapped up in the idea of multiple extruders: the wiper can’t be on the platform near Z=0, because the nozzle can’t reach it after the first few layers. Maybe it must be a part of the extruder mechanism(s)? More pondering required!

  2. #3 by Adrian Carter (@OzAdr1an) on 2013-04-15 - 08:29

    I do similar with my Solidoodle3, but use G1 E7 to extrude an anchor just on the very edge of the build plate… it tends to pool over the side and be removed from the nozzle 99% of the time…

    • #4 by Ed on 2013-04-15 - 09:00

      pool over the side

      I like that!

      The nozzle just barely clears the edge, so moving the blob that way should anchor it to the side of the plate.


  3. #5 by Jason Doege on 2013-04-15 - 09:15

    BTW, this: looks like it might be an interesting board for 3d-Printer control.

    • #6 by Ed on 2013-04-15 - 10:11

      an interesting board for 3d-Printer control

      The requirements for real time control seem to be pretty much directly opposed to the requirements for cheap hardware, particularly for system-on-a-chip architectures. Plenty of gotchas lie in wait for the unwary…

      Plus, it’s dramatically easier to lash hardware together than to get hard real time software running on it. RTAI is still testing patches for the Linux 3.x kernel series, so they could use some help, too.

      None of which will stop somebody from dropping a motor driver board atop that thing! [grin]

      • #7 by Jason Doege on 2013-04-15 - 11:41

        It seems like the limitations are mostly in the OS, not the hardware, so much. Isn’t there an RTLinux out there? I wonder if someone has ported that to the Arm platform, yet.

        • #8 by Ed on 2013-04-15 - 13:13

          Isn’t there an RTLinux out there?

          According to Wikipedia, Wind River borged RTLabs, then shut it down, so RTLinux is no more. I vaguely recall a patent kefuffle inside the hypervisor that caused RTAI / Xenomai / Adeos to spring into existence…

          RTAI actually has several architectural ports: you could pick the ARM flavor and see where it takes you. [grin]

  1. Makergear M2: Z-minimum Switch | The Smell of Molten Projects in the Morning