Finding home

In view of my upcoming 3D printing talk at the Macoun Developer Conference in Frankfurt/Main in a few weeks, I thought that my Makerbot could use a little bit refurbishment.

Since a while it rattles a lot during printing, so at least I wanted to remove the X/Y stages from the bot, in order to clean the rods and to tighten all bolts.

I also wanted to find a better solution for the heated build platform’s cables. Until now, they somehow dangled in the back of the Makerbot on their way up to the extruder controller board.

After removing the X/Y stage from the bot, I saw another problem which needed to be solved:

Not only the acrylic build surface looks like reaching its end of life (it’s still the very first one, which came with the Makerbot kit more than a year ago), the main problem is that the whole platform has far too much play. Although my heated build platform is rather heavy (6mm aluminum + 3 big power resistors), I remember that this was also a problem with the original, unheated, wooden build platform.

I decided to bolt the aluminum plate directly to the Y stage with one central screw:

IMG_0813.JPG IMG_0814.JPG

In order to be able to easily remove the print stage, I got rid of the acrylic build platform (bolt to the aluminum plate before). Instead I tried three different “interface” sheets.

The first try was a aluminum cover for the build platform. I folded the cover out of .5mm aluminum sheet with Kapton tape as surface:

IMG_0817.jpg IMG_0821.jpg

To cut a long story short: It didn’t work. The cover wasn’t easy to install and remove from the build platform and it was impossible to get a good, leveled surface.

Next, I tried a piece of transparent LDPE. I had some leftovers of this from building the second filament box. I attached the LDPE with some foldback clips to the heated build platform.

It worked relatively well. However, the LDPE degenerates rather quick:

IMG_0863.JPG

Also I have the problem that there are only very few spots on the build platform where foldback clips can be used without blocking the build platform’s movement. Since LDPE heavily warps when heated, there just weren’t enough clips to hold it down to the flat aluminum.

Finally, I cut a sheet of thin glass (from a cheap picture frame) to 10x10cm. Like the aluminum sheet, I used Kapton tape as “interface” material for the ABS. So far, this build surface seems to work great. The glass is nicely flat and leveled and keeps it that way when heated. And two foldback clips are enough to securely attach the surface to the aluminum plate:

IMG_0859.JPG

Now, with the aluminum platform bolt down to the y stage, I was able to use a piece of ribbon cable to connect the cables from the platform with the x stage:

IMG_0824.JPG

There was a connector on one end of the ribbon cable (it used to be a part of an old PC’s RS232 access), I glued this end of the cable to the y stage. After soldering a compatible connector to the platform’s wires, I was able to connect the heated build platform in a way which allows easy removal if needed.

IMG_0823.JPG

Up until half way, I glued the ribbon cable to the x stage’s edge. Then the cable runs inside the drag spring from the x stage to the outside of the Makerbot. I already had the drag spring installed about a year ago to guide the y stepper motor’s and the y end stops’ cables.

Here’s a short video of the ribbon cable during a print:

It works great!

After playing around with my Mendel for a while, I very much like the autohoming feature of it’s firmware.

When I browsed the current Makerbot firmware, I was surprised to find support for automatic homing, ready to use. As far as I know, this code is currently not used by ReplicatorG, right?

Anyway, having endstops installed for the X and Y stage, it’s no problem to autohome these stages with the current firmware.

Just send the G-Codes G28, G161 or G162 with information on the axis to the Makerbot:

G28 is the “normal” ‘return to home’ G-code, also used by the RepRap firmware. However, in the Makerbot firmware, there are two more variants of the homing functions:

G161 is ‘home negative’, which means, that the respective stages are moved in direction of the MIN endstop until they reach the end of the line. Currently, G28 and G161 are exactly the same in the Makerbot firmware.

G162 is ‘home positive’, which means, that the respective stages are moved in direction of the MAX endstop until they reach the end of the line.

Concerning the X and Y stage, you might use either of them to bring the Makerbot into a “well known position”. If you have installed all four MIN/MAX endstops for the X&Y stages, that is.

In case you have only one endstop per axis you should call G161 for those axes with a MIN endstop and G162 for those axes with a MAX endstop.

