Skip to content

This python script or Windows executable will automatically level the bed by adjusting M666 XYZ and M665 LR for a Monoprice Mini Delta 3D Printer. It uses the more up-to-date P5 method.

License

Notifications You must be signed in to change notification settings

PurpleHullPeas/MPMD-AutoBedLevel-Cal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Monoprice Mini Delta (MPMD) V1 Auto Bed Calibration (P5)

This python script will automatically adjust the M666 XYZ and M665 LR values to calibrate bed leveling for a Monoprice Mini Delta 3D printer. It uses the G29 P5 method for an improved bed mesh.

DO NOT USE THIS WITH THE MONOPRICE MINI DELTA V2! THIS TUTORIAL IS FOR THE OLDER MONOPRICE MINI DELTA V1!

MPMD V1 vs MPMD V2
The firmware for these two machines behave very differently. The Monoprice Mini Delta V2 already includes a built-in Delta Calibrate routine, so do not use these scripts/programs.

Overview

This tutorial is designed to be used in place of Step C5 in Dennis Brown's great alignment/calibration tutorial.

I automated Dennis's G29 P5 Heatmap Spreadsheet for M666/M665 Calibration by updating Technoswiss's python script. Special thanks to them for all of their effort!

Python Script (auto_cal_p5.py)

Dennis's Spreadsheet and Original Instructions
You should only need this for generating pretty heatmaps. I.E., there's no need to go through his Step C5 spreadsheet instructions if you're using this script.

There is a comprehensive troubleshooting guide near the bottom of this post. I WILL NOT HELP YOU AT ALL unless you have gone through that section and provided ALL of the requested information in the Troubleshooting Form. I get that there's a lot of content and that things are easy to overlook, but I can't help you unless I have a full picture of what's going on.

Bed Leveling Heat Map
Image Source: https://www.facebook.com/groups/mpminideltaowners/permalink/2996644567017676/

