hits counter

Auto bed-leveling for the Makerfarm Prusa i3 - Part 2: Setting up Marlin

(I’m assuming that you have already downloaded and set up the current version of Marlin to work with your printer.  This post is ONLY about getting the auto bed-leveling functions active.  If you need help getting Marlin ready, check out this post: Upgrading the Makerfarm Prusa i3 to a new version of Marlin)

 

There are only a very few modifications that need to be made in the current version of the Marlin firmware in order to get the auto bed-leveling functions active.

First, find the section of the configuration.h file that is labeled:

Bed Auto Leveling

Just above this, you’ll see this:

#define min_software_endstops true // If true, axis won't move to coordinates less than HOME_POS.

Later on, we’ll need this to be defined as false, so go ahead and change it now.

Just under the Bed Auto Leveling header, you’ll find the following line, commented out:

//#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (remove // at the start of the line)

Uncomment this line and congratulations, you’ve enabled Auto-leveling!

Oh, you want it to work? Well, in that case, there are a couple more things you’ll need to do.

A few lines further down, there are a few more #defines, having to do with probe offsets:

#define X_PROBE_OFFSET_FROM_EXTRUDER -25
#define Y_PROBE_OFFSET_FROM_EXTRUDER -29
#define Z_PROBE_OFFSET_FROM_EXTRUDER -12.35

For now, just note where these are, but don’t worry too much about them. There is no good way to even fake these values, they have to be measured, which we’ll be doing a little later.

The X-Y travel speed is set fairly high, at 8000 mm/minute by default.  In order to avoid any issues with skipping steps, I recommend setting this value to something smaller.  Some people have good luck with 6000, but I’ve got mine all the way down to 4000, just in case.  I figure I save so much time by having this feature enabled that I’m willing to give up a couple of seconds per print just to make sure everything is working right.

#define XY_TRAVEL_SPEED 8000         // X and Y axis travel speed between probes, in mm/min

Now scroll down a few more sections. Near the bottom, you’ll find a section labeled:

R/C Servo support

Uncomment the following lines:

//#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command

//#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1
//#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles

Quick and dirty, that’s all you need to do.  There are a few more things left to do before it works, of course, but that’s for part 3.

Here’s a video showing what we just did:

16 comments to Auto bed-leveling for the Makerfarm Prusa i3 – Part 2: Setting up Marlin

  • Jordan

    Hello, I’ve been following your videos on how to set up the bed leveling and have ran into a wall. When I use the m280 command to begin configuring my probe, the arm will extend but then it looks like a drop in voltage across my printer. The LCD will dim and will cause the printer to disconnect from my computer almost as if it is being reset but not fully. Do you think this is a software or hardware issue? I made sure the jumper and servo was placed on the RAMPS board correctly so I’m pretty stuck as to what could be the issue. Besides what you posted about converting the Marlin software in a previous post, are there any other major changes that I should look out for?

    • I think we may have talked about this via email, but just in case, and in case anyone else runs into this: Your servo may be too power-hungry for the on-board RAMPS power supply. Try removing the jumper, and pulling 5v from an external power supply. Your ATX should have a 5v line, but in any case, a LM7805 voltage regulator (cheap and plentiful) wired in-line would be a good idea.

  • Mortorojo

    Have you posted the part 3 for this? As I cant seem to find it.

    • That’s weird, I wrote it up, and thought I published it here, but now I can’t even find the draft. I’m not sure what happened there. I’ll put up a post with the video in it for now. Thanks for pointing that out.

  • TAZ427

    A quick comment here. It looks like there was at least an extra change in the most recent SW release (as of at least 2/26/2014 – v1)

    Thee following variables have been replaced.

    MakerFarms:
    // The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
    const bool X_ENDSTOPS_INVERTING = false; // set to true to invert the logic of the endstops.
    const bool Y_ENDSTOPS_INVERTING = false; // set to true to invert the logic of the endstops.
    const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of the endstops.
    //#define DISABLE_MAX_ENDSTOPS

    with

    Marlins:
    // The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
    const bool X_MIN_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop.
    const bool Y_MIN_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop.
    const bool Z_MIN_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop.
    const bool X_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop.
    const bool Y_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop.
    const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop.
    //#define DISABLE_MAX_ENDSTOPS
    //#define DISABLE_MIN_ENDSTOPS

    and of course you want to set all these to false.

  • Rawb

    So, after doing all of the changes how do I go about flashing the edited version of Marlin to my printer?

    • I know this is going to sound way harsher than I want it to, but the fact that you’re asking that question makes me think you may well be in over your head. Before you should even be thinking about flashing anything to your printer, you’ll want to have set up and tested the Arduino IDE, and become familiar with how it works. There is some great documentation on the Arduino site, and lots of resources out there in the community.
      Any time you’re flashing firmware, there is a possibility you could get yourself into serious trouble, in which it may even look like you’ve fried all of your equipment. Most of the time it’s recoverable, but good knowledge and research will keep you out of that situation to begin with, and also help you get out of it is something does go awry.
      Again, I really don’t mean to sound harsh, but there is a basic level of knowledge and skill that one should have (and can easily get) before getting into this kind of project.

  • Rawb

    Zenn, Dont worry Im not offended. Regarding the “software” side of things, yes one could say that I have gotten in a little over my head. Everything else I am extremely comfortable with. As for now, I have not messed with anything for the simple fear of frying something. Colin from Maker Farm has been very patient with my multitude of questions and has walked me through most my problems. With that said, I have another question based on your previous response; I noticed that you mentioned the Arduino website. If I am running RUMBA ATmega 2560 will the Arduino website be of value to me?

    • Absolutely. Boards like the RUMBA, RAMBo, Megatronics, RAMPS, and every other electronics board used in RepRap are all Arduino-based. Marlin is, through and through, an Arduino sketch (Arduino-ese for program). The only way to get Marlin onto your board is via the Arduino IDE. My strong recommendation is to get at least familiar with how that process works. The Arduino is also just an amazingly fun little board to play with, which you may find to be a nice side benefit if you’re a hardware guy. 🙂

  • Rawb

    Well thank you for your patience and I will continue researching Arduino and Marlin.

  • Steven

    Michael,

    I really appreciate the information on your website. I have found something I recommend you and your readers change, however. In the configuration.h file, you will find:

    //#define PROBE_SERVO_DEACTIVATION_DELAY 300

    I highly suggest you uncomment this line so that it detaches the servo after movement. You have probably noticed the servo jitters while printing if you do not have this line uncommented. This constant jittering will cause servo failure. I have had an old cheap servo and a brand new Hitec servo fail(after several hours of printing). It looks like the pot fails due to the jittering. Note that if you are using a slow servo, you may need to increase the delay.

    For those who are interested, if you look in marlin_main.cpp you will find two functions:

    static void engage_z_probe()
    and
    static void retract_z_probe()

    These are where the calls are made to extend and retract the Z-probe. You will notice they have if statements that look for a value of PROBE_SERVO_DEACTIVATION_DELAY. If that value is >0, the servo is attached and detached. The Arduino will only send a drive signal to an attached servo. This prevents the jittering.

    Thanks again and I hope you and others are helped with this information.

    • That’s come up a lot. Some users have had problems with getting the servo to respond correctly when the delay is turned on, and sometimes trouble with the duration of the delay. For that reason, I didn’t include it as a “matter-of-course” setting in the setup, but it is certainly the best way to get rid of servo twitch if you get it.

  • Finally figured out why the origin is shifting after auto-bed leveling, and i see here that many are facing the same problem, and would like to share my solution:

    the problem lies in the following code:

    // these are the positions on the bed to do the probing
    #define LEFT_PROBE_BED_POSITION 60
    #define RIGHT_PROBE_BED_POSITION X_MAX_LENGTH-20
    #define BACK_PROBE_BED_POSITION Y_MAX_LENGTH-20
    #define FRONT_PROBE_BED_POSITION 20

    // these are the offsets to the prob relative to the extruder tip (Hotend – Probe)
    #define X_PROBE_OFFSET_FROM_EXTRUDER_DEFAULT 40
    #define Y_PROBE_OFFSET_FROM_EXTRUDER_DEFAULT 0
    #define Z_PROBE_OFFSET_FROM_EXTRUDER_DEFAULT -11.6

    and also has something to do with

    #define min_software_endstops true // If true, axis won’t move to coordinates less than HOME_POS.
    #define max_software_endstops true // If true, axis won’t move to coordinates greater than the defined lengths below.

    for the Offsets, do it like zennmaster explained, keeping the” #define min_software_endstops” as false. after you have all the values, put it back into the code, and enable to min software endstops.

    And here is the part that makes all the difference:

    the positions on which probing are done in a coordinate system RELATIVE to the actual nozzle in “#define LEFT_PROBE_BED_POSITION XX…etc), i,e (position of actual nozzle in x/y while probing)+ (offset in x/y)

    example, if your offset x offset is 40, and you want to probe x at 20, the carriage will crash into the min x axis by 20mm after homing, since it has to go to -20 to get the probe into position, and in case you have the min software endstops enabled, then it will not go below -20, resulting in resetting the position the printer thinks its in from -20 to 0, and loosing 20mm towards the end of the traverse.

    keep this in mind and set the probe positions appropriately, you should be good to go. , for me, i just don’t let any negative values arise by the above logic, and you should be good to go.

    Hope this helped.

  • Hadi

    Hi , I set auto bed leveling feature for my 3D printer but after that the Z axis started to have a problem , I think it’s from the firmware … the problem is ( when I raise it up some times the two motors go up together while other times they go in different directions ) Could you please help me … it’s a tough problem for me !
    Do you want my firmware to send it to you using email ?
    Thank you .

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>