Tuesday, February 4, 2014

First tests and calibration - Marlin

Update: After working with a few guys who use Mac, I have learned that Repetier host Mac has some notable differences. I have added some Mac specific screenshots and explanation for these readers. Furthermore, even after reading this blog posting some were still confused so I have added more clarification in bold blue. If you use Repetier firmware go here.

Update: I have uploaded a YouTube video of the testing process http://www.youtube.com/watch?v=BX8UoTgS50M

First tests and calibration

  1. Power connected and turned on (cooling fan for stepper drivers going), and USB cable connected
  2. Arduino software - you need this to compile and upload your firmware. Go back The Basics and read/re-read what I already typed out Arduino installation, no point in copy and paste.
  3. Host software - you'll need Repetier, Pronterface, or Cura software next. I use Repetier host
Repetier-Host Printer Shape
Open your host software and configure your port. Arduino creates a com (communications) port and that's what you'll want to use. You can leave the port and the baud at auto and let the software auto-detect these. Now we need to configure the printer setting in the host software. This should match your firmware. Repetier-host lets you specify your printer is a Delta and will change the display to show a cylindrical print volume with the origin point at (0,0,0), other hosts may or may not doe this. Follow the configuration guide and use -85 and 85 (or whatever the radius of your print surface is) for the X and Y minimums and the same MANUAL_Z_HOME_POS value you used in firmware.

In addition, you need to tell Repetier-host to home to X=0, Y=0, and Z=MAX (click the Printer Shape photo to zoom in).

Click the Connect button and it should turn green. Click the Manual control tab and if you don't see the Log window click the Toggle Log button. there should be a simple message about the version of Marlin in the log.

Sample log output in Repetier-host

Check end stops
Before you click home, (the 12V power should be off or you can click the "Turn Motors Off buttonmanually move your effector down until all three max end stops are not touching. Now lets check a few things otherwise you may get an unpleasant surprise. In the G-Code: text box type M119 and click Send (or press enter).
You should see something like:
   < 8:42:05 PM: Reporting endstop status
   < 8:42:05 PM: x_max: OPEN
   < 8:42:05 PM: y_max: OPEN
   < 8:42:05 PM: z_max: OPEN

If not, then something is miswired or misconfigured. Confirm that you connected to NC (normally closed) and C (common) on the switch, and you connected the two wires to the X+, Y+, and Z+ pins on the RAMPS, and those two wires connect to the S (signal) and - (ground) pins, not the (5V). Another reason would be you did not update and upload the configuration.h changes I discussed in The Basics. Now one at a time push and hold an end stop switch and rerun the M119 command (hint, you can press the up arrow key on your keyboard to cycle through the history of G-Code commands you have issued via the G-Code entry field). You should see OPEN changed to TRIGGERED for the matching endstop. If not, then there is a wiring issue (make sure you plug max X(alpha) endstop into X+ not Y+ or Z+ :) Do not continue until you get this right.
Note: If you have a probe (and I don't think you need one) then make sure it shows TRIGGERED when retracted and OPEN when deployed.

Check motor direction (Note: deltas use a blend of all 3 motors to move the effector)
If everything checks out so far, then we need to confirm the motors are moving in the right direction. Again, disable the motors and manually move the effector down so it's around 100mm away from your surface. On the Manual Control tab, use the X and Y arrows to manually move the end effector. The arrows are divided into segments. The segment closest to the center will move the effector in that direction 0.1mm. The next segment 1mm, then 10mm then 50mm. Z only has the 0.1mm, 1, and 10 segments. Mac users, the author decided to give you a row of buttons from -100 to 100 for each axis. Remember we home to the Max and so all movements toward the bed are negative.
Notice the Mac manual controls are not a
graphic like Windows.

Let's start with Y. Click the 1mm in the Y+ direction, the effector should move to the rear toward the Z(gamma) tower. If not, take notice of which way each carriage moved, X(alpha) should have moved down, Y(beta) moved down, and the Z(gamma) carriage up. If any of these moved opposite, STOP (never unplug a stepper motor while it's powered, you will destroy the stepper driver)unplug 
 the 12V power, and flip the stepper connector on the ramps for that motor. Then you can reapply the 12V power. Repeat until they move as they should. Now same for X, click the 1mm in the +X direction and make sure the effector travels to the right. If that looks good then Try the Z+ 1 mm and all 3 should move up. If all these work, then it's time to home.

Home (Note: make sure in your configuration.h you set the homing speed to something less than 200*60. I recommend 90*60 to start)
Keep one hand on the power cord (emergency disconnect), the reset on the RAMPS, or better yet the power switch if you wired one in, for the first time and go ahead and remove your build plate or put something to protect it ;) Ok, now click any of the home buttons, there are 4, (keep in mind host software was designed for Cartesians. For delta all axis must home at the same time). All carriages should move up at the same speed (the homing speed) until they hit their end stops. Then the X(alpha), followed by Y(beta) and finally Z(gamma) will home and back off the switch. Congratulations! If not, then you skipped a step and hopefully nothing was damaged. Go back to the basics or wiring and confirm you got it right.