Features

  1. Started with Technoswiss's G29 P2 v2 python script and included the most up-to-date bug fixes from it.

  2. Updated to use Dennis Brown's G29 P5 Excel heatmap calculations.

  3. Saves results after each iteration in text files (can be copy-pasted into Dennis's spreadsheet).

  4. Works with stock firmware and mcheah's Marlin4MPMD 1.2.2 and 1.3.3. Early tests suggest it can work with aegean-odyssey's newer MPMD Marlin 1.1.X, but you have to run both G29 and G29 C1 after running the script.

  5. Saves time iterating through the Excel procedure yourself and makes it easier to update values when you make any mods or change the bed temperature.

Disclaimer

Use at your own risk. Backup everything and keep your finger on the after-market power-button (that I'm sure you installed) while the script runs. I'm not responsible if your printer decides to spontaneously combust or if you void your warranty. All disclaimers and prerequisites listed by Technoswiss on his original project still apply.

Tested Firmware and Operating Systems

Tested Firmware

Stock v37
Stock v41
Stock v43
Stock v44
Stock v45
Marlin4MPMD 8x (v1.2.2 and v1.3.3) by mcheah
Marlin4MPMD 16x (v1.2.2 and v1.3.3) by mcheah
MPMD Marlin 1.1.X by aegean-odyssey: Early tests suggest it can work, but you have to run both G29 and G29 C1 after running the script. I actually recommend against using the P5 program for this firmware, as the built-in routines or my advanced auto_cal_generic.py script may work better.

Tested Operating Systems

Linux (mostly Octopi)
Windows 10 (batch file and command-line executable included)
Exactly one person has told me that it works with Mac. They had to use auto_cal_p5_v0.py instead of auto_cal_p5.py.

Prerequisites

  1. This script is intended to be used only AFTER you've gone through other calibration steps (namely Dennis's improved bed hold-down clips and having a more consistent bed surface). Do not run it unless you've made it that far in the Calibration Roadmap I've put together.

  2. You will need to be able to control your printer via USB. I use my Octopi (but not Octoprint) to run the script via terminal/command line (not to be confused with your print server terminal).
    E.G., I don't have a monitor plugged into my Octopi, so I do all of this using Putty. I'm able to enter "octopi" instead of the IP address to connect, but YMMV.

  3. Unless you're using the Windows executable, Python3 is required, with additional updates/packages.

    Octopi Installation: (some unnecessary commands included to help noobs)
    sudo apt-get install python3-serial
    sudo apt-get install python3-scipy
    sudo apt-get install python-serial
    git clone https://github.com/PurpleHullPeas/MPMD-AutoBedLevel-Cal.git
    cd MPMD-AutoBedLevel-Cal
    git fetch
    git pull

    Windows Installation:
    I recently released a command-line executable that can be used instead of the python script, as well as a batch file to make running it more straightforward: auto_cal_p5_v0.bat and auto_cal_p5_v0.exe (you will need both files in the same directory).
    The Visual C++ Redistributable may be required whether you use the executable or the Python script.
    If you prefer to use Python, you will need the additional packages included with WinPython.

    Mac/OSX Installation:
    Download Python for Mac
    Install pyserial
    Install scipy and related packages
    Exactly one person has told me that it works with Mac. They had to use auto_cal_p5_v0.py instead of auto_cal_p5.py.
    The terminal command
    ls /dev/tty.usb*
    will show the usb ports in use.

  4. The points that the nozzle probes need to be consistent. I.E., if you're using tape, a sticker, PEI, glass, mirror, etc., you need to make sure the nozzle taps that for every probe point. If using tape, make sure it covers the entire build surface without overlapping; however, it is probably safer to run this calibration with no tape on the bed. Whatever build surface you choose, make sure you remove the stock sticker before application because you want everything as flat as possible. If you typically use glue/hairspray on your bed, I recommend cleaning it off beforehand. The script will most definitely not work if the effector is colliding with a bed clip or other obstructions before the nozzle can probe the bed. In my experience, trying to use glass retainer/holding clips causes problems and should be avoided (read my recommendations in the calibration guide).

  5. Dennis wrote the spreadsheet assuming you have his hold-down clips installed (see previously linked tutorial). This is not an optional step. You should also tune your belts if you haven't done so recently.

Instructions

DO NOT FORGET TO COMPLETE THE REMAINING STEPS AFTER RUNNING THE PROGRAM! UPDATING YOUR M666, M665, using G29 P5 (stock firmware), and having the correct M92 is crucial!

  1. Power cycle your printer to clear out any temporary settings.

  2. Make sure the nozzle is clean and then turn the nozzle heat off.

  3. Heat your bed up to your desired printing temperature and clean it. Let it sit for a while so that all parts get fully heated. Later when you run the script, you want to set the "-bt 60" parameter to whatever your desired bed temperature is.

  4. If you're currently connected to the printer via Octoprint, Pronterface, Repetier, Cura, Simply3D, or some other service, click the Disconnect button now.

  5. Run the Python script with your port connection, starting R and L values from Dennis's previous alignment tutorial step, the appropriate step/mm for your firmware (firmware v45 can be weird), and your desired bed temperature. Standby with your finger on the power button, ready to abort, just in case weird things start happening. Don't forget to complete the remaining steps here after running the program.

    The following examples are provided for Octopi, using Dennis's default M665 L/R values, stock firmware, and a bed temperature of 60 C. Additional details for Windows will be covered later.

    Stock Firmware <=V41
    python3 auto_cal_p5.py -p /dev/ttyACM0 -ff 0 -tf 0 -r 63.5 -l 123.0 -s 57.14 -bt 60

    Stock V43 & V44
    python3 auto_cal_p5.py -p /dev/ttyACM0 -ff 0 -tf 0 -r 63.5 -l 123.0 -s 114.28 -bt 60

    Firmware Flag and Tower Flag Notes
    Because of differences in how stock firmware and Marlin4MPMD treats tower orientation and G29, you will need to set the firmware flag (-ff) and tower flag (-tf) appropriately.
    -Stock Firmware: -ff 0 -tf 0
    -Marlin4MPMD 1.3.3 (Default): -ff 1 -tf 1
    -Marlin4MPMD 1.3.3 (M665 X-120 Y-120 Z-120): -ff 1 -tf 2
    -Older Marlin4MPMD Versions (Default): -ff 1 -tf 0
    -Other Configurations: You can try all three tower flags (0, 1, or 2) one at a time until one works. The script will stop due to an error in a few passes if you guessed the wrong configuration.

    Windows Executable Notes
    For Windows, you can can instead use the executable/batch file (see uploaded screenshots). You will need both the auto_cal_p5_v0.bat and auto_cal_p5_v0.exe files in the same folder for this to work. Don't forget to complete the remaining steps here after running the program.

  6. The calibration values should now be set to whatever was calculated on the last pass. The outputs for each pass should be stored in files named auto_cal_p5_pass#.txt. You can paste the contents of this file into Dennis's Spreadsheet to check your heatmap. If you've run the script multiple times, sort the files by date to make sure you're using the most recent text file.
    Note: I'm using Samba to copy files between Windows and Linux.

  7. [MARLIN ONLY] If you are using Marlin4MPMD firmware, now would be a good time to re-run the 7x7 mesh while the bed is still hot (details given below). After that, you may or may not need to revisit your z-offset via M851.
    ;At this point, you've already run the script and the bed should still be heated.
    ;Delete your old M666 XYZ and M665 RL lines from your Start Gcode.
    ;Send the following commands via terminal:
    M665 S120
    G29
    G29 C1 ; This is needed for aegean-odyssey's port.
    ;Wait for the G29 to finish running.
    M500
    ;You can now use G29 P0 in your Start Gcode if you wish

  8. [STOCK FIRMWARE ONLY] Stock firmware doesn't save M665 R with M500 due to a bug, so for the purposes of keeping things simple for this tutorial, I'm just going to suggest you save your M665/M666 values in your Start Gcode. If there are already lines in your Start Gcode with M665/M666, replace those with your new values. If you followed the prerequisites, the proper M92 values should also be set there (if not, fix that now). Change your G29 line to G29 P5 Z0.28. You may need to change 0.28 to whatever z-offset value works best for your machine (see MPMD 101). It has also come to my attention recently that, if you have not already, you should add M665 S120 to your Start Gcode.

Troubleshooting

1) Python versions and/or dependency errors.
E.G., "python3: command not found", "ModuleNotFoundError: No module named 'numpy'", etc.
Try replacing "python3 auto_cal_p5.py" with "python auto_cal_p5_v0.py". This will both reduce the number of dependencies required to run the script and handle any issues where your OS may have assigned "python" to Python 3.X instead of "python3". You will still need to install pyserial for this to work.

