Skip to content

Hardware settings and print quality

repetier edited this page Sep 25, 2011 · 14 revisions

Hardware settings and print quality

Basics

Many people are confused by the many possible hardware settings. The settings are quite easy, if you understand the basics of the firmware and the physics needed for a good print. On this page, I'll try to give an overview over the most important settings and how they may have an effect on print quality.

What the user wants

  • Fast output - no one likes to wait hours for a job to complete.
  • Fine details.
  • No restrictions to shapes, we can print, e.g. unlimited overhangs.
  • Exact copy of the model.

In contrast to our wish list, the real world physics set some limits. Some wishes even contradict each other. A fast print reduces the print quality. The trick is, to find some hardware settings balancing speed and quality.

Physics of printing

The basic concept is very simple. We take some plastic filament, warm it up until it melts and press it to the position, where we want our object. The problem is timing and positioning. When do I need how much pressure and speed, to get the wanted result.

The extruder

The extruder has two parts. The filament driver and the hot end. The driver pushes the filament into the hot end, which creates a pressure

p = E * Ldiff / Lext

with

p = created preesure
E = E-modulo of the filament
Ldiff = Length of fileament pushed in - equivalent length printed
Lext = distance between filament driver and hot end melting zone.

The hot end melts the filament and uses the pressure to push it out with the "desired" speed. A simple approximation of the math behind this is Bernoulli's principle:

vt²/2 + pt/rho + gzt = vb²/2 + pb/rho + gzb + zeta*vt²/2

with

vt = Filament speed at the top of the melting zone.
pt = Pressure at the top = p from filament + air pressure.
rho = Density of the filament.
g = Gravity.
zt = Height of the top of the melting zone.
vb = Speed, the filament leaves the nozzle.
pb = Pressure at the bottom = air pressure.
zb = Height of the bottom.
zeta = Friction constant.

The term g * (zt - zb) can be omitted for most considerations. I call it the ooze term, because it numbers the gravity on the melted filament, which causes oozing. The simplified version can be reordered, so that we get

vb = sqrt(vt² * (1-zeta) + 2 * (pt-pb)/rho)

Furthermore, we can remove pb and the air pressure part of pt:

vb = sqrt(vt² * (1 - zeta) + 2 * p / rho)

We see, that the output speed depends on the input speed and on the pressure. As we will see later, the pressure term is the real problem. If we change speed, we need to adjust the pressure, too.

Ooze

There are two reasons for the ooze. If we do not print, but the hot end is on, the filament will melt and slowly flow outside. The other reason is pressure, caused by the filament driver. During the print move, a certain pressure was needed. If we just stop the extruder, the pressure is still there and will force the plastic outside.

Oozing during warm up

  • Always start with your print head over the dump area.
  • Just before the target temperature is reached, remove all plastic hanging from the nozzle.
  • Let the axes home for a clean start.
  • Print a dummy line, long and fat enough to refill the hot end.

A sample code:

M109 S170
G90
G28 X0 Y0 Z0
G92 E0
G1 Z0.38 F80
G1 X100.0 E11 F600
G92 E0

Oozing during print

The standard method, is to tell your G-Code generator to reatract the filament a few (2-3) millimeter for traveling moves and to push it back just before the next print move. If you have a filament driver with backslash, don't forget to tell that, too.

A second method is to use the advance method (Matthew Roberts) described later in "Extruder pressure control". This method will update the extruder steps to create the needed pressure.

Trajectory smoothing

Before I start on speed and acceleration, you should understand, how the firmware manages moves. Your print head and extruder are driven by stepper motors. They are ideal for positioning, because you can tell them to rotate a fixed amount. The most common used steppers need 200 full steps for a complete rotation. By controlic the magnetic field, the drivers are able to do 1/2 to 1/16th step resolution. This rotary precision combined with the gear give a fixed length, the head can be moved. Normal resolutions are 1/40 mm or 1/80 mm. Every position is always a multiple of this length. If the printer performs a move from point x0,y0,z0,e0 to x1,y1,z1,e1 it uses the Bresenham algorithm, depicted below.

Bresenham algorithm

In the picture, you see a black grid. Each of these lines are multiple of the stepper resolution and possible positions. The blue line is the ideal move, we want your head to take. The algorithm takes the direction with the most steps needed as driving axis. Then for each position on this line, the optimal position of the three depending axis are computed and taken. This will result in the best approximation for this resolution.

