Home » Tools » 3D Printer » 3D Printer Auto Leveling DIY

3D Printer Auto Leveling DIY

3D printer auto leveling design

Getting the first layer right is the holy grail of 3D printing. This is hard if your print bed is not completely level. Here’s the story of why and how I added 3D printer auto leveling to my Sunhokey Prusa i3.

First the why. 3D printed parts are created by adding layers of extruded plastic one on top of the other. The first layer that you print is the foundation for all others. There are two tricks to getting this right. The first is preparing your print bed surface so that the plastic sticks to it “just right”. As I mentioned before, I use Kapton tape with ABS slurry to print ABS on a heated print bed. This surface treatment is shown above. The second trick is to make sure that the hot end nozzle is the proper distance from the surface. This proper distance is roughly the width of a piece of paper. This is hard to achieve because it is not easy to get a completely level print bed for three reasons.

  • Sometimes the print bed is slightly warped or bowed. There is little you can do about that mechanically.
  • Sometimes the table holding your printer is not completely level. You can compensate by adjusting screws in each corner of the print bed to raise and lower corners. But with four screws, each adjustment effects the other and you can spend a lot of time trying to get it right.
  • Finally, heating the print bed may also introduce warping after you have done your mechanical leveling.

3D printer auto leveling does not actually involve changing the level of the print bed. In this respect, it is misnamed. 3D printer auto leveling involves teaching your printer about how it is not exactly level. The printer software then uses mathematics to compensate. Here’s how I modified my printer.

The easiest way to implement 3D printer auto leveling is to attach a proximity sensor near the print head. A proximity sensor is that little metal cylinder with an orange tip in the “after” photo above. If you have a metal print bed, you can use an Inductive Sensor, which can detect aluminum up to 4 millimeters away. If you have a non-metal print bed, you can use a Capacitive Sensor, which can detect a hard surface up to 10 millimeters away. You then replace your Z-Axis (vertical) mechanical end stop switch with the proximity sensor.

You will need to design and print an ABS plastic part to hold the proximity sensor. See the middle photo above.

Before each print, 3D printer auto leveling works by probing the distance between your nozzle and the print bed in several places across the surface. Once your printer understands these distances, it will automatically compensate for how “level” changes across the surface. All of this should be automatic and you should not need to do any more manual leveling.  You would normally do 3D printer auto leveling just before the print starts, after the bed and hot end have been heated.

3D Printer Auto Leveling Circuit

Before we go any further, here are the tutorials which helped me figure everything out.  There is a video from Thomas Sanladerer and written description from marshallpeck. I chose a slightly different approach for my 3D printer auto leveling circuit, and will explain it here.

3D printer auto leveling circuit

First, I bought a couple of proximity sensors from eBay. One was inductive and the other was capacitive. Both were PNP or sourcing devices. My plan was to use one to close a relay when it sensed the print bed surface. These cost between $5 – $10 each, with the inductive sensor being cheaper. The 12V needed for these devices can be obtained from the controller board.

Second, I carefully measured the sensor and my 3D printer hot end mount and then printed a part to hold the sensor. This part is shown in the middle photo above. It was designed using a CAD program as three pieces (two sides and a sensor mount) that screw together.

Third, I used a normally closed SPDT relay to interface between my senor and printer control board. This avoids any direct electrical connection. You can buy a relay like this for a couple of dollars if you don’t have one in your junk box. When the sensor “senses” metal, it puts 12V on its Output, which in turn opens the relay in about 8 milliseconds.

Finally, I removed the wiring from my printer’s mechanical Z- end stop, and connected it to the output of the relay. During normal operation, the normally closed relay completes the circuit between the Z- Signal and common V- terminals. When the relay is opened, it breaks this circuit which triggers the end stop recognition in the controller board. You will want to confirm this operation before moving on to enabling your 3D printer auto leveling in the firmware. This is done my sending the M119 command which reports the end stop status, as either open or triggered.

The tutorials listed above will provide you with the information you need to do the rest of the work to get 3D printer auto leveling set up properly. It’s not hard, but it requires concentration. The hard part is getting the sensor at just the right height relative to the nozzle. Once you have this figured out, you save the settings in your firmware. The sensor height is easily adjustable with two nuts and lock washers. With a capacitive sensor, the sensitivity is also adjustable.

(In case you are interested, my Inductive Proximity Sensor is an LJ12A3-4-Z/BY and the relay is a Mode 50-533-0 SPDT 12V. Total parts cost for the project is well under $10.)

The STL files for this build are available on Thingiverse.

8 comments

    • John VE6EY says:

      Thanks for your comment, Jerry. What aspects would mean most to you, in addition to the firmware changes? I can try to put together a small video.

  1. Anthony says:

    Hello, I have the same printer, and I have purchased the same inductive sensor, I believe. Is your sensor normally open, or normally closed? Mine is normally opened. Would I need that relay incorporated into my setup?

    • John VE6EY says:

      Hi Anthony. My sensor is normally open. When it senses metal, it closes (the red LED comes on and 12V is applied to the Output pin.) I used a relay to isolate the sensor from the end-stop wiring. Thomas shows a different way of wiring it in his video, without the isolation. My circuit isolation was just my preference. You can wire the relay as NO or NC, depending on how you set the end-stop circuit in your firmware.

  2. Tom B says:

    I have a printer already with auto level. The sensor plugs directly into the board. I want to use a different sensor. LJ18A3-8-Z/AX. This has the the same properties as the PL-08 that is on there now. It is too hard to adjust . Need the cylinder which would be easier. Thank you Tom

  3. Alan Holbrook says:

    John, Do you know how the compensation algorithm works? Does it do linear interpolation and adjust Z between measurement points?
    Thanks for the great post!

    • John VE6EY says:

      Hi Alan. Yes, I think your description as “linear interpolation and adjust Z” is correct. As far as I know it is a “least squares best fit” implemented in the qr_solve file in Marlin. Technically, though, this would be a “bilinear interpolation” (quadratic rather than linear function).Since Arduino does not do double precision math, the results may be a bit off, but probably good enough. I really have not taken the time to “read the code” in Marlin. 🙂 Thanks for your comment.

Leave a Reply