2) Serial Ports?
The provided examples work for Octopi if you only have one serial device plugged into the rPi. Otherwise, you will need to replace "-p /dev/ttyACM0" with your appropriate serial port, because it will most likely not be the same as the provided examples.
Windows Example: "-p COM3"
Mac Example: "-p /dev/tty.SOMETHING" (need to replace SOMETHING with your actual value)
If you're unsure of what your port name is, try seeing what it's called when you connect to the printer via Octoprint, Pronterface, Repetier, or some other service. Otherwise, try Googling, "how to find serial port name on my operating system".

3) I had to abort because the nozzle started probing outside of the build area and/or the machine started making weird/bad noises.
Two possibilities come to mind:
a) Hardware/setup issue. Go back and read through the PREREQUISITES section. Also, please fill out the troubleshooting form at the bottom of this section (including a photo of your bed setup) so we can identify potential issues. It also probably wouldn't hurt to check the lubrication on your moving parts (guide rods, carriage arm joints, etc.).
b) Bad M665 values. The examples provided use Dennis's starting values and may not be applicable for your machine (although, they do seem to work for most). You can adjust these by replacing "-r 63.5 -l 123.0" with your desired R/L values. Ideally, you have calculated these values from the Carbon Paper Step C4 in Dennis's tutorial. If not, replace these numbers with whatever you've been using to print successfully. For example, the stock values would be "-r 61.70 -l 120.80".