You can see, the timing for the driving axis es perfect. The driven axis is only updated at the primary axis updates, resulting in some imperfections. To reduce this jittering, the Repetier-Firmware takes half steps in the primary direction, if the speed is not too high (until 8000 Hz steprate for 16MHz CPU). That way, the driven axis are updated earlier, reducing the jittering. In the example above, the green dots show earlier updates. Depending on the angle, there max be more or less. You can disable this by setting

#define MAX_HALFSTEP_INTERVAL 16000000

Since there are no negative side effects, disabling is not encouraged.

Initial speed

Can we start a move with some inital speed? Physics says v = a * t, with a = acceleration and t = acceleration time. So no, we can't. But we do it anyway. In your configuration, you see a definition

#define MAX_JERK 40.0

A waiting head is initalized with a speed of 50% MAX_JERK. We can't beat physics, but the timing belt and printer constructions is flexible to some extend. What happens is, that the abrupt move causes a shock and a sudden acceleration. The maximum inital speed is limited by the torque of the motor. If the shock is to harsh, your stepper will make some screaming sounds and stay at its place. For best results, we need a high inital speed. It increases print quality (for explanation see acceleration) and reduces print time. Problems with too high inital speeds are:

  • Lost steps.
  • Timing belt may skip over your pulley tooth (=> put more tension on the belt).
  • Pulley may rotate against your stepper axis (=> better fix your pulley).
  • Increased shaking of your printer.

Jerk constrain

For two consecutive moves with a direction change, the problem is similar to the inital speed problem. If we keep a constant speed and change direction, the direction of the speed vector makes a sudden change. This is shown in the next picture.

Jerk

Look at the red jerk vector, presenting the speed difference. Within this documentation, we call this vector jerk, also it is not the real jerk from physical definitions. The same thing as with the inital speed happens. A shock results in sudden accelerations in the new direction or the motors fail, if MAX_JERK is set to high.

What the firmware does is quite simple. For every corner, it computes the maximum allowed jerk vector and compares it with the jerk, we would have, if we keep our speed. If the jerk is to high, like in example 1, the speed for the corner is reduced to the maximum possible speed.

Acceleration

We want to print fast. We already know, the inital speed is limited to something like 10 - 20 mm/s. Of course we want 100 mm/s and more. We need to accelerate from our inital speed to the desired speed. For safety reasons, we also need to decelerate to inital speed at the end of your print move. That said, what are our limits?

Needed force

For the maximum acceleration, we use the following equation:

a = F/m

with

a = Acceleration/Deceleration F = Motor force - friction forces m = moved mass (printer head, print bed)

Lets take some numbers. Our stepper has 49Ncm holding torque. Lower voltage, rotation and substepping reduce this to, lets say 25Ncm (just a guess). For the mass we take 2kg. The motor has a 8 tooth pulley.

rpulley = 85mm/(23.1415) = 6.37 mm
F = 250 Nmm / 6.37 mm = 39.2 N
a = 39.2 N/2 kg = 19.6 m/s² = 19600 mm/s²

Thats pretty high. Unfortunately, this value must be reduced. If we spend all our force on acceleration, there is no reserve for the jerks we have.

The distance needed to accelerate to a given speed is d = v^2 / (2*a). The following table shows some values:

a [mm/s] d for v=100mm/s d for v=200mm/s
1000 5.00 mm 20.00 mm
2000 2.50 mm 10.00 mm
3000 1.67 mm 6.67 mm
4000 1.25 mm 5.00 mm
5000 1.00 mm 4.00 mm
7500 0.67 mm 2.67 mm
10000 0.50 mm 2.00 mm

Print quality

You may ask, why acceleration affects the print quality. The problem is our fileament. If the head speeds up, the bresenham algorithm will also speed up the filement driver. If you look at the bernoulli equations in the extruder section, you will see the nonlinear dependence on pressure. What happens is the following:

  • During acceleration, some of the steps meant to push filament outside the nozzle are used to increase the pressure. From the beginning to the end of the acceleration area, we get less filament as wanted, resulting in thinner walls.
  • During the next section with constant speed, the pressure stabalizes and the througput approches the correct amount, if the length is long enough.
  • During the deceleration, we have the reverse process. We need less pressure, so more filament is pushed through the nozzle. Especially at the end of the deceleration zone you will see larger blobs of plastic.

