# Calibration

You RepRap works well? Great!

Did you ever hold a caliper on your parts to see wether these 10 mm in the STL file match on the printed part? Wether this 8 mm hole actually has 8.0 mm diameter, not 6.8 or 8.3? No?

Here we talk about how to not disappoint you in case you or your friend ever does. A Mendel can be calibrated to be as accurate as the mechanics allow.

# Prerequisites

Before starting calibration, your build process has to be pretty stable already. You have to know which temperatures work best, how much feedrate you prefer, the nozzle size, plastic flow, and all the other stuff which makes for a good print. Because all these parameters change the actually received part size at the end of a build.

# Explanation

To be defined. Scaling goes into the STEPS_PER_MM of the firmware, track offset goes into the G-code compiler (Skeinforge etc.).

OK, here we get a bit stuck. While the theory section below nicely shows how to calculate the optimum track offset, Skeinforge has no configuration option to adjust this value.

An excerpt from a chat between Greg Frost and Traumflug, on 2011/22/06:
[14:30] <GregFrost_> I calibrated the extruded length and then set feed=flow and pw/t and iw/t to 1.5 and immediately got nice looking prints. However, and here is the kicker, the objects are all slightly too big because my single wall box has an actual w/t of 2.1
[14:31] <GregFrost_> I can fix this with p flow but then i get thin preimeters and they dont alway bond well to each other (but objects are the right size).
[14:31] <GregFrost_> I would like normal flow on the perim but a wider w/t but if i do that it adjusts all of the flows up and I get far too much plastic.
[14:32] <GregFrost_> what I really need is a way to change the distance inside the objest that the perimeter is traced without changing the flow rates.
[14:37] <Traumflug> To be honest, I never used Skeinforge, this adjustable track offset is an assumption.
[14:38] <GregFrost_> Traumflug: it would be a good setting, i agree.
[14:38] <GregFrost_> Traumflug: I think the only way to achieve a track offset is to adjust the perimiter w/t ratio.
[14:38] <Traumflug> So, Skeinforge doesn't compensate for track width?
[14:38] <GregFrost_> Traumflug: it does. but it uses the perimiter witdth/t and infill w.t settings
[14:39] <GregFrost_> Traumflug: then it uses the layer height
[14:39] <GregFrost_> Traumflug: and useing those it works out the track offset.
[14:39] <Traumflug> ok, good to know.
[14:39] <GregFrost_> Traumflug: but the kicker is, changing perimeter w/t also adjusts the flow rate
[14:40] <GregFrost_> Traumflug: so theoretically when you choose a new w/t, it puts out enuf plastic to fill the width.
[14:40] <Traumflug> Yes, theoretically
[14:41] <GregFrost_> Traumflug: but on the perimiter if you use the same volumetric flow as the infill, it bulges past the desired width because there is no containing line.
[14:42] <GregFrost_> but the one setting that allows you to compensate for that adjusts the flow on all other lines (both infill and permiiters)
[14:42] <Traumflug> IMHO, changing the plastic flow to compensate for size errors isn't a good way.
[14:43] <GregFrost_> Traumflug: I agree completely.
[14:43] <Traumflug> Each time you change the flow, a lot of minor parameters change as well, so a prediction is very difficult.
[14:43] <GregFrost_> I want to change the track offset.

# Sprinter Firmware Guide

Adjustments to the calibration are made in the firmware because this is where the motors are told how much to move each time they are told to move a unit. You will need to know how to compile and uploaded firmware to your arduino to find the following information useful. The sprinter firmware can be found at https://github.com/kliment/Sprinter.

First, you will need to choose your electronics in the configuration.h file:

 //// The following define selects which electronics board you have. Please choose the one that
// MEGA/RAMPS up to 1.2  = 3,
// RAMPS 1.3 = 33
// Gen6 = 5,
// Sanguinololu up to 1.1 = 6
// Sanguinololu 1.2 and above = 62
// Gen 3 Plus = 21
// gen 3  Monolithic Electronics = 22
#define MOTHERBOARD 3

 //// Thermistor settings:
// 1 is 100k thermistor
// 2 is 200k thermistor
// 3 is mendel-parts thermistor
// 4 is 10k thermistor
// 5 is ParCan supplied 104GT-2 100K
// 6 is EPCOS 100k
// 7 is 100k Honeywell thermistor 135-104LAG-J01
#define THERMISTORHEATER 1
#define THERMISTORBED 1


Calibration settings are inside the configuration.h file (take note of the comments around this code if you are using Metric Prusa Mendel with Makergear geared stepper extruder or MakerGear Hybrid Prusa Mendel):

 //// Calibration variables
// X, Y, Z, E steps per unit - Metric Prusa Mendel with Wade extruder:
float axis_steps_per_unit[] = {40, 80, 3200/1.25,700};


