Intro: DIY Z-Probe Using Capacitive (or Inductive) Sensor and Optocoupler
This project will require just a few things:
1) A control board with at least one z-endstop, 2 is unnecessary, but allows more flexibility if you're confident and capable.
2) A DC capacitive sensor with roughly ~8mm sensing range and a working voltage range that includes 12v
3) An optocoupler or DIY optocoupler
4) An aluminum bed or metal tape to place under the bed so the capacitive sensor can detect the bed.
5) Marlin, Repetier, or another customizable firmware
6) Basic logic and reasoning capability. Solder/wire-twists, electrical tape, and some breadboard wires with female ends make life easier too.
This project costs between $5-$15 USD and will provide 100% automated mesh bed leveling. At the given moment a capacitive, 8mm sensing distance, 3v-36v sensor is $5 from uxcell on Amazon, and the 12V EL817 Optocoupler is $2.5 on Amazon.
Step 1: The Mount
Choose a extruder mount that has a hangar for inductive and capacitive probes. I use the one linked below. You can mount your probe anywhere on the extruder carriage because you define the probe's location in Marlin relative to the primary extruder. In the case of mine, the probe is roughly 23.5mm left, 10mm forward, and 2mm above the primary extruder tip. Yours may differ and that's perfectly fine.
My current extruder and probe mount: https://www.thingiverse.com/thing:2777673
Step 2: Mount the Probe and Prep the Endstop
When your mount is printed out and ready for the probe, go ahead and slide it into the mount and lower it down until the tip of the probe it 2mm higher than the tip of the extruder. Creality printers usually come with a small wrench. That wrench is 2mm thick so it's a great tool to stick under the probe and lower till it touches the wrench. Secure the probe with either the two large nuts it comes with. I've seen some mounts in the past with threading built in and locks built in, so use that if your mount has one.
Next, unplug and remove your z-endstop from the printer and unplug the z-endstop cable from the printer's control board. In many cases, opening up the printer to get to the control board will tear a small tamper sticker, meaning you'll void your warranty. That's not always the case, it's just a forewarning.
At this point you should have your extruder mount fully assembled, your probe mounted, and your old z endstop removed and cable unplugged.
Step 3: Wire in the Optocoupler
Check out the image here. That is an Optocoupler. The easiest explanation is that optocoupler separates one electrical system from another. The proper way to power a probe is to power it through the MOSFET that powers the control board or to take power directly from the power supply. Given that the probe is powered directly, it is a danger to the control board so we use the optocoupler to prevent our probe from shorting out and burning up our control board. Now to the instructions:
Go ahead and wire the black, brown, and blue wires of the probe to the optocoupler to match the included picture of my own probe. The brown probe powered wire and the positive 12v power from the PSU or MOSFET go into the same input positive plug on the optocoupler and the ground from the PSU or MOSFET and the blue of the probe go into the same ground plug on the optocoupler output. The black ground from the probe goes to the input ground of the optocoupler, which complete the wires from the probe itself. The last set of wiring in to connect the VCC (red) and the OUT(black) from the optocoupler output to the Red/Black z-endstop plug on the controlboard. If the controlbard has only 2 wires for the endstop then you match color to color. If it has 3 inputs then the black is the ground and the red goes to the signal input which is often a green wire instead of read.
You are free to use whatever color you want, but the usual color pattern for 3 wire endstops is black = ground, red = power, and green = signal.
Warning: If you don't pay attention you could accidentally fry your controller by blasting it with power straight from the PSU, that's why we use the optocoupler. Please spend the extra few dollars on the optocoupler!!!! It's worth waiting even if you can't get it shipping fast.
Step 4: Optional: Using Z-Max Instead of the Z-min Endstop
This information below is simply here as information to spark thoughts and plans for future work!
If you are a more advanced user you may have already put in a better control board or maybe your printer is fancy and has both max and min endstops for each axis. If this is the case then you can keep your z-endstop and connect the probe to z-max instead. Truly advanced users, who are probably rolling their eyes at me in boredom, are fee to use any available pins on the control board and simply need to modify configuration.h, pins.h and boards.h (i think that's it...) in Marlin to make the printer think normally and use the probe as an endstop without losing z-max OR z-min.
If this is the case then you can connect the probe to z-max or available pins and simply need to define the probe's pin location in your firmware of choice, like Marlin. I'm not going to explain that here because it is not a short or simple task.
Step 5: Firmware
Now the probe is mounted and wired in with an optocoupler protecting out control board. The only remaining task is to tell the control board how to use the probe using Marlin, Repetier, or other firmware. I will use Marlin.
*Note: The Unified firmware from Th3D is Marlin, just like the firmware from Creality3D, so my info here is applicable to that too. I am not a TH3D employee, nor a Creality employee, I'm just computer scientist and engineer who loves everything electronic and mechanical.*
First things first, marlin users need to go into configuration.h and get familiar with the bed leveling and z-probe options. Once you have an idea of what you need to enable and edit, then it's time to move on:
As of Marlin 1.1.x and beta 2.0.x these steps are all that is needed to get the probe working.
- Match the invertion of the z probe and z-endstop tom prevent a compilation error. I cannot tell you if true or false is correct for you because it's different for each probe and board combo. Mine are true.
- #define Z_MIN_PROBE_ENDSTOP_INVERTING = true
- #define Z_MIN_ENDSTOP_INVERTING = true
- For the advanced users not using the min endstop, you have to define your pins now so marlin knows where the probe is connected
- For everyone else this tells Marlin the probe is connected as the z endstop
- this tells Marlin the probe is mountred permanently up with the extruder(s)
- Here you need to measure how far it is from the top of the extruder to the center of the probe on each axist and fill in the values. Negative values mean left, backwards, and down respectively. Positive values mean right, forward, and up.
- My x, y, and z offset are -63, 10, & 2 using the mount I linked in step 1, meaning my probe is left of the extruder, towards the from of the bed, and 2mm up. You must set the z to positive 2mm or you will either knock over prints or be too far to detect the bed. Tweak it as need, but stay as close to 2mm as possible.
- "Multiple probing" is how many measurements are taken at each stop, I suggest 2 or 3 for accuracy
- I suggest using auto bed level UBL with 10-13 points to make the grid.
- If you have an A/C powered bed the use the delay feature in Marlin 2.0.x (when released or with beta version) to reduce interference from the A/C current. Capactive sensors arent much of an issue here, but inductive are
Compile your code, upload, and work through any typos and errors. Be warned that mounted probes can cause Marlin some headaches with going "out of bounds" so you may bed to play with the bed size, MESH_INSET setting, and possibly manually defining the 3 starting points for bed leveling. All that is printer/board/probe dependant and I can't tell you exactly what to do. Just think it through logically and make sure you aren't telling the big, new extruder assembly to go outside the bounds of the printer by accident.
Step 6: Done
Enjoy your new auto-leveling. If everything worked out properly you should now be able to tell the printer to level, go grab a drink, and come back to watch it finish up and save a z-offset and virtual mesh to the EEPROM, ready to print.
Remember to level at temp! Marlin has settings to disable fans and heating when probing, so be careful. They are disabled by default, so it should heat and probe if told to.
I will try my best to keep this up to date and add more pictures with time.