Saturday, June 25, 2016

Capacitive Sensor for Auto Bed Leveling

Leveling the printing bed is time consuming, move the printer, adjust any of the axises, move any of the Z axis motors and the printing bed is no longer level.

Add to this that I've recently added a glass printing bed that needs to be removed and replaced once in a while and bed leveling becomes a non pleasant task and wasted time.

The solution is auto bed leveling.

There are 3 main types of sensors, induction, capactive and some sort of touch, which is based on movement of a material, metal pushing on a switch, hall effect sensor or optical.

Other less common sensors could be distance sensors based on light or sound, but are not accurate enough for this purpose.

I've ruled out induction sensor since my print bed is now glass and induction sensors works only with metals but the concept is pretty similar. So I've selected the LJC18A3-H-Z/BX capacitive sensor for my tests.

The easiest proximity sensor to use is a switch since it interfaces directly to the controller without any circuitry, but the 2nd best sensor is NPN transistors since the MKS boards have a pullup and NPN connects the signal to ground when active, otherwise its considered floating, that's why a voltage divider works.

So I made a resistor voltage divider, you can use this calculator for initial values. Always use a multimeter to verify the output voltage is not over 5v otherwise you might burn the input pin or worse, the whole controller. also, if you use lower values for voltage divider you might ruin the proximity sensor, a good starting point is 15k/10k resistors for 12v. 

Again, measure, measure, measure! Like the old carpentry saying goes, measure twice, cut once.

Another thing to note is that the NPN sensors might display the status led always on if you connect the voltage divider directly, you can add a diode between the divider and the signal pin from the sensor, for example, anything in the 1N400X series would do.

After I've built the mini circuit and made sure the output voltage has the desired values (0v/5v) I went ahead and printed the proximity sensor bracket that connects to the fan/printing head assembly and made sure the printer can home the Z axis based on the proximity sensor.


There are two adjustments possible with this bracket, first, the height of the sensor from the print bed. My setup had a limitation since I've used bull clips to hold my glass on the build plate and the proximity would crash on the handle, so I've adjusted them as close as I could. In general the closer the capacitive sensor to the build plate, the more accurate the activation.


Another adjustment is the activation potentiometer on top of the sensor



Lastly, the z height in Marlin, which can be set in Configuration.h or in the menus (Control->Motion->Z Offset).

Combined, all these parameters will set the distance from nozzle to build plate. But to use the probe to home the printer, you'll need to issue G28 - home.

To actually autolevel the printer, we need to issue G29, which will probe multiple points on the build plate and create an adjustment matrix for the bed.

If you issue G29 without G28, it won't do anything, if you issue G29 without support in the firmware, same result, which is how my printer came configured, so I had to flash the firmware with autolevel support.

To do that, you need to have Arduino Software and get the sources from Marlin. You can find some explanations from here or use the documentation from Marlin's website.

There are explanations about autoleveling and configuration, but from my experience, less is more, I'm using 4 point grid on the outer edges of the bed, for glass its good enough, also, I recommend adding babystepping which helps you to fine tune the height when the print starts.

Probably the most important settings should be the board type, which tells marlin which pins are assigned to which input/output (motors/sensors/servos etc'), the temperature sensor settings, the steps per unit which indicate how many pulses to the stepper motor equals a millimeter, the max feedrate which indicates how fast the axises can move and the acceleration, which is depends on the weight of the print head carriage, you can reduce vibration and skipping and/or increase quality with lower values. The best way to figure it out is experiment.

You can find steps per unit calculator here and you can find multiple calibration structures here, each one for its own purpose, accuracy, speed, temperature, bridges, etc'

Good Luck! :-)

No comments:

Post a Comment