Klipper3d / klipper

Klipper is a 3d-printer firmware
GNU General Public License v3.0
9.58k stars 5.35k forks source link

servo probe behaviour with mesh bed leveling #616

Closed aeropic closed 6 years ago

aeropic commented 6 years ago

First of all, I must say I'm amazed by the features Klipper now offers. i've installed it on my ANET A8, tweaked the printer config in order to add a servo probe and mesh bed leveling, and every thing is working (I mean first print OK after bed sensing!)

My question is, is it normal the servo is activated before and after each probe point. I have not found a way to activate the servo once to release the probe, sense all 9 points on the grid, then activate the servo to place the probe in the parking position.

I think a way to do this could be to add the servo move in the [homing_override] gcode section and do the same in the [bed_mesh] gcode section if it would exist !!!!

Is there another way ? Thank you for this amazing piece of software.

printer.cfg.txt

oderwat commented 6 years ago

Good idea. This would need a bed_mesh start and end gcode section. I don't see how it would be related to the homing override section. This would only be useful if one takes more than one probe sample I guess.

oderwat commented 6 years ago

BTW what probe do you use? I recently made this mod for using the BFPTouch which works much better than all three of the BLTouch clones I testet. https://www.thingiverse.com/thing:3080865

aeropic commented 6 years ago

Hi Oderwat,

I 'm using this optical Z probe which is really very very accurate in terms of repeatability. https://www.thingiverse.com/thing:2805327 When homing the Z, you need to have the probe activated. Today it is done in the probe gcode section : activate_gcode: SET_SERVO SERVO=bltouch ANGLE=120 G4 P200 deactivate_gcode: SET_SERVO SERVO=bltouch ANGLE=10 G4 P100

If you suppress those lines, z-homing will fail as ther would not be any z switch ...

oderwat commented 6 years ago

That is similar to what I do. I just wanted to know which probe you use. I do not really see a reason for not storing the probe in between points but as I said it could be done if mesh bed gets a start and end gcode section (which should be trivial to implement).

aeropic commented 6 years ago

Yes, It is basically the same optical endswitch used in our probes ! Indeed far better than BLtouch... Not storing the probe between points would just allow to probe faster and would also limit the stress on the servo ...

Arksine commented 6 years ago

Could you remove the activate-deactivate gcodes from the probe and use a gcode_macro?

[gcode_macro G80]
gcode:
SET_SERVO SERVO=bltouch ANGLE=120 
G4 P200 
BED_MESH_CALIBRATE
SET_SERVO SERVO=bltouch ANGLE=10 
G4 P100 
aeropic commented 6 years ago

Clever idea I will try soon. I think it will work for the mesh leveling but I have some doubts for both the homing and leveling. Indeed when mesh bed leveling, there is a homing which is performed hence it will work. but if we perform a homing without the probe motion in the probe section it will crash into the bed... And if we add a gcode to activate the probe the probe in the oming override section then I'm afraid the mesh leveling will fail as there is systematically a homing which is performed before the probing... maybe would it be better to suppress the homing in the mesh leveling ?

I will try and keep you informed!

aeropic commented 6 years ago

@Arksine , I tested you idea and it works fine to mesh calibrate the bed with only one servo activation. ==> GREAT !

But, as anticipated, the G28 command (alone) is no more activating the probe. Adding a servo move in the homing override section helps to make the G28 command (alone) work : [homing_override] set_position_z: 5 axes: z gcode: G90 ; Uncomment these 2 lines to blindly lift the Z 5mm at start G1 Z10 F600 G28 X0 Y0 G1 X112.5 Y112.5 F3600 SET_SERVO SERVO=bltouch ANGLE=120 G4 P200 G28 Z0 SET_SERVO SERVO=bltouch ANGLE=10 G4 P100

But, as the G28 is included, in firmware in the mesh leveling routine, the mesh leveling retracts the probe after homing and is then no more effective...

So maybe the good idea would be to suppress the homing process from the mesh leveling. We could then do the both gcode sections ;

Is it easy to make this mod ? Any advice where to patch the code (I'm fully noob in python ) ?

aeropic commented 6 years ago

Hi friends, I found the way to patch klipper !!! Just removed this line in bed_mesh.py : def start_calibration(self): self.bedmesh.set_mesh(None)

self.gcode.run_script_from_command("G28") <<<<<<<<<<<<<<<<<<<<<<<<

    self.probe_helper.start_probe()

bed_mesh.py.txt

now the probe section becomes:

Define a probe using the BLTouch

[probe] pin: ^PC4 x_offset: -13 Y_offset: 22 z_offset: 2.41 ;activate_gcode: ; SET_SERVO SERVO=bltouch ANGLE=120 ; G4 P200 ;deactivate_gcode: ; SET_SERVO SERVO=bltouch ANGLE=10 ; G4 P100

the homing override: [homing_override] set_position_z: 5 axes: z gcode: G90 ; Uncomment these 2 lines to blindly lift the Z 5mm at start G1 Z10 F600 G28 X0 Y0 G1 X112.5 Y112.5 F3600 SET_SERVO SERVO=bltouch ANGLE=120 G4 P200 G28 Z0 SET_SERVO SERVO=bltouch ANGLE=10 G4 P100

and the macro to mesh probe the bed: [gcode_macro G29] gcode: G28 G1 Z10 F600 SET_SERVO SERVO=bltouch ANGLE=120 G4 P200 G1 Z10 F600 BED_MESH_CALIBRATE SET_SERVO SERVO=bltouch ANGLE=10 G4 P100 printer.cfg.txt

It is now working as with MARLIN and the slicer start code has not to be modified as the G29 macro does the same job ! Klipper is really great and fun, thank you for all the work you do here.

Arksine commented 6 years ago

Nice job. I'm hesitant to remove homing from bed_mesh, as its required to actually probe the bed. Perhaps I can add a check to only home if it hasn't already been homed.

aeropic commented 6 years ago

Thanks ! I really think the probe activation should be connected not to a single probe but to the "macro" actions that require a probe:

Concerning homing inside the probing process or not, I would say you could check and forbid the probing if homing is not done, I think this would make a more versatile sofware ... Homing is homing, probing is probing ;-)

Eric, If you're at the origin of the mesh leveling module: congratulations as it was exactly what I wanted before jumping into Klipper's adventure ! Have you seen the other issue I get with too high Z-speed after leveling? I tried to dive into the code but could not figure out where to search...

aeropic commented 6 years ago

I close this one as the #751 is fully covering the only open point (G28)