Klipper3d / klipper

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

Z Offset with BLTouch does not work when printing #3334

Closed Twilek-de closed 4 years ago

Twilek-de commented 4 years ago

I have encountered a weird problem with the Z Offset. I have a CR 10 V3 with BLTouch. I have done the PROBE_CALIBRATION procedure multiple times and always came out with something around 3.5. Having set that lowering the nozzle to the bed manually works fine and I get a good grip on the paper on every part of the bed with the paper test. The moment I start printing the nozzle will fly about a millimeter above the bed and print in the air. After G28 and manually lowering everything is fine again. If I manually compensate for this and set the Z Offset to 4.4 I get a good first layer. This is 100% reproducible

IMG_5536

IMG_5535

This is the height of the nozzle while printing the purge line

IMG_5537

This is the resulting purge line

IMG_5538

This is the nozzle height after g28 and g1 z0

IMG_5541

And this is the purge line after manually overcompensating the z offset to 4.4

klippy.log

Twilek-de commented 4 years ago

Might be the same as this https://github.com/KevinOConnor/klipper/issues/3324 and then again maybe not....

CHILLYSMOKES commented 4 years ago

Comment out the Z-Offset under the Extruder section. Then make sure you are using the offset in the BLTouch section. I had same issue until I did that. Now it works flawlessly.

Twilek-de commented 4 years ago

@CHILLYSMOKES Which entry in my config are you refering to? I can only find a z_offset in the bltouch section. The extruder section has the following settings: [extruder] step_pin = ar26 dir_pin = !ar28 enable_pin = !ar24 step_distance = .002266032 nozzle_diameter = 0.400 filament_diameter = 1.750 pressure_advance = 0.12 pressure_advance_smooth_time = 0.04 heater_pin = ar10 sensor_type = EPCOS 100K B57560G104F sensor_pin = analog13 min_temp = 0 max_temp = 300 control = pid pid_kp = 24.967 pid_ki = 1.290 pid_kd = 120.780

CHILLYSMOKES commented 4 years ago

I meant the stepper_z section... Duh. Sorry. Look in there.

Twilek-de commented 4 years ago

Hmm still not sure ... that section looks like [stepper_z] step_pin = ar46 dir_pin = !ar48 enable_pin = !ar62 step_distance = .0025 position_max = 400 position_min = -3 endstop_pin = probe:z_virtual_endstop

I have searched my whole config for the word "offset" and it only shows up in the bltouch section und in the start print macro (I have tried commenting it out there, but that didn´t help)

Gilabite commented 4 years ago

The z offset is in the bltouch section. If you ran the probe calibration and saved it, it should have automatically commented out the zoffset in the bltouch section and it puts it at the bottom in the do not edit below this block section of the config.

mental405 commented 4 years ago

I would delete the entirety of the section at the bottom of the config that says "DO NO EDIT BELOW THIS LINE".

Then run probe calibrate until you get an offset you like, then be sure to run SAVE_CONFIG

Also, if you happen to be using OctoKlipper, do not edit your config file after running SAVE_CONFIG unless you first close and re-open the OctoPrint browser window.

Twilek-de commented 4 years ago

I am aware how the save config mechanic works and I had only one uncommented z_offset at any given time being it manually entered in the upper bltouch section or auto generated in the lower block with the upper one commented out. That had absolutely no effect on the differences in z offset while manually moving the head and printing.

CHILLYSMOKES commented 4 years ago

Post your printer.cfg please. And check your slicer for Z-Offset.

Twilek-de commented 4 years ago

I am using Cura without any z offset modification that I am aware of.

My printer.cfg looks like this (commenting out the "SET_GCODE_OFFSET Z=0.0" doesn´t change the problem):

#CR-10 V2 PLUS (From Tiny Machines: CR-10 V2 with bl touch and titan direct drive included MAY VARY FROM STANDARD WIRING ON THE BLTOUCH)
[stepper_x]
step_pin: ar54
dir_pin: ar55
enable_pin: !ar38
step_distance: .0125
endstop_pin: ^ar3
position_endstop: 0
position_max: 300
homing_speed: 50

[stepper_y]
step_pin: ar60
dir_pin: ar61
enable_pin: !ar56
step_distance: .0125
endstop_pin: ^ar14
position_endstop: 0
position_max: 300
homing_speed: 50

