Skip to main content

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 (2.0.6.1) 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 STRING_CONFIG_H_AUTHOR
//#define SHOW_BOOTSCREEN
//#define SHOW_CUSTOM_BOOTSCREEN
//#define CUSTOM_STATUS_SCREEN_IMAGE
//#define SPEAKER
#define S_CURVE_ACCELERATION
#define MANUAL_PROBE_START_Z 0.2
#define FIX_MOUNTED_PROBE
#define NOZZLE_TO_PROBE_OFFSET { -45, -5, -5 }
#define AUTO_BED_LEVELING_BILINEAR
#define RESTORE_LEVELING_AFTER_G28
#define GRID_MAX_POINTS_X 4
#define EXTRAPOLATE_BEYOND_GRID
#define Z_SAFE_HOMING
#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.


Comments

Popular posts from this blog

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

This procedure worked for my laptop (Thinkpad E530) with a Conexant 20671 sound card, but I suspect it will work for other sound cards in the Conexant family. I was playing with CamStudio to do a video capture of a Flash-based cartoon so that I can put it on the WDTV media player and play it on the big screen in the living room for my kids. The video capture worked brilliantly, but to do a sound capture, I needed to do some hacking. Apparently, there was this recording device called "Stereo Mixer" that was pretty standard in the Windows XP days. This allowed you to capture whatever was played to the speaker in all its digital glory. Then under pressure from various organizations on the dark side of the force, Microsoft and soundcard makers starting disabling this wonderful feature from Windows Vista onwards. So after much Googling around, I found out that for most sound cards, the hardware feature is still there, just not enabled on the software side. Unfortunately, to

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

This hack is inspired by this post . A year ago, I bought an adapter cable for my wife's Thinkpad X1 Carbon (2nd Gen) that allows her to power her laptop with a 60W-capable portable battery (20V x 3A). A USB-C cable goes from the battery into the adapter, which converts it to the slim tip output required by the laptop. Everything works out of the box, so I didn't give much thought about it. Recently, I decided to buy a similar cable for my Thinkpad T450s. I know technically it should work because the T450s can go as low as 45W (20V x 2.25A) in terms of charging (though I have the 65W charger - 20V x 3.25A).  I went with another adapter cable because it was cheaper and also I prefer the single cable design. So imagine my surprise when the cable came and I plugged it into my laptop and it didn't work! The power manager just cycle in and out of charging mode before giving up with an error message saying there is not enough power. After much research and reading the Thinkwiki

Using Google Dashboard to manage your Android device backup

I used to use AppBrain/Fast Web Install to keep track of which apps I have installed on my phone, and to make it easier to reinstall those apps when the phone gets wiped or replaced. But AppBrain had been going down the tubes, and Fast Web Install had always been a hit-and-miss affair. Android's own "backup to the cloud" system had previously been even more unusable. There isn't a place where you can see what has been backed up. And when you setup a new phone with your Google account, you just have to wait and pray that your favorite apps will be restored to the phone. Typically all the stars have to be aligned just right for this to happen. More often than not, after waiting for an hour or so and nothing happens, you just curse under your breath and proceed to install your favorites apps manually via the Play Store. But I just looked again recently and was pleasantly surprised that things are much more civilized now. Firstly there is a place now where you can loo