Calibration (Note: This link to Calibrating a 3D Printer is the de facto set of instructions for this, I only disagree with where he says you need to disable EEPROM.)
Now comes the arduous task of calibrating your actual MANUAL_Z_HOME_POS as well as your end stop offsets (M666 in Marlin). Before we begin, I think it's worth understanding what we are trying to do and what endstop offsets do for us.

In order to print thin layers and have successful first layer adhesion we need to make sure the effector (and the hotend it carries) moves parallel to our build surface and is calibrated such that Z=0 means the tip of our hotend is touching the build surface at any point. We also need to make sure our build surface is "flat" from one point on its surface to any other point. I put flat in quotes because depending on your layer thickness, 0.1mm maybe flat enough. The design of the delta with the 3 sets of parallel arms is such that it should constrain the movement effector to remain flat and not tilt or rotate around the X or Y axis. If you notice any tilting in your effector (or nozzle tip) then your arms are not parallel, not fixed to the pivot points (magnets?), or not the same length and this is a physical issue, not software.

The firmware has to convert a set of coordinates into the number of steps for each axis motor. This is some Pythagorean math (A^2 + B^2 = C^2) and is calculated for each tower, for each move, and moves are subdivied by segments per line so there is a lot of computations. In order to move where we want, the machine needs to have a reference point to start from. We call it Home, and on most deltas it's chosen to be at the maximum (max) or top of the machine. The trick is, how to you ensure that each axis endstop is in the exact same location, such that when you are homed ( X0 Y0 ZMAX_Z), the effector is in the center of the machine, and when you are at X0 Y0, Z0 the effector is still in the center and each axis has moved Z_MAX in distance and the tip of your hotend is just touching the build surface? On some designs the endstop is fixed (3DR, Lisa) and thus is guaranteed to be at the same height. Other designs have a mechanical adjustment to allow one to tweak the end stops.

The mini Kossel does not have this, so Peter Hercek wrote a new M code for to allow users to specify an offset for each axis so that when homed the carriages would all be at the same height. This M code is M666 and how it's used is M666 X-n.n Y-n.n Z-n.n, where n.n is some floating point number representing a distance in millimeters. The numbers are always negative (meaning they move away from the end stop toward the surface) and always have a decimal since we need them as floating point values.

You should test your MAX_Z before you send a command to go to Z0. I would advise you sneak up on the distance to the build surface as you move the nozzle down to Z0. If you reach the surface before Z = 0.0 then you need to subtract the value Z displays from your MANUAL_Z_HOME_POS. For Marlin, disconnect from the printer, save the change in configuration.h, upload the firmware, reconnect, and verify. The Max Z height will change in the next steps so don't worry about getting it perfect, we are just trying to get close on the first round.

Step 1, we need to make sure that each axis carriage is at the same height after homing. To do this, we need to home the machine (send a G28 G-Code command or click any home button). Then send a G-code command to get the nozzle at a point on the surface directly in front of each axis (X, Y, Z in that order). The nozzle should be touching such that it pinches a piece of paper and that paper can be pulled out from between the nozzle and surface without tearing. So let's look at the three outcomes for each trial. Here are our starting conditions (my comments in red)
  • steps per mm are 80
  • M666 X-0.0 Y-0.0 Z-0.0    (start with no endstop offsets)
  • MANUAL_Z_HOME_POS 225.0 (determined from step 1)
  • DELTA_PRINTABLE_RADIUS  = X_MAX = Y_MAX = 85 (for a build diameter of 170mm)
  • DELTA_EFFECTOR_OFFSET 20    (from the effector.scad file)
  • DELTA_CARRIAGE_OFFSET 19.5 (from the carriage.scad file)
  • The coordinates for the point in front of the X/Alpha tower are 
    • X=-73 Y =-45 
  • G1 X-73 Y-42 Z5 F6000  (start at 5mm above the surface. We will step down toward Z0 in 1mm then 0.1mm increments)
  • Pay attention to the axis readouts on the Manual Control tab, especially the Z value 