My Makerbot, for example, has only one endstop per axis: MAX on the X axis, MIN on the Y and Z axes. So in order to home my Makerbot, I’d send

G162 X
G161 Y Z

The Z-axis endstop isn’t as easy to install as the X/Y endstops. Depending on the build platform and/or extruder or frostruder you’re using, the Z-axis endstop needs to be adjusted for the correct height.

Quite a while ago, I already tried some possible solutions on my Makerbot. Back then, I designed the Z-stage endstop trigger (my very first published thing on Thingiverse!). I also designed  a X-stage endstop trigger and an adjustable Z-stage endstop trigger. But since I wasn’t too happy with the results, I never published these.

IMG_4266.JPG

I always thought, that the best way to do homing of the z-stage would be a probe as near as possible to the nozzle, sensing the actual build surface.

I also did some test on this back a year ago, but again the results weren’t too promising:

IMG_4162.JPG

The main problem is, that the probe needs to be retractable during the print process. A year ago I tried to solve this with a manual retraction mechanism. But it didn’t work reliably. Also, adjusting the probe wasn’t very easy.

More than a year later, I learned a lot about electronics, microcontrollers and embedded systems programming…

So here’s what I came up with:

IMG_0846.JPG

The Z-Probe

This new design contains a standard endstop PCB and a needle-like sensing-probe. The head of the sensor is motorized retractable with help of a standard servo.

IMG_0852.JPG

The Z-Probe is designed to be mounted behind/under the extruder on the z-stage:

IMG_0855.JPG IMG_0856.JPG

That way, the Z-Probe is able to sense the build platform only 1-2 cm from the nossle.

The servo, lowering and rising the sense-pin, is controlled by the extruder controller board. There are two digital pins on the extruder controller board v2.2, currently unused on a Makerbot (D9 and D10).

These pins are ready to use with a servo. Just plug the servo connector to the 3 pins of D9. Make sure to put the black wire (GND) on the pin marked with “-”:

IMG_0865.JPG

Of course, some firmware/host software changes are needed in order to drive the Z-Probe.

The D9 and D10 pins are even PWM enabled. So usually it’s quite easy to add support for servos on an Arduino controller.

Unfortunately, since v2 of the extruder controller firmware Adam from Makerbot Inc. decided to move away from the Arduino IDE and API. The firmware is now “native AVR”, i.e. no more access to the Arduino libraries. Of course, there are several valid reasons to abandon the Arduino IDE, especially when projects grow and get more complex. But this also makes it harder  to “hack” the software.

What’s even worse: The current firmware already uses the hardware timer of the ATMega, which ususally drives the PWM pins D9 and D10. So I needed quite a while to understand how to solve these problems.

I think, I’ve found a way to solve the problem with the timer. The current firmware uses this timer for a general software interrupt routine. So I hooked the servo driver for the z-probe into the same interrupt routine.  So the servo PWM signal now is created by the CPU in software (and not by the hardware PWM driver). I tried some other ways around this timer conflict, but this was the only way both, the servo and the rest of the firmware, are working. I guess it’s not the best idea to mess around with one of the firmware’s central timers…

After solving these problems, I was able to extend the firmware with a new class “ZProbe”. This class handles the lowering and raising of the ZProbe hardware.

The upper and lower positions of the ZProbe are configurable in the extruder’s EEPROM preferences (well, they will be, as soon as I’ll find the bug which currently prevents the firmware to write new values to the preferences…).

In order to control the Z-Probe from within Replicator-G and -even more important- from within G-Code files, I added some new “M-Codes” to the GCode-Parser: M140, M141 and M142

M140 “Engage Z-Probe”: This M-Code lowers the Z-Probe into working position.

M141 “Disengage Z-Probe”: This M-Code raises the Z-Probe into parking position.

M142 “Adjust Z-Proble Angle”: This M-Code takes a S argument and moves the Z-Probe’s servo int the given angle (e.g. M142 S45 moves the servo to 45°). This code is intended for internal use only.

One thing to keep in mind is, that the zeroed Z-stage with engaged Z-Probe mustn’t be moved in X or Y direction. Since the Z-Probe pin touches the build surface in this case, moving the build platform could cause scratches in the build surface or -worse- damage of the Z-Probe itself. So always either disengage the Z-Probe or raise the Z-stage a little before moving the X/Y stage.