4) I reach the maximum number of runs and/or my results suck. Make sure you have Dennis Brown's custom hold-down clips installed. That step is not optional. Without the clips, the 5x5 probe mesh will make the bed wobble everywhere, preventing you from obtaining consistent results. Also, make sure you're using G29 P5 in your Start Gcode. For some reason, people keep skipping that step in the instructions. After that, you can further improve your results by removing the stock Buildtak and installing 120 mm borosilicate glass w/ a 0.5 mm thermal pad and/or PEI. If you have a bad/stuck/obstructed endstop switch, damaged belts, poorly-lubricated parts, or other major hardware issues, the script will fail to provide usable results.

5) My nozzle is going too high or low on the first layer (possibly even grinding into the plate).
Multiple possibilities come to mind.
a) Did you remember to complete the remaining steps that come AFTER running the script/program? For some reason, most recent questions have been related to skipping the steps (for Marlin4MPMD or Stock firmware) pertaining to G29.
b) Search the Calibration Roadmap and FAQ for the word "erratic." There are a lot of possible causes for this behavior.
c) Z-Offset problem
As long as most of your points are <= 0.14 in the spreadsheet, you'll probably be okay. Keep in mind that the spreadsheet values represent measurements BEFORE G29 makes any compensations. A high "Initial Layer Height", finely-tuned z-offset (see: MPMD 101, and/or the tips within the Calibration Roadmap and FAQ) can help compensate for any remaining issues. Tuning the z-offset should come AFTER adjusting the Initial Layer Height.

6) "Calibration error on non-first run exceeds set limit."
This error usually occurs for one of two reasons:
a) Hardware problem. Go back and read Troubleshooting point 3.
b) Wrong tower flag. the -tf option tells the script how to account for any software tinkering of tower locations via Marlin4MPMD 1.3.3 and/or M665 X/Y/Z adjustments (not to be confused with M666). You can try each tower flag (0, 1 and 2) until you find one that works.

7) Windows Batch/Executable Errors I've had a few other people report to me that they were able to run the batch file, so I know it works for more than just me. For example, one common issue is when users try clicking the executable instead of the batch file (read the instructions again). When doing that, a command window containing only the following information will appear:
"Could not connect to error at baudrate 115200
Serial error: could not open port 'error': FileNotFoundError(2, 'The system cannot find the file specified.', None, 2) auto_cal_p5_v0.py: error: the following arguments are required: -p/--port
Press Enter to continue..."

8) Other Issues. At this point, many users have successfully run this script for all configurations of printer firmware on Octopi. Mac has not been as thoroughly-tested. If you're still having issues, please fill out the troubleshooting form at the bottom of this section and post it via one of the following channels:
a) File an issue on this GitHub page.
b) Respond to my original thread on Facebook. Note: If I don't respond, maybe make a new post. Facebook can be buggy sometimes.
c) Ask the question on Reddit and tag me /u/PurpleHullPeas

Troubleshooting Form/Questionnaire