[stepper_z]
step_pin: ar46
dir_pin: !ar48
enable_pin: !ar62
step_distance: .0025
position_max: 400
position_min: -3
endstop_pin: probe:z_virtual_endstop

[safe_z_home]
home_xy_position: 104.6,150.4 # Change coordinates to the center of your print bed relative to the probe
speed: 50
z_hop: 10
z_hop_speed: 5

[extruder]
step_pin: ar26
dir_pin: !ar28
enable_pin: !ar24
step_distance: .002266032
nozzle_diameter: 0.400
filament_diameter: 1.750
pressure_advance: 0.12
pressure_advance_smooth_time: 0.04
heater_pin: ar10
sensor_type: EPCOS 100K B57560G104F
sensor_pin: analog13
#control: pid
#pid_Kp: 22.2
#pid_Ki: 1.08
#pid_Kd: 114
min_temp: 0
max_temp: 300

[heater_bed]
heater_pin: ar8
sensor_type: ATC Semitec 104GT-2
sensor_pin: analog14
#control: pid
#pid_Kp: 690.34
#pid_Ki: 111.47
#pid_Kd: 1068.83
min_temp: 0
max_temp: 100

[fan]
pin: ar9

[mcu]
serial: /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0
pin_map: arduino

[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 3000
max_z_velocity: 5
max_z_accel: 100

[display]
lcd_type: st7920
cs_pin: ar16
sclk_pin: ar23
sid_pin: ar17
encoder_pins: ^ar33, ^ar31
click_pin: ^!ar35

[bltouch]
sensor_pin: ^ar19
control_pin: ar11
pin_move_time: 0.680
#   The amount of time (in seconds) to wait for the BLTouch pin to
#   move up or down. The default is 0.680 seconds.
stow_on_each_sample: True
probe_with_touch_mode: False
x_offset: 46
y_offset: 2
#Z_offset: 4.200
samples: 1
sample_retract_dist: 2
samples_result: average

[bed_mesh]
speed: 100
horizontal_move_z: 6
mesh_min: 48,6
mesh_max: 300,300
probe_count: 5,5
#fade_start: 1.0
#   The gcode z position in which to start phasing out z-adjustment
#   when fade is enabled.  Default is 1.0.
#fade_end: 10.0
#   The gcode z position in which phasing out completes.  When set
#   to a value below fade_start, fade is disabled. It should be
#   noted that fade may add unwanted scaling along the z-axis of a
#   print.  If a user wishes to enable fade, a value of 10.0 is
#   recommended. Default is 0.0, which disables fade.
#fade_target:
#   The z position in which fade should converge. When this value is set
#   to a non-zero value it must be within the range of z-values in the mesh.
#   Users that wish to converge to the z homing position should set this to 0.
#   Default is the average z value of the mesh.
#split_delta_z: .025
#   The amount of Z difference (in mm) along a move that will
#   trigger a split. Default is .025.
#move_check_distance: 5.0
#   The distance (in mm) along a move to check for split_delta_z.
#   This is also the minimum length that a move can be split. Default
#   is 5.0.
mesh_pps: 2,2
#   A comma separated pair of integers (X,Y) defining the number of
#   points per segment to interpolate in the mesh along each axis. A
#   "segment" can be defined as the space between each probed
#   point. The user may enter a single value which will be applied
#   to both axes.  Default is 2,2.
algorithm: bicubic
#   The interpolation algorithm to use. May be either "lagrange"
#   or "bicubic". This option will not affect 3x3 grids, which
#   are forced to use lagrange sampling.  Default is lagrange.
bicubic_tension: .2
#   When using the bicubic algorithm the tension parameter above
#   may be applied to change the amount of slope interpolated.
#   Larger numbers will increase the amount of slope, which
#   results in more curvature in the mesh. Default is .2.
relative_reference_index: 24
#   A point index in the mesh to reference all z values to. Enabling
#   this parameter produces a mesh relative to the probed z position
#   at the provided index.

[screws_tilt_adjust]
screw1: 0,31
screw1_name: front left screw
screw2: 224,31
screw2_name: front right screw
screw3: 224,273
screw3_name: rear right screw
screw4: 0,273
screw4_name: rear right screw
speed: 50
horizontal_move_z: 10
screw_thread: CW-M3
#   The type of screw used for bed level, M3, M4 or M5 and the
#   direction of the knob used to level the bed, clockwise decrease
#   counter-clockwise decrease.
#   Accepted values: CW-M3, CCW-M3, CW-M4, CCW-M4, CW-M5, CCW-M5.
#   Default value is CW-M3, most printers use an M3 screw and
#   turning the knob clockwise decrease distance.

######################################################################
# Filament sensors
######################################################################

# Filament Switch Sensor.  Support for filament insert and runout detection
# using a switch sensor, such as an endstop switch.
[filament_switch_sensor fsensor]
pause_on_runout: True
#   When set to True, a PAUSE will execute immediately after a runout
#   is detected. Note that if pause_on_runout is False and the
#   runout_gcode is omitted then runout detection is disabled. Default
#   is True.
runout_gcode:
     M117 Filament Runout Detected
     M118 Filament Runout Detected
     M600

insert_gcode:
     M117 Filament inserted
     M300 S125
     M300 S125
     M117 Use menu to load filament
     M118 Use menu to load filament

event_delay: 3.0
#   The minimum amount of time in seconds to delay between events.
#   Events triggered during this time period will be silently
#   ignored. The default is 3 seconds.
pause_delay: 0.5
#   The amount of time to delay, in seconds, between the pause command
#   dispatch and execution of the runout_gcode.  It may be useful to
#   increase this delay if Octoprint exhibits strange pause behavior.
#   Default is 0.5 seconds.
switch_pin: ar2
#   The pin on which the switch is connected. This parameter must be
#   provided.

######################################################################
#MACROS
######################################################################
# Start Print and End Print
######################################################################

# Replace the slicer's custom start and end g-code scripts with
# START_PRINT and END_PRINT.

[gcode_macro START_PRINT]
default_parameter_BED_TEMP: 60
default_parameter_EXTRUDER_TEMP: 205
gcode:
    # Use absolute coordinates
    G90
    # Reset the G-Code Z offset (adjust Z offset if needed)
    SET_GCODE_OFFSET Z=0.0
    #HOME
    M140 S{BED_TEMP}
    M104 S{EXTRUDER_TEMP}
    G28
    # Wait for bed to reach temperature
    M190 S{BED_TEMP}
    # Run Mesh Calibration
    BED_MESH_CALIBRATE
    #LOAD MESH
    BED_MESH_PROFILE LOAD=default
    #Home
    G28
    # Set and wait for nozzle to reach temperature
    M109 S{EXTRUDER_TEMP}
    G92 E0 ;Reset Extruder
    G1 Z2.0 F3000 ;Move Z Axis up
    G1 X10.1 Y20 Z0.28 F5000.0 ;Move to start position
    G1 X10.1 Y200.0 Z0.28 F1500.0 E15 ;Draw the first line
    G1 X10.4 Y200.0 Z0.28 F5000.0 ;Move to side a little
    G1 X10.4 Y20 Z0.28 F1500.0 E30 ;Draw the second line
    G92 E0 ;Reset Extruder
    G1 Z2.0 F3000 ;Move Z Axis up

[gcode_macro END_PRINT]
gcode:
    #Relative positioning
    G91
    #Retract a bit
    G1 E-2 F2700
    #Retract and raise Z
    G1 E-2 Z0.2 F2400
    #Wipe out
    G1 X5 Y5 F3000
    #Raise Z more
    G1 Z10
    #Absolute positionning
    G90
    #Present print
    G1 X0 Y300
    #Turn-off fan, hotend, bed, disable all steppers except Z
    M106 S0
    M104 S0
    M140 S0
    M84 X Y E
    #Clear Mesh
    BED_MESH_CLEAR

[pause_resume]

[gcode_macro PARK_MACRO]
default_parameter_X: 0
default_parameter_Y: -85
default_parameter_Z: 30
gcode:
        M117 PARKING..
        G91
        G1 E-3.14 F1500
        G1 Z{Z}
        G90
        G1 X{X} Y{Y} F3000

[gcode_macro UNLOAD]
gcode:
        G91
        G1 E5.0 F1200
        G1 E3.0 F1600
        G1 E-13.14 F7000
        G1 E-540 F3000
        G90

[gcode_macro M600]
gcode:
        PAUSE_MACRO
        UNLOAD

[gcode_macro PAUSE_MACRO]
gcode:
        PAUSE
        PARK_MACRO

[gcode_macro PURGE]
gcode:
        M117 PURGING..
        G91
        G1 E45.0 F250
        G90

[gcode_macro LOAD_FILAMENT]
gcode:
        M117  LOADING...
        G91
        G1 E25.0 F1000
        G1 E435 F2500
        G4 P900
        G1 E45.0 F250
        G90

[gcode_macro RESUME_MACRO]
gcode:
        M117  RESUMING...
        RESUME

#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [bed_mesh default]
#*# version = 1
#*# points =
#*#     0.110000, 0.105000, 0.110000, 0.110000, 0.070000, 0.045000, 0.050000
#*#     0.142500, 0.125000, 0.102500, 0.090000, 0.040000, 0.000000, -0.020000
#*#     0.177500, 0.147500, 0.105000, 0.072500, 0.002500, -0.060000, -0.105000
#*#     0.160000, 0.107500, 0.042500, 0.000000, -0.077500, -0.152500, -0.185000
#*#     0.182500, 0.100000, 0.007500, -0.047500, -0.152500, -0.232500, -0.285000
#*#     0.145000, 0.017500, -0.087500, -0.165000, -0.272500, -0.347500, -0.390000
#*#     0.120000, 0.005000, -0.140000, -0.240000, -0.360000, -0.462500, -0.497500
#*# tension = 0.2
#*# min_x = 48.0
#*# algo = bicubic
#*# y_count = 7
#*# mesh_y_pps = 2
#*# min_y = 6.0
#*# x_count = 7
#*# max_y = 300.0
#*# mesh_x_pps = 2
#*# max_x = 300.0
#*#
#*# [extruder]
#*# control = pid
#*# pid_kp = 24.967
#*# pid_ki = 1.290
#*# pid_kd = 120.780
#*#
#*# [heater_bed]
#*# control = pid
#*# pid_kp = 72.505
#*# pid_ki = 1.465
#*# pid_kd = 897.251
#*#
#*# [bltouch]
#*# z_offset = 4.350
CHILLYSMOKES commented 4 years ago

Twilek- I see multiple G28 in your start gcode. Did you manually change the very last line?

Twilek-de commented 4 years ago

I cut the last lines straight out of cura, so that I am just using a call to the macro as cura start gcode. But it really can´t be the last line only because the nozzle purge line (the gcodes before that) already have the problem.

Twilek-de commented 4 years ago

As there have been changes to the bed leveling code in the last two days I thought it might be a good idea to update the firmware and I did. It seems to work now, which I guess is good. But I am a bit cautious, as it also worked when I flashed the klipper fw for the first time. I hope it is not something that gets reset when flashing the firmware and then slowly builds up again. We will see I guess.

CHILLYSMOKES commented 4 years ago

Close it then bro. There are other issues still open that are similar enough if they want to monitor. GJ.

Twilek-de commented 4 years ago

I thought to give it a day or two to see wether it stays working. But you are right, I can close it and if necessary open it again.

Twilek-de commented 4 years ago

And it´s back. After several succesfull prints, the nozzle is "air printing" again, as before.... The automatic probe calbration reliably shows a z-offset of 3.5. When printing it is all over the place. This time I had to compensate bei 0.6.

jrgilman commented 4 years ago

@Twilek-de I think I'm having a very similar issue or the same...

My first layer is going down really poorly, specifically in one corner where the nozzle ends up hovering visibly above the build plate. It ends up just dragging the filament along for the ride until it catches. The second layer seems to go down correctly though?

.I've spent 8 hours yesterday and several today trying to square my ender 3 to absolute perfection, along with adjusting the eccentric screw on the x gantry to level the bed as best as humanely possible (with the aid of the bed visualizer).

Problem Corner Image: https://cdn.discordapp.com/attachments/582347488938164240/757297428167655485/image0.jpg GCode for the calibration print (in-case some slicer setting is interfering): http://vpaste.net/DOlMy

CHILLYSMOKES commented 4 years ago

Have you guys tried using bed level compensation instead of mesh?

Twilek-de commented 4 years ago

Nope, but I don´t think that that is the problem. When I lower the nozzle via manual controls to 0 height it will be exactly above the build plate at any xy position as it should. With exactly the same settings it will hover like 2 mm above the plate when trying to go to 0.2 for putting down the first layer. If I go to the same position afterwards and manually go to 0.2 the height is perfect again. And the strangest thing is: the problem went away and came back without me changing any parameters.

jrgilman commented 4 years ago

Have you guys tried using bed level compensation instead of mesh?

As in bed_tilt?

jrgilman commented 4 years ago

@Twilek-de out of desperation I tried switching my algorithm from the default (lagrange) to bicubic in the [bed_mesh] section and I immediately saw a positive improvement in first layer adhesion. Maybe give it a shot?

Twilek-de commented 4 years ago

@Twilek-de out of desperation I tried switching my algorithm from the default (lagrange) to bicubic in the [bed_mesh] section and I immediately saw a positive improvement in first layer adhesion. Maybe give it a shot?

I am running in bicubic mode and again I really don´t think that it is a bed leveling problem. After a bed leveling manual or manually entered gcode driven positioning of the head works perfectly. Start a print and it all goes down the drain. When I have compensated the error the prints will churn out perfectly again. Somehow the software assumes a different Z Offset when printing than when idle. When I enter my reproducibly measurable Z Offset of 3.5 manual positioning will work every time at every position of the bed. I start a print and it adds an extra offset that sometimes changes. I haven´t found out when.

Twilek-de commented 4 years ago

What I haven´t tried yet is what happens when I do a manual positioning after having initiated a bed leveling from the terminal. Until now i have only done manual positioning after a finished print, where the end print macro clears the mesh and cancelled prints with a firmware restart (which shouldn´t clear the mesh, right?!). I will try that when my current print finishes tomorrow and report back.

Twilek-de commented 4 years ago

Ok I have been able to manually reproduce the problem. If I do a BED_MESH_CALIBRATE and the load the profile I will get the flying nozzle even with manual positioning. A PROBE_CALIBRATE will consistently give out a wrong parameter of 3.5 even after Mesh Calibration.

Twilek-de commented 4 years ago

Ok something is indeed off with the bed leveling. I did a manual bed leveling. Then I did a mesh calibrate and saved that. Then I did a probe calibrate (which came up 3.5 again) and saved that. When I now go to Z=0 the nozzle is about 2mm above the bed on every position.

Twilek-de commented 4 years ago

Changed algorithm to lagrange. Same effect. Measured Z Offset is about 2 mm off. Update... Well it is not that far off. I now have set the Offset to 4.0 and with that it lays down a good first layer across the whole bed.

Twilek-de commented 4 years ago

And suddenly it changed. I have done the same print twice directly after one another. The first print went perfectly. After having taken off the modells without any problems or force I started the second print without really checking how the first layer looked, as it had worked just 2 hours ago. This time the print was "rammed" into the build plate. I had to compensate about 0.2 mm afterwards and it then printed fine again.

jrgilman commented 4 years ago

@Twilek-de I ended up figuring out what it was 100%. It had nothing to do with the algorithm and took me all weekend to identify. I have an Ender 3 so very similar to your CR-10. On the right-side of the x-gantry, the nylock nut holding the inner wheel was spinning freely and no longer was holding the wheel against the eccentric nut. I only noticed this when my hand slipped while messing around with the eccentric nut. Once I tightened this down via a ratchet + an allen wrench in the through hole on the other side my problems immediately went away. I would check your nylocks for something similar, just try turning them by hand. They should be snug against the bearings...

image

Edit: added picture of the nut in question.

Twilek-de commented 4 years ago

Wow thanks for the effort with the photo and it is really cool that you have your printer running again. For me I am afraid that wasn´t the solution. All screws and nuts of the X axis were nice and tight.

Twilek-de commented 4 years ago

I have just disabled Klipper and moved back to Marlin as the Z Offset was all over the place. If the problem persists with Marlin I have to seriously take a look at my hardware. If not, something in Klipper is badly broken. I will report back.

Twilek-de commented 4 years ago

I have done several prints with Marlin and haven´t seen any Z Offset problems, so it seems that something in Klipper didn´t work. As I have no further ideas how to solve the issue I will stay with Marlin for now...

Arksine commented 4 years ago

@Twilek-de I just took a look at your issue and I notice that you are using a relative_reference_index in bed_mesh. This setting should only be used if you are homing z with an endstop, as it override's the z-offset applied to the mesh.

Twilek-de commented 4 years ago

@Arksine Thanks! That sounds wildly plausible so I reinstalled and flashed Klipper. Did a new Z-Offset Calibration. The first Calibration Cube I printed wouldn´t stick with the measured offset so I tweaked it manually a bit. I am now on my third Calib Cube and things are very consistent so far. I think you solved the problem. I will monitor the first layers of the next prints very closely.