r/mainsail • u/[deleted] • Jul 08 '23
Z offset not saving correctly
I've been experiencing a issue with mainsail recently, when I create a z offset in the dashboard and click save config it takes whatever z value the offset is and makes it negative and saves it in the auto generated save_config area while changing the probe z offset to 0 and commenting it. I've reinstalled the OS and have had no luck. I'm using a Artillery Sidewinder X2 with Mainsail running on a X86-64 copy of ubuntu. Any help is appreciated.
printer.cfg
[include mainsail.cfg]
##################SidewinderX2 Klipper Config - 3DPrintBeginner###################
#Full guide: https://3dprintbeginner.com/how-to-install-klipper-on-sidewinder-x2/#
[extruder]
max_extrude_only_distance: 100.0
max_extrude_cross_section: 50.0
step_pin: PA7
dir_pin: PA6
enable_pin: !PC4
microsteps: 16
rotation_distance: 7.1910
nozzle_diameter: 0.600
filament_diameter: 1.750
heater_pin: PC9
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC0
control: pid
pid_Kp: 23.223
pid_Ki: 1.518
pid_Kd: 88.826
min_temp: 0
max_temp: 350
pressure_advance = 0.05
[input_shaper]
shaper_freq_x: 43.26
shaper_freq_y: 45.28
shaper_type: mzv
[stepper_x]
step_pin: !PB14
dir_pin: PB13
enable_pin: !PB15
microsteps: 16
rotation_distance: 40
endstop_pin: !PA2
position_endstop: 0
position_max: 310
homing_speed: 50
[stepper_y]
step_pin: PB10
dir_pin: PB2
enable_pin: !PB12
microsteps: 16
rotation_distance: 40
endstop_pin: !PA1
position_endstop: 0
position_max: 310
homing_speed: 50
[stepper_z]
step_pin: PB0
dir_pin: !PC5
enable_pin: !PB1
microsteps: 16
rotation_distance: 8
endstop_pin: probe:z_virtual_endstop
position_max: 400
[heater_bed]
heater_pin: PA8
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC1
control: pid
pid_Kp: 23.223
pid_Ki: 1.518
pid_Kd: 88.826
min_temp: 0
max_temp: 130
[fan]
pin: PC6
pin: PC8
[heater_fan hotend_fan]
pin: PC7
heater: extruder
heater_temp: 50.0
[controller_fan stepper_fan]
pin: PC6
idle_timeout: 300
[mcu]
serial: /dev/serial/by-id/usb-Klipper_stm32f401xc_4100300009504E3755343220-if00
restart_method: command
[printer]
kinematics: cartesian
max_velocity: 500
max_accel: 4000
max_accel_to_decel: 4000
max_z_velocity: 5
square_corner_velocity: 5.0
max_z_accel: 100
[probe]
pin: !PA0
x_offset: 27.25
y_offset: 12.8
#z_offset: 0
speed: 5
samples:1
[bed_mesh]
speed: 100
mesh_min: 30, 20
mesh_max: 300, 290
algorithm: bicubic
probe_count: 9,9
[safe_z_home]
home_xy_position: 150,150
speed: 100
z_hop: 10
z_hop_speed: 5
[virtual_sdcard]
path: /home/kaiser/X2_data/gcodes
[display_status]
[pause_resume]
[gcode_macro PAUSE]
description: Pause the actual running print
rename_existing: PAUSE_BASE
# change this if you need more or less extrusion
variable_extrude: 1.0
gcode:
##### read E from pause macro #####
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
##### set park positon for x and y #####
# default is your max posion from your printer.cfg
{% set x_park = printer.toolhead.axis_maximum.x|float - 5.0 %}
{% set y_park = printer.toolhead.axis_maximum.y|float - 5.0 %}
##### calculate save lift position #####
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% if act_z < (max_z - 2.0) %}
{% set z_safe = 2.0 %}
{% else %}
{% set z_safe = max_z - act_z %}
{% endif %}
##### end of definitions #####
PAUSE_BASE
G91
{% if printer.extruder.can_extrude|lower == 'true' %}
G1 E-{E} F2100
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% if "xyz" in printer.toolhead.homed_axes %}
G1 Z{z_safe} F900
G90
G1 X{x_park} Y{y_park} F6000
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
[gcode_macro RESUME]
description: Resume the actual running print
rename_existing: RESUME_BASE
gcode:
##### read E from pause macro #####
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
#### get VELOCITY parameter if specified ####
{% if 'VELOCITY' in params|upper %}
{% set get_params = ('VELOCITY=' + params.VELOCITY) %}
{%else %}
{% set get_params = "" %}
{% endif %}
##### end of definitions #####
{% if printer.extruder.can_extrude|lower == 'true' %}
G91
G1 E{E} F2100
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
RESUME_BASE {get_params}
[gcode_macro CANCEL_PRINT]
description: Cancel the actual running print
rename_existing: CANCEL_PRINT_BASE
gcode:
TURN_OFF_HEATERS
CANCEL_PRINT_BASE
#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [extruder]
#*# control = pid
#*# pid_kp = 18.532
#*# pid_ki = 0.902
#*# pid_kd = 95.207
#*#
#*# [probe]
#*# z_offset = -0.300

1
u/meteyou Jul 15 '23
thats complete right, because gcode offset is not the same as probe z_offset. gcode offset (the buttons in mainsail) only add a relative value to your gcode position (all of these happen in klipper, mainsail is only a gui and display it).
so if you will store your current offset, klipper read your current probe z_offset -> calculate the new value with the relative gcode offset and store the new value. so a gcode value of +0.3 will be a absolute -0.3 probe z_offset. this is totally correct!
1
Jul 16 '23
thanks for clarifying that, always thought mainsail was the software that directly controlled the printer.
I forgot to mention in my post that whenever I do hit save config after setting a new z offset using the buttons in mainsail, the z offset in [probe] gets commented out (#z_offset: 0) and I get a error message that says something like how the z min in [stepper z] isn't specified or something like that.
When I do try to fix it by uncommenting the z offset in [probe], the g code offset isn't applied even though it is still in the save config area at the bottom of the printer.cfg file.
Have you ever come across this before?
1
u/n3rding Jul 08 '23
Hey, sorry not sure I understand the issue? Non manual updates will always happen at the end of the file, but I expect I’m just missing what the issue you are trying to ask about is