Do your best to fill this out, even if you just write "I don't understand." Even if you don't think it's relevant. Do not skip the bed photo. I know the list has grown quite long, but I'm usually pretty forgiving as long as you make an honest attempt to answer the questions.
Computer Used: Octopi/Windows7/Windows10/Mac/etc.
Firmware Version Shipped with Printer/Mainboard: Stock v[37/38/39/40/41/42/43/44/45]
Are you now using Marlin firmware? Yes/No? copy-paste the firmware.bin filename and list the version of Marlin
Build Plate Surface: Glass/Mirror, PEI, WhamBam, Terrible Stock Sticker, Tape, etc. (also include how you decided to attach the bed to the printer)
Did you remove the stock build surface sticker prior to installing the surface above? Yes/No, Why?
List any mods between the heated build plate and printer base that cannot be seen in your photo: N/A
Did you make sure that the bed heater wires are tucked away completely in the base hole?: Yes/No
Do you have Dennis's Hold-Down Clips Installed? Yes/No
Did you calibrate Dennis's Hold-Down Clips with an Index Card with the bed heated to printing temperature? Yes/No
Have you tuned the belts recently? Yes/No
Have you lubricated moving parts recently? Yes/No
Have you shimmed the bed square to the rails (not always necessary)? Yes/No
Have you ensured all arms are the same length (very rarely necessary)? Yes/No
Is there any "play" in the carriage bearings and/or arm screws/nuts? Yes/No/What
Is your effector colliding with a bed clip (or something else) Yes/No (See 8-second Video)
Does the nozzle appear to be sliding across the surface at any probe point? Yes/No
Did you clean the filament off of the tip of the nozzle? Yes/No
Is the nozzle tapping only the primary print surface throughout the entire calibration process? I.E., it is not tapping outside of the glass/flexplate/tape/etc. Yes/No
Are the arms and/or effector getting stuck at the top near the wires and/or Bowden Tube (Helpful Video)? Yes/No
Have you (optional) rotated any towers (swapping wires and/or M665 XYZ)? Yes/No - Explain
List any other mods that may affect bed leveling: N/A
What method did you use to calibrate M665/M666?: auto_cal_p5.py, auto_cal_p5_v0.py, auto_cal_generic.py, auto_cal_p5_v0.bat, Dennis's spreadsheet, G33, MPMD Marlin 1.1.X's AUTO_CALIBRATE.GCODE, other (explain), etc.
Did you preheat the bed and/or nozzle prior to software calibration?: Yes/No, what temperatures?
Terminal Command Used and/or Batch File Screenshot: E.G., python3 auto_cal_p5.py [insert inputs here]
Successful? Yes/No/Partial
Terminal Error: Screenshot preferred. If applicable, copy and paste any script errors here
If not successful, were you able to run "python auto_cal_p5_v0.py [INPUTS]"? Yes/No - If no, paste that error as well. If N/A, try running this alternate script using "python" instead of "python3".
Did you try any of Marlin's advanced post-processing options? G29 C1, parabolic fit, least squares fit, manual mesh adjustment, etc.
Comments: E.G., Here's how/why it sucks.
Photos/Video: Include a photo (mandatory) of your bed setup and/or a video of your printer while the script runs. A screenshot of your heatmap could also be helpful, but do not skip posting an actual photo of your bed setup.
Start Gcode: Copy-Paste your entire Start Gcode from your slicer.
M503: Send M503 over USB and Copy-Paste Your Output

Windows Batch File Help

Step 0

Follow the previous instructions until it is time to run the script/program.

Step 1

Windows Batch File Step 1

Step 2

Windows Batch File Step 2

Step 3

Windows Batch File Step 3

Step 4

Windows Batch File Step 4

Step 5

Go back and finish the remaining steps in the instructions.

What if the batch file didn't work?

Try WinPython instead (go back up to the Windows Installation section for details/links). The large multi-step screenshot is included below. Click the image below to zoom in.
Note: If you're trying to copy-paste into the heatmap, the spacing in the output text files may be wrong. You can either fix it, manually, by removing blank lines or just run G29 P5 V4 over USB on stock firmware. WinPython Instructions

About

This python script or Windows executable will automatically level the bed by adjusting M666 XYZ and M665 LR for a Monoprice Mini Delta 3D Printer. It uses the more up-to-date P5 method.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •