Compiling Marlin 2.x for the Creality Ender 3 using PlatformIO

 I had previously modded my Ender 3 to use the FreeABL for auto bed-leveling.

This requires compiling and uploading a custom version of Marlin firmware with AUTO_BED_LEVELING_BILINEAR enabled. Since this takes quite a quite of extra storage, it requires SLIM_LCD_MENUS to be enabled. This removes the function to configure E-steps from the control panel. 

As mentioned in my previous post, setting the right E-steps value is one of the most important operation to perform when changing filament or print nozzle. As a result of enabling SLIM_LCD_MENUS, I can only configure E-steps by hooking up the Ender 3 to my laptop and issuing raw G-codes. This was getting old pretty fast.

So the other day, I started poking around to see if there is a way to fit both AUTO_BED_LEVELING_BILINEAR and SLIM_LCD_MENUS in the limited storage on the plain-vanilla Ender 3. After much research and tinkering, I am glad to report this is indeed possible. Here are 2 links I found most useful in helping me achieve this objective:

I use PlatformIO to compile the Marlin firmware ( using the melzi_optimized profile:

which essentially uses the build parameters mentioned here:

build_unflags = -g -ggdb
build_flags   = ${common.build_flags} -fno-tree-scev-cprop -fno-split-wide-types -Wl, --relax -mcall-prologues

The following features were modified from the default Ender 3 Configuration.h file:

//#define SPEAKER
#define NOZZLE_TO_PROBE_OFFSET { -45, -5, -5 }
#define DISABLE_M503

and Configuration_adv.h file:

//#define LCD_INFO_MENU
//#define ARC_SUPPORT

With these changes, I am finally able to fit both the normal LCD menu *and* bilinear bed leveling function into the compiled firmware (with S-curve acceleration thrown in).

RAM:   [===       ]  30.6% (used 5007 bytes from 16384 bytes)
Flash: [==========]  98.1% (used 127580 bytes from 130048 bytes)

The new firmware didn't like the old config values, so the settings had to be initialized. There were basically 2 operations that needs to be performed from a fresh setup like this:

  1. Probe Z-offset
  2. Auto bed leveling

Probe Z-offset

Z-offset is the distance between the print bed and the nozzle when the ABL probe is engaged. Another way to look at it is that when the ABL probe is disengaged, the Z-offset is the distance that the nozzle needs to travel down so that it just touches the print bed. Therefore if the Z-offset is set too high, the nozzle will dig into the print bed and leave scratch marks on it as it moves, as I had the privilege of finding out! So set the Z-offset to as low as possible to get the first layer to stick, and not any higher.

Finding the Z-offset requires some work on the user's part. First, select Menu > Motion > Auto Home. This will move to print head to the center of the print bed and lowers the print head until the ABL probe engages.

Now disengage the ABL probe and move the nozzle to touch the print bed using Menu > Motion > Move Axis > Z Axis. Move using the 1mm interval initially until the nozzle is almost touching the print bed, then insert a piece of paper between the nozzle and the print bed. Switch to using 0.1mm interval and continue moving the nozzle downwards until you can just feel drag when you move the paper. 

Remember the current Z-axis value (eg. 0.2mm). Now select Menu > Configuration > Probe Z-offset, which will show you the current Z-offset value (default -5mm i.e. last value of NOZZLE_TO_PROBE_OFFSET). To get the new Z offset, simply add the 2 values toegther (eg. -5mm + 0.2mm = -4.8mm). Adjust and set the Z-offset value, and remember to store it using Menu > Configuration > Store settings.

Select Menu > Motion > Auto Home again with the ABL probe engaged, then disengage the probe and test again by moving the Z-axis. Now when the Z-axis is at 0.0mm, it should just touch the print bed and introduce the same drag on the piece of paper.

Auto Bed Leveling

The auto bed leveling option is found under Menu > Motion > Bed leveling. Since I have defined GRID_MAX_POINT_X to be 4, the firmware will automatically perform bed leveling by probing 16 points (4x4) on the print bed. This part is pretty straightforward.


Popular posts from this blog

Adding "Stereo Mixer" to Windows 7 with Conexant sound card

Hacking a USB-C to slim tip adapter cable to charge the Thinkpad T450s

Attiny85 timer programming using Timer1