The G-Code in start.gcode homes all three axes, but now I have two limit switches on the Z axis: the MBI Z-Maximum at the top and a new Z-Minimum on the platform. The Z axis platform can’t miss the switch at the top, but I must position the nozzle directly over the Z-Minimum switch on the platform before probing for it. Homing the stage at the top of the Z axis makes sure the nozzle starts more-or-less at the right height over the switch, which then provides an exact adjustment.
For the home switches on my Sherline CNC milling machine, the EMC2 homing routines proceed in two stages: a fast slew to find the switch, then a slow approach to ensure the axis doesn’t overrun the switch. That seemed like a good way to ensure that the X and Y stages would home repeatably enough to hit a 2 mm button with a 1 mm nozzle every time.
I recycled the default home sequence for coarse homing, albeit with the speeds cranked up a bit:
(- coarse home axes -) G162 Z F1000 (home Z to get nozzle out of danger zone) G161 Y F4000 (retract Y to get X out of front opening) G161 X F4000 (now safe to home X) G92 X-53.0 Y-59.0 Z117.0 (set XYZ coordinate zeros)
Then the fine homing sequence backs off a few millimeters and bumps the switches very slowly:
(- fine home axes) G0 X-51 Y-57 Z115 F400 (back off switches) G161 Y F200 G161 X F200 G162 Z F200 G92 X-53.0 Y-59.0 Z117.0 (re-set XYZ coordinate zeros)
You could set relative motion mode with G91; that might be cleaner all around.
I discovered experimentally that you must set all three axes in the G92 command, because any missing axes get set to 0.0: probably not what you want. It’s not what I expected, either, but this isn’t the EMC2 G-Code dialect I’m more familiar with.
In normal use, the extruder has been heating for quite a while and there’s no pressure inside. There’s most likely a long strand of filament hanging off the end that will interfere with the switch, so a preliminary wipe is in order. I first pause the nozzle over the middle of the platform as a visual indication that everything started up OK, then make a dogleg around the wiper blade to the front of the wipe station:
(- manual nozzle wipe) G0 X0 Y0 Z10 (pause at center to build confidence) G4 P500 G0 X40 Y-57.0 Z10 (move to front, avoid wiper blade) G0 X56 (to wipe station) G0 Z6.0 (down to wipe level) M6 T0 (wait for temperature settling) G1 Y-40 F1000 (slowly wipe nozzle)
With the dry wipe done, move to the Z-Min switch and poke it very very slowly:
(- home Z downward to platform switch) G0 X55.9 Y8 Z3 (get over build platform switch) G161 Z0 F50 (home downward very slowly) G92 X55.7 Y8 Z1.45 (set Z for actual switch trip height) G0 Z6.0 (back off switch to wipe level)
I had to determine the actual height of the trip point experimentally, by doing some test extrusions and adjusting that Z1.45 to make the answer come out right. I’m sure that will change as things settle into their final places.
Ditto for the exact XY location of the Z-Min switch, which I found by using a very slow G1 move to Z2.0 in place of the G161 probe.
Note that you increase the Z value in G92 to lower the initial nozzle position and vice versa. It helps to draw some diagrams and work through the whole thing to be sure you understand it; that’s what I had to do, anyway.
Then return the nozzle to the wipe station by running over the blade again to dislodge any gunk on the front side, crank up the extruder to build up pressure, and wipe again to get rid of the snot ball:
(- start extruder and re-wipe) G0 X56 Y-40 (set up for wipe from rear) G1 Y-57.0 F1000 (wipe to front) M108 R2.0 (set stepper extruder speed) M101 (Extruder on, forward) G4 P4000 (take up slack, get pressure) M103 (Extruder off) G4 P4000 (Wait for filament to stop oozing) G1 Y-40 F1000 (slowly wipe nozzle again) G0 X0 (get away from wiper blade)
Running the extruder here ensures that, no matter what, the molten ABS in the hot end begins the print in a consistent state every time. The extruded length varies from a few millimeters to a real string, so there’s obviously plenty of variation.
Then I put a manual splodge turd at the middle of the front edge of the platform. This is unnecessary now that SF40 shuts off the extruder before zipping off to the first Skirt, so I’ll probably junk it in the near future:
(- manual splodge) G0 X0 Y-58 (to front center) G0 Z0.5 (just over surface) M108 R2.0 (set stepper extruder speed) M101 (start extruder) G4 P2000 (build up a turd)
Putting all that together with some odds & ends gives the complete current version of start.gcode:
(---- start.gcode begins ----) (MakerBot Thing-O-Matic with aluminum HBP and Z-min platform switch) (Tweaked for TOM 286 - Ruttmeister MK5 stepper extruder mod) (Ed Nisley - KE4ZNU - May 2011) (- set initial conditions -) G21 (set units to mm) G90 (set positioning to absolute) (- begin heating -) M104 S210 T0 (extruder head) M109 S120 T0 (HBP) (- coarse home axes -) G162 Z F1000 (home Z to get nozzle out of danger zone) G161 Y F4000 (retract Y to get X out of front opening) G161 X F4000 (now safe to home X) G92 X-53.0 Y-59.0 Z117.0 (set XYZ coordinate zeros) (- fine home axes) G0 X-51 Y-57 Z115 F400 (back off switches) G161 Y F200 G161 X F200 G162 Z F200 G92 X-53.0 Y-59.0 Z117.0 (re-set XYZ coordinate zeros) (- manual nozzle wipe) G0 X0 Y0 Z10 (pause at center to build confidence) G4 P500 G0 X40 Y-57.0 Z10 (move to front, avoid wiper blade) G0 X56 (to wipe station) G0 Z6.0 (down to wipe level) M6 T0 (wait for temperature settling) G1 Y-40 F1000 (slowly wipe nozzle) (- home Z downward to platform switch) G0 X55.9 Y8 Z3 (get over build platform switch) G161 Z0 F50 (home downward very slowly) G92 X55.7 Y8 Z1.45 (set Z for actual switch trip height) G0 Z6.0 (back off switch to wipe level) (- start extruder and re-wipe) G0 X56 Y-40 (set up for wipe from rear) G1 Y-57.0 F1000 (wipe to front) M108 R2.0 (set stepper extruder speed) M101 (Extruder on, forward) G4 P4000 (take up slack, get pressure) M103 (Extruder off) G4 P4000 (Wait for filament to stop oozing) G1 Y-40 F1000 (slowly wipe nozzle again) G0 X0 (get away from wiper blade) (- manual splodge) G0 X0 Y-58 (to front center) G0 Z0.5 (just over surface) M108 R2.0 (set stepper extruder speed) M101 (start extruder) G4 P2000 (build up a turd) (---- start.gcode ends ----)
Then I did a bunch of measurements to see how it worked…
Comments
5 responses to “Thing-O-Matic: Z-Minimum Probe G-Code”
Have enjoyed reading your Z-min probe development. Thanks.
I have enjoyed the piece of mind of having 6 endstop switches on my CNC machine, and a sacrificial surface holding my item. The thought that I could plow the extruder head through the heated surface of my TOM with a simple Gcode mistake has given me some anxiety.
My current plan is to put a slat like a wooden ruler across the back window of the TOM, about 50mm from the bottom.
A Z-min endstop switch on this slat would be hit by the wooden base of the Z-platform, just as the top of the Z-platform now hits the Z-max endstop.
Just waiting for my MakerBot aluminium top to arrive.
There’s really not that much human-generated G-Code involved, which eliminates almost all the opportunities for me to screw something up…
Not that I don’t make the occasional error, particularly on the Sherline. I just replaced the tool height switch after ramming it with a probe rod while doing some manual CNC work…
I’d be tempted to mount the switch on a clamp attached to a Z rod, so the stage would squat on it and it wouldn’t take up any room elsewhere. Put it a micro-smidgen lower than the height switch on the platform to allow that one to work, but driving the Z stage “below zero” would trip it almost immediately.
You’ll like it a lot!
Almost all of the limit switches on the various cnc machines around my work operate with a fast approach to trip, then slow reversal until contact is broken. It at least removes one step from what you’re describing, though it would probably require a change in the firmware. I’ve also heard that microswitches can be/are more consistent when read in that fashion, though I don’t know how true that is.
The one exception is a large and ancient Toyoda VMC that has center limit switches as well and therefore knows when to slow down, thats a very bad idea if you forget to move it past the center limit switches before homing, don’t ask me how I know this.
I’ve been hoping somebody would make that change in the firmware so that we don’t have to home so slowly, it would probably also increase accuracy and eliminate problems when starting homing with one or more axis already triggering its limit.
Doesn’t everything? [sigh]
EMC2 can handle all those different patterns, but on the Sherline I home downward to remove the Z axis backlash. I set the workpiece zero by lowering the head, so doing the same thing at the switch puts the backlash on the proper side.
On the TOM, homing downward gives the correct result for the first printed layer, but the second layer requires an upward move. I’ll have more to say about that in a bit, but the first layer is so critical that I think it’s worthwhile.
I think the motors stop quickly enough that there’s not much overtravel at any reasonable speed. That’d be an interesting thing to measure, wouldn’t it?
I went to double-tap fast/slow homing, doing one axis at a time, to eliminate all the possible sources of confusion. It works very well: the nozzle hits dead center on the switch button every time.
[…] exactly this position it would be nice to set only the Z height to the actual switch thickness, but G92 sets all un-mentioned axes to zero, so you can’t set just one axis. I have no idea how M131 and M132 behaves in that regard; […]