Auto Leveling Implementation

By Greg Rios – 3D Modeling

What you will need:

 

TowerPro SG90 9G Mini Servo with Accessories

Omron SS-5 Microswitch (not shown in picture)

Servos mount (3D printed)

Servo arm (3d printed)

PARTS NEEDED

Male pins

Assembly:

Servos mount needs to be sanded down in order for the servo to fit properly. The slot that was made for the servo wires was cut off further, for easier installation. Micro-switch is added to the bottom of the printed arm with a zip tie. Top of the printed arm has an opening that needed to be enlarged with the Dremel, in order to be able to connect to the servo gear. By now there should be two items to be connected together.  Combine both servo and printed arm, and use the small white arm (that came with the servo) into the servo gear. Use a small screw to keep in place.

In the Ramps shield, a jumper needs to be installed 5V to Vcc next to the reset button. This will activate the servo pins. Our current Ramps shield did not have pins for servos or for 5v to Vcc, so some soldering was done.

PINS

Installing:

With hardware assembled, the completed part is attached to the hotend mounts/x-carriage. A drill was used to make opening for the screws that will hold the servo mount in place. After everything installed, we need to connect to the servo pin 0 and connect the servo into the Ramps shield. With hardware installed, we need to go to the Marlin Firmware to enabled auto leveling

Firmware:

In configuration.h file:

#define min_software_endstops true // If true, axis won’t move to coordinates less than HOME_POS.

Was changed from true to false, this will not allow firmware to move any axis go below zero.

Scroll back down to Auto Bed Leveling section, uncomment:

//#define ENABLE_AUTO_BED_LEVELING

Scroll down and skip (for now):

#define X_PROBE_OFFSET_FROM_EXTRUDER -25
#define Y_PROBE_OFFSET_FROM_EXTRUDER -29
#define Z_PROBE_OFFSET_FROM_EXTRUDER -12.35

(These values will change, these need to be measured. Every printer will have its own unique offset numbers)

Change the travel speed, (8000 is too high and might cause skipping problems), choose from 4000-6000. I choose 4000.

#define XY_TRAVEL_SPEED 8000         // X and Y axis travel speed between probes, in mm/min

For now, I pass the Auto Leveling section and go to R/C Servo support section:

Uncomment the following lines:

//#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
//#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1
//#define SERVO_ENDSTOP_ANGLES {0, 0, 0, 0, 70, 0} // X, Y, Z Axis Extend and Retract angles

 

Servo number was changed from 3 to 1. In SERVO_ENDSTOPS the first two values are “-1” (disable) with the third being “0” enable). SERVO_ENDSTOP_ ANGLES will later be changed to an appropriate angle of extraction and retraction

I encountered twitching problems while printing; servo printed arm would twitch when printing which might cause the servo to malfunction after time. To avoid this problem this line was uncomment:

In the configuration.h file

//#define PROBE_SERVO_DEACTIVATION_DELAY 300

Now the angles for servos will be adjusted using Pronterface with command:

M280 P0 S160

(This command is telling the printer to extend servo 0 (P0) to an angle of 160 degrees (S160)).

If everything is installed appropriately, the printed arm will extend. Changing the value of “S” until the micro-switch is parallel with the print bed. If it’s not parallel the switch will never activate and it crash into the bed. Do the same for the retraction angle; make sure that the angle is wide enough to clear from any objects while printing.

Go back to Configuration.h file, and add your new angles:

#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles

The 3rd pair (Z-axis endstop) was change and new values were added (Z Axis Extend and Retract angles). Then load to Ramps. Now the probe/extruder offsets needs to be defined. An arbitrary point was selected on the bed and marked. Somewhere in the middle works well, but it’s not important. Using the X, Y, and Z controls on Pronterface, positions the hotend so that it is just touching the mark. Slide a piece of paper between hotend nozzle and bed should be barely able to clear.

Zero all the axes with command:

G92 X0 Y0 Z0

(This command will temporarily set the hotend’s current location as the zero point for all three axes)

After the command, raise the hotend until there is sufficient room to extend servo printed arm with micro-switch (which is now your z-axis probe). To extend the Z-probe use the M401 command.

With the z-probe extended, Pronterface was used to place the micros-witch trigger right on top of the mark on the bed. Z-probe is lowered until the Z-end stop is triggered; check if endstops were triggered command M119.  Once verified that the Z-end stop has barely been triggered, use M114 to read the current position of the hotend, and record the values. You should have one value for X, one for Y, and one for Z.

Multiply the values by -1 to reverse the sign.

Back in Configuration.h, change the probe offset values to your new values

Example: (old values)

#define X_PROBE_OFFSET_FROM_EXTRUDER -20
#define Y_PROBE_OFFSET_FROM_EXTRUDER -24
#define Z_PROBE_OFFSET_FROM_EXTRUDER -10

Replace the values with your new sign-reversed values.

#define X_PROBE_OFFSET_FROM_EXTRUDER 30
#define Y_PROBE_OFFSET_FROM_EXTRUDER -2
#define Z_PROBE_OFFSET_FROM_EXTRUDER -9

The last things to change are probing positions on the bed:

Initially were set as:

#define LEFT_PROBE_BED_POSITION 50
#define RIGHT_PROBE_BED_POSITION 150
#define BACK_PROBE_BED_POSITION 150
#define FRONT_PROBE_BED_POSITION 50

These will need to be changed in order to probe farther out. Farther out the better the plane calculation will be. Caution needs to be taken to make sure that there will be no issues with clearance with any other objects around the x-carriage and auto leveling parts and make sure that the probe is within the bed. Ramps 1.4 will be uploaded with all new changes.

Use command G29 to run the auto-level. But before you do, you need to home all positions by either clicking home button on Pronterface or by using G28 before running the G29. Click on the link below to see auto bed leveling in action.

https://www.youtube.com/watch?v=I3SBSFOKj5w