To get the most out of Marlin, here are a few simple tweaks.
1. EEPROM Settings
By default, Marlin forgets any configuration changes you make via the Mxxx G-codes whenever you reset or power cycle your controller. If you want to remember the settings, so you don’t have to set them every time you power up your controller, Marlin can store them in EEPROM. In Configuration.h, uncomment
#define EEPROM_SETTINGS
EEPROM_CHITCHAT is optional:
//to disable EEPROM Serial responses and decrease program space by ~1700 byte: comment this out:
// please keep turned on if you can.
#define EEPROM_CHITCHAT
You will need to compile Marlin and then upload the modified firmware to your controller in order to take advantage of the changes.
After sending your Mxxx G-codes to Marlin, send M500 to save them to EEPROM. You can also revert to default (“factory settings”) with M502.
One nice feature of Repetier-Host is that you can use it to set your EEPROM, rather than manually typing in Mxxx G-codes. Simply go to Config->Firmware EEPROM Settings from the menu.
Personally, I prefer to just set all my Mxxx G-codes as start G-codes in Slic3r, rather than storing them in EEPROM, but most people will probably prefer to use EEPROM.
2. PID Auto Tune
When I first switched to Marlin, I was not at all happy with the temperature control of my extruder. It was taking a long time for my hot end to heat up, and the temperature was still varying a lot. While the hot bed is controlled using bang-bang (traditional on/off temperature control), the extruder uses a more sophisticated algorithm, called PID, which should yield better temperature stability.
Initially, I tried turning off PID by commenting out
#define PIDTEMP
in Configuration.h. My hot end heated up much faster, but the temperature was still fluctuating a lot. I decided to try to get PID working better. In order to get best performance out of PID, there are some parameters which need to be tuned: Kp,Ki, and Kd. Configuration.h contains settings for Ultimaker, Makergear, and Mendel Parts hot ends, but I’m using a JHead. I had no idea what values to use for After doing a bit of googling around, I found out that Marlin has a way for it to automatically calculate PID parameters, G-code M303 – PID relay autotune. To automatically tune your hot end PID parameters, start with your hot end at room temperature, and using Pronterface, send it the M303 G-code as follows:
M303 S230
The parameter is the target temperature in celcius. If your target temperature is different, substitute it for the 230. Marlin will then heat up and cool down your hot end, while taking measurements. This will take a while. When it’s done, it will output a message similar to this one:
bias: 103 d: 103 min: 147.98 max: 152.02
Ku: 65.06 Tu: 30.67
Clasic PID
Kp: 39.04
Ki: 2.55
Kd: 149.66
Next, you need to tell Marlin to use the calculated Kp, Ki, Kd values. If you don’t want to hassle with compiling/reloading Marlin, you can just use the M301 – Set PID parameters P I and D G-code. Using the my values above, it looks like this:
M301 P39.04 I2.55 D149.66
I simply added the line to my start G-code in Slic3r. Setting the PID parameters in G-code allows you to change them on the fly for different profiles, for instance, if you like to switch back and forth between PLA and ABS.
If you prefer to hardcode the values as defaults in the firmware, set them as follows in Configuration.h:
#define DEFAULT_Kp 39.04
#define DEFAULT_Ki 2.55
#define DEFAULT_Kd 149.66
3. Acceleration and Jerk
If your printer vibrates a lot when printing at higher feedrates, causing wiggly prints, you can improve the quality without slowing down your prints too badly by lowering the acceleration and/or XY-jerk values. In Marlin, acceleration is specified in mm/s^2. The default is 3000. On my Printrbot, I slowed it down to 1000 with G-code as follows:
M201 X1000 Y1000; // max accel print
M202 X1000 Y1000; // max accel travel
M204 S1000; // default accel for normal moves
You can also change the value in Configuration.h, if you prefer:
#define DEFAULT_ACCELERATION 1000 // X, Y, Z and E max acceleration in mm/s^2 for printing moves
If you have a slow extruder, you can also slow down the retraction acceleration, but generally, there’s no reason do do this:
#define DEFAULT_RETRACT_ACCELERATION 3000 // X, Y, Z and E max acceleration in mm/s^2 for r retracts
3000 is the default value.
The jerk value is also useful, and affects the speed at which Marlin joins two segments. The default XY-jerk value is 20 mm/s. Lowering the value will slow down the transitions between segments. This is especially helpful for smoothing out ringing waviness on 90 degree turns. I found that 15mm/s is a good balance between speed an quality on my Printrbot. G-code:
M205 X15; // max xyjerk mm/s
Configuration.h:
#define DEFAULT_XYJERK 20.0 // (mm/sec)
There are also values for the z-axis and extruder, but I didn’t need to change them:
#define DEFAULT_ZJERK 0.4 // (mm/sec)
#define DEFAULT_EJERK 5.0 // (mm/sec)
When tuning acceleration and jerk values, a handy way to test the effects of your new settings is the Dry Run feature of Repetier Host. When Dry Run is enabled, the extruder is disabled while printing, so you can observe its motion without wasting filament.
After tuning the acceleration and jerk values my prints are better quality at higher feedrates, without sacrificing too much speed. Note that depending on your print, the lower acceleration/jerk values will have more or less effect on the total time it takes to complete it. Prints that have more short segments will be slowed down a bit more.
Even though my discussion was about slowing down the printer, you can also tune the acceleration/jerk parameters to speed things up, if you have a particularly well-tuned bot.