Here’s the G-Code for a complete autohome sequence on a Z-Probe equipped Makerbot:

G21 (Metric FTW)
G91 (relative positioning)
G0 Z7.0 (move up the z-stage for security)
M141 (Disengage Z-Probe)
G90 (Absolute Positioning)
G162 X (home positive)
G161 Y (home negative)
G92 X0 Y0 (Reset reference position)
G0 X-55.0 Y20.0 (Center ** Z-Probe-Pin **)
G92 X0 Y-25 (Reset reference position)
M140 (Engage Z-Probe)
G161 Z F500 (home negative [fast])
G92 Z0 (Reset reference position)
G0 Z2.0 (Back up z-stage 2mm)
G161 Z F25 (home negative [slow])
G92 Z0 (Reset reference position)
M141 (Disengage Z-Probe)
G1 F150 (Reset Z-speed)
G0 Z1 (backup Z for Y move)
G0 Y0 (center Y *** Nozzle ***)
G0 Z0 (return Z to zero)

Of course, this G-Code would need to be adjusted if the Makerbot has an other endstop configuration than mine. Also the ‘move to center’ distance is likely different on each Makerbot.

Here’s a video, showing my Makerbot while running the above G-Code:

As you can see, the Z-Probe just works, even if the height of the build platform was changed. No manual adjustmens needed. This is not only a nice feature for operators using differnt types of build platforms or surfaces, it also might be quite useful for people using the brand new Automated Build Platform.

You want?

First and frontmost: This is all still in a very early stage, both hardware and software.

I released the printable parts for the Z-Probe on Thingiverse: http://www.thingiverse.com/thing:4093

The design is for use with a Futaba servo S148. That’s the servo I found in my junk box. I guess each servo has a different size. So the design might be more a draft for your own design. I plan to try the same thing with a smaller (and cheaper) “micro servo” in the future. I hope I’ll find the time to create a parametric OpenSCAD design until then.

Since it’s still a prototype, the servo is currently glued to the base plate with some hot glue.

Both, the new extruder firmware as well as the extended ReplicatorG host software, are available on GitHub. I forked both projects from Makerbot:

G3Firmware: http://github.com/zaggo/G3Firmware

ReplicatorG: http://github.com/zaggo/ReplicatorG (ZProbe branch)

Please remember: This is all beta (at best). As mentioned above there’s still a known bug with saving the Z-Probes EEPROM settings.

Feel free to improve!

One comment

  1. Hello Zaggo, I was interning this summer at Makerbot industries and I’ve developed something (as my intern project) you might like.

    Makerbot firmware: git://github.com/xtremd/Xtremd.git
    Modified ReplicatorG: git://github.com/xtremd/ReplicatorG.git

    It’s a completely automated, in firmware homing function called by one Gcode at the beginning of the print. M139. The user just has to set his/her XY and Z in the 0,0,0 position once and click a button in the ReplicatorG control panel that does a automatic orchestrated homing function which saves the distances from the endstops in Eeprom memory. The Gcode M139 homes to endstops (taking care not to hit anything along the way) and then moves back to the 0,0,0 location saved in Eeprom. I wish I had a video of how all this works, but I don’t have a makerbot at this time.

    I was thinking, this weekend I want to make some code changes to my homing script to add support for odd endstop configurations like yours (right now it only homes to all positive, or all negative). Would you be interested in allowing me to try and see if I can add support for your servo (from your code)? I think it would make alot of Mb operators happy if they had one Gcode homing support that also allowed them to quick swap build platforms. (That retractable Z-Probe looks awesome!)

    Just shoot me an email at mr.servergeek@gmail.com and congrats on getting a retractable Z-probe working!

    -Xtremd

    Ps: Here is my code commands for writing to eeprom memory that I used in my firmware.
    Committing a 32 bit int into EEPROM at location offset:
    eeprom_write_block((const void*)&dataa, (void*)offset, 4);

    Reading a 32bit int: eeprom_read_block((void*)&dataa, (const void*)offset, 4);

    (\_/)
    ( ^ ^) <)
    | | |
    (_(_)

Leave a Reply