Here are the potential outcomes as we step to Z=0:
  1. The nozzle pinches the paper and it can be pulled out when Z=0. This is the ideal state and means you can move to the next axis (Y/Beta). If you get this on the first try you got lucky :)
  2. The nozzle is above the surface (let's say by 2mm) when Z=0. This means we need to increase the offset for this axis. Using the M666 command, send M666 X-3.0 G-Code. We want to go a bit further so as we use -0.1mm steps, we find the most accurate offset value. Send a G28 (home), then send G1 X-73 Y-42 Z2 F6000 which should put you roughly 1mm above the surface. Use the Z -0.1 button to step down while testing with a sheet of paper as your feeler gauge. If you reach a point where there is sufficient drag of the nozzle on the paper and Z reads something other than 0, then subtract that amount from the X value in M666. Let's say Z = 0.4. Then send M666 X-2.6. Then G28, then G1 X-73 Y-42 Z0 F6000 and confirm the paper test works.
  3. The nozzle reaches the surface before Z=0. In this case, you will need to move the plastic piece that holds the end stop up, or you can reduce your MANUAL_Z_HOME_POS (including reflashng the firmware) and increase M666 value by the same amount. Then re-home (G28) and retest.
Once you finish X/Alpha, then move on to Y/Beta. Once you finish Y/Beta, Check X/Alpha and adjust if needed. If you adjust X/Alpha, then recheck Y/Beta. If X/Alpha and Y/Beta are good, go on to Z/Gamma. And you guessed it, once you finish Z/Gamma, check and adjust the other two as needed.

Step 2, ok now all 3 carriages are at the same height and pass the paper test. Now we need to set the center. If DELTA_SMOOTH_ROD_OFFSET, and by association DELTA_RADIUS, is not accurate then your nozzle may be above or hitting the surface (trying to move through it). Again to preserve your machine, use a G1 X0 Y0 Z5 F6000 to sneak up on Z0.
  1. If the nozzle passes the paper test at Z=0 then you are done. Save the M666 values. I use EEPROM so I would use M500 to save them. If you are not using EEPROM and don't plan to, then add the M666 to your start.gcode in your slicer.
  2. If the nozzle is above the surface and Z=0 then you need to increase DELTA_SMOOTH_ROD_OFFSET. As soon as you do, you'll need to go back through step 1 (The difference this time is you should have to add the same amount of offset to all three. ). How much you change DELTA_SMOOTH_ROD_OFFSET depends on how far off. You can try 1mm at a time and increase by more depending on the observed change.
  3. If the nozzle touches the plate before Z=0, then you'll need to decrease DELTA_SMOOTH_ROD_OFFSET and go back through step 1.
Step 3, you should have very parallel movement now, and any point you chose on the surface should pass the paper test at Z=0. Don't forget to update your host software's Printable Height in the Printer Settings. Now you need to calibrate your extruder steps. The de facto on that is Triffid Hunter's Calibration Guide. I was recently given the tip to use 1/8th microstepping instead of 1/16th as a way to increase my retract speeds. I have a 5.2:1 geared stepper and this allowed me to go from 35mm/s to 70mm/s which makes a difference. However, that was a little more vibration which meant more noise so I'm looking for more sound isolation opportunities.


  1. Your calibration instructions are great. I just need one clarification. You wrote;
    The nozzle reaches the surface before Z=0. In this case, you will need to move the plastic piece that holds the end stop up, or you can reduce your MANUAL_Z_HOME_POS (including reflashng the firmware) and increase M666 value by the same amount. Then re-home (G28) and retest.

    I am not clear on this "and increase M666 value by the same amount". Are you saying to increase the M666 H value ie H (Z-Height): 220.40?

    Also, is there an easy way when building to ensure your endstops are far enough down so that you do not have to do the above, because adjusting by changing the x,y,z using m666 is wayyyy easier.


    1. M666 X-n.n Y-n.n Z-n.n, means you set the offset for each tower. If you are hitting the bed before Z=0, it means your Z_MAX (the starting height when homed) is too big. You are right, I do not think you have to change both the MANUAL_Z height and the endstop offsets (M666). Have you seen my Youtube videos where I walk through the process?

      I put my endstops at the very top, and do not move them :) I also use firmware with EEPROM so I can update these offsets real-time and agree M666 M665 are way easier.