To test the effects, I developed a special test. The following picture shows the path:

Acceleration test

Normal slicing software will never create this path. To help you, I wrote a test case generator in my Host software. A description, how to use the generator can be found here.

The number of steps needed for pressure are proportional to v². That known, what are our possebilities to increase print quality.

  • Increase inital speed.
  • Use pressure control for the extruder (see further down).
  • Reduce acceleration, leaving more time to accomodate to the new speed and distibute the error over a larger zone.
  • Reduce final speed. If we go from 10 to 80mm/s we need to increase the pressure with factor 64. Going from 20 to 60 mm just increases the pressure by a factor of 9.
  • Add path planning.

Because the quality is only affected during print moves, you can different acceleration for print and travel moves.

#define MAX_ACCELERATION_UNITS_PER_SQ_SECOND {1000,1000,50,1000}
#define MAX_TRAVEL_ACCELERATION_UNITS_PER_SQ_SECOND {1000,1000,50,1000}

Path planning

Acceleration is evil to our quality but necessary. So, what can we do? We need to avoid acceleration where possible and minimize it to a minimum where necessary. For this we need a path planning algorithm. The result is shown in the picture below.

Path planning

So how does it work? If a new move is send, the firmware makes no assumtions on prior or future moves. Therefore the movement is constrained at the beginning and the end by the inital speed. Between these points, it will try to accelerate to the requested feedrate. If the move is long enough (>2 * acceleration distance) the target feedrate is reached, otherwise we get triangular speed share with a maximum between start and commanded feedrate. These precomputed moves are stored in a buffer.

For every new move stored, the path planning algorithm is called. It from right to left until it reaches a corner, where the maximum allowable speed is already reached, except the last two blocks. The last block is the one we currently print, no changes are allowed in that block. The second last may be needed any time, so it is also skipped for safety. With a buffer length of at least 16 moves, this is no real limitation for a real print. For every corner it checks the following:

  1. What is the maximum speed if the previous move accelerates until the corner and what is the maximum speed if we can decelerate the complete move. The lower value is taken for furter considerations.
  2. Is the speed higher than any of the target feedrates, reduce speed to lowest target feedrate.
  3. Is the jerk higher than allowed? If yes, reduce speed, so maximum allowed jerk is reached.

If the speed is limited to maximum jerk or reaches the full feedrate, the corner is marked as fixed and the update is finished. All moves to the left are already optimized to the maximum possible speed.

Path planning has the following side effects:

  • Reduces print time.
  • Reduces acceleration to minimum, which reduces wrong filament extrusion amount.

No negative effects are known, so it is always turned on.

Extruder pressure control

In a post (see here) Matthew Roberts proposes to add additional steps to the extrude, to fix the changing pressure problem. This method is called the advance method, because it computes, how many staps the extruder hast to take in advance, to create the needed pressure.

From the extruder section, we already that

vb = sqrt(vt² * (1 - zeta) + 2 * p / rho)

and

p = E * Ldiff / Lext = E * advance / (Lext * extruderStepsPerMM)

Combining both we get:

advance = (vb² - vt² * (1 - zeta)) * (Lext * extruderStepsPerMM * rho) /(2*E)

vb can be expressed as

vb = vt*at/ab

with at = filament cross section and ab nozzle cross section. This gives the final formula

advance = vt² * (a_t^2/(2a_b^2) -1 + zeta) * (Lext * extruderStepsPerMM * rho) /(2E) = k * vt²

The factor k is exactly the value you set in your extruder definition with

#define EXT0_ADVANCE_K 0.0f

It is disabled by default. Every extruder needs other values, because it is influenced by too many factors.

Note: Other firmwares may have another definition for k, because they pushed some values outside. I liked this, because it gave me reasonable large k value. For a 3mm filament and a 0.5mm nozzle, k is between 40-70.

To calibrate your k-value use the test case described in the acceleration section. Make L1 = 20mm and L2=60mm. Set the low speed to jerk/2 and the fast speed to your target printing speed like 60 mm/s or 80 mm/s.

Clone this wiki locally