If you are using RAMPS, it is important to find the following lines in the pins.h file and do as the comments say:

 // uncomment one of the following lines for RAMPS v1.3 or v1.0, comment both for v1.2 or 1.1
#define RAMPS_V_1_3
#define RAMPS_V_1_0


# Theory and Maths

## X and Y Axis

Both horizontal axes can be calibrated with two values: track offset and overall scaling. To find out how this is done, let's have a look at a part specially designed to find out those values:

It's a frame, similar to the one you use to put pictures up onto the wall. The essential part here is, it has long and short distances to measure on the same part. We need to measure both, to distinguish between track offset and scaling.

To the right of the drawing, a few tracks laid down by the extruder are sketched in. It shows how the track offset lets the extruder move closer to the inside of the part, so the outer side of the track just ends where the part should end as well.

All the sizes are overlaid by scaling, which is sort of a "gear ratio" between measurement units and stepper motor steps.

### Calibration Object

// X-Y Calibration object
// See http://reprap.org/wiki/Calibration#Theory_and_Maths

difference() {
cube([100,100,3], true);
cube([80,80,3.1], true);
}


### Basic Equation

With that knowledge, we can sum up what the extruder moves to get the size T = 10 mm exactly 10 mm wide:

\begin{align} \mbox{movement} = ( \mbox{intended size} - 2 * \mbox{track offset} ) * \mbox{scaling} \\ \end{align}

This holds true for measurements of any size, i.e. also for the 100 mm size of our calibration frame:

\begin{align} M_{10} & = ( 10\,\mbox{mm} - 2 * TF ) * S \\ M_{100} & = ( 100\,\mbox{mm} - 2 * TF ) * S \\ \end{align}

You see? Two unknowns and two equations, so the set is solvable.

### Extending to Erroneous Movements

Now, the whole point of this writing is, the extruder movement doesn't match what we need to get accurately sized parts. So we have not only a movement, but also a movement error.

Reason for the movement error is, according to the basic equitation, errorneous track offset and/or errorneous scaling.

Get these two into the basic equitation, result to the left, reason to the right:

\begin{align} & \mbox{movement} * \mbox{movement error} = \\ & ( \mbox{intended size} - 2 * \mbox{track offset} * \mbox{track offset error} * \mbox{scaling} * \mbox{scaling error} \\ \end{align}

Again, this holds true for both our measurements:

\begin{align} M_{10} * E_{M10} & = ( 10\,\mbox{mm} - 2 * TF * E_{TF} ) * S * E_S \\ M_{100} * E_{M100} & = ( 100\,\mbox{mm} - 2 * TF * E_{TF} ) * S * E_S \\ \end{align}

... to be continued ... about a formula to get scaling and track offset from measuring these 10 mm and 100 mm ...

## Z Axis

On the Z axis, there is no track offset compensation, so calibration is reduced to scaling of part height. Build any part of 50 mm height, let it cool down, measure it. Then adjust your STEPS_PER_MM in your firmware's config.h to reduce the difference between intended and received part.

As most RepRaps use a threaded rod on the Z axis, the theoretical value should match reality pretty close. However, there's also material shrink as the plastics is printed at a higher temperature than room temperature.

# References

put here as the new part is still incomplete --Traumflug 22:55, 21 June 2011 (UTC)

Is this part of commissioning? Is this part of Builders/Config/Config Axes?

To calibrate, you will need the following: a Rep(st)rap, a slide caliper, and printing material (ABS, PLA, HDPE, etc).

You will also need this object file to print out.

2. Print the calibration object.
3. Allow the object to cool.
4. Use the slide caliper to measure each edge and the diagonals.
5. Make a note of each measurement and this will allow you to determine where a problem is IF there is a problem.

With the above measurements, you should be able to determine any alignment issues. The sides should measure withing .5mm of 40mm.

if it is off consistently, then it is probably a firmware issue.

Most inconsistent discrepancies are a sign of backlash (i.e. slop or play in your mechanical system). Make sure the grub screws on the pulleys are tight; make sure the belts are tensioned so that when you turn the stepper by hand, it immediately produces a movement in the axis; make sure all the bearings turn smoothly, and that the carriages only move along their intended axis. with all of that double checked, try printing your test piece again, and pay very close attention while it is printing. If your stepper motors make strange noises occasionally, it might be that they are skipping steps because they don't have enough torque. Try turning up the trim pot for that axis.

If all this fails, the best place to go to figure out how to fix your issue, once you've identified it, is either to ask someone in the forums, or on IRC, if you prefer. Then come back here and make this page better, or complain to the forum users.

Once you get a simple cube printed adequately, you might consider trying a more difficult object such as the bearing clip 01 for more fine-tuning.