Skip to content

Commit

Permalink
fixing Qmode velocity caps not being set
Browse files Browse the repository at this point in the history
  • Loading branch information
lhndo committed May 25, 2024
1 parent 12fe0c1 commit ad9276c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PCB/LHS Breakbeat/LHS Breakbeat.kicad_prl
30 changes: 11 additions & 19 deletions Config/Klipper_Config/mymacros.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ variable_q_max_velocity: 200 # Caps max velocity
variable_q_max_accel: 10000 # Caps max accel
variable_q_accel_factor: 1.0 # Acceleration Multiplier
variable_q_min_cruise: 0.4 # Minimum distance to cruise
variable_q_scv: 5
variable_q_scv: 5 # Max SCV
variable_q_stealthchop: False # Enable Stealthchop switching on TMC2240


Expand Down Expand Up @@ -259,7 +259,6 @@ variable_accel: 0
variable_velocity: 0
variable_square_corner_velocity: 0
variable_min_cruise: 0.0
variable_pressure_advance: 0.00
variable_fan_value: 0.00
variable_fan_aux_value: 0.00
variable_fan2_value: 0.00
Expand Down Expand Up @@ -313,17 +312,9 @@ gcode:
gcode:
{% set printer_state = printer.print_stats.state %}
{% set client = printer['gcode_macro _CLIENT_VARIABLE'] %}
SET_GCODE_VARIABLE MACRO=_CLIENT_VARIABLE VARIABLE=q_active VALUE=False


{% if client.q_active == True %}
{% set q_pa = printer['gcode_macro Qmode'].pressure_advance %}
{% if q_pa > 0 %}
SET_PRESSURE_ADVANCE ADVANCE={q_pa}
RESPOND MSG="Pressure Advance Restored to: {q_pa}"
{% else %}
RESPOND MSG="Unable to restore PA. Recalled value is 0"
{% endif %}


SET_VELOCITY_LIMIT ACCEL={printer['gcode_macro Qmode'].accel} VELOCITY={printer['gcode_macro Qmode'].velocity} SQUARE_CORNER_VELOCITY={printer['gcode_macro Qmode'].square_corner_velocity}
SET_VELOCITY_LIMIT MINIMUM_CRUISE_RATIO={printer['gcode_macro Qmode'].min_cruise}
M220 S{printer['gcode_macro Qmode'].speed_factor * 100}
Expand All @@ -345,7 +336,8 @@ gcode:
SET_TMC_FIELD STEPPER=stepper_z FIELD=TPWMTHRS value=1048575
SET_TMC_FIELD STEPPER=stepper_z1 FIELD=TPWMTHRS value=1048575
{% endif %}


SET_GCODE_VARIABLE MACRO=_CLIENT_VARIABLE VARIABLE=q_active VALUE=False
RESPOND TYPE=command MSG='Quiet Mode Disabled'

{% endif %}
Expand Down Expand Up @@ -385,20 +377,20 @@ gcode:
{% else %} # Qmode behaviour

{% if 'VELOCITY' in params %}
{% set get_params = (base_params ~ ' VELOCITY=' ~ [params.VELOCITY | int, client.q_max_velocity] | min | string) %}
{% set get_params = (base_params ~ ' VELOCITY=' ~ [params.VELOCITY | int, client.q_max_velocity | int] | min | string) %}
{% endif %}
{% if 'ACCEL' in params %}
{% set lim_accel = [(params.ACCEL | float * client.q_accel_factor) | int, client.q_max_accel] | min %}
{% set lim_accel = [(params.ACCEL | float * client.q_accel_factor) | int, client.q_max_accel | int] | min %}
{% set get_params = (base_params ~ ' ACCEL=' ~ lim_accel | string) %}
{% endif %}
{% if 'SQUARE_CORNER_VELOCITY' in params %}
{% set get_params = (base_params ~ ' SQUARE_CORNER_VELOCITY=' ~ [params.SQUARE_CORNER_VELOCITY | int, client.q_scv] | min | string) %}
{% set get_params = (base_params ~ ' SQUARE_CORNER_VELOCITY=' ~ [params.SQUARE_CORNER_VELOCITY | int, client.q_scv | int] | min | string) %}
{% endif %}
{% if 'MINIMUM_CRUISE_RATIO' in params %}
{% set get_params = (base_params ~ ' MINIMUM_CRUISE_RATIO=' ~ [params.MINIMUM_CRUISE_RATIO | float, client.q_min_cruise] | max | string) %}
{% set get_params = (base_params ~ ' MINIMUM_CRUISE_RATIO=' ~ [params.MINIMUM_CRUISE_RATIO | float, client.q_min_cruise | float] | max | string) %}
{% endif %}
_SET_VELOCITY_LIMIT {base_params}

_SET_VELOCITY_LIMIT {get_params}

{% endif %}

Expand Down

0 comments on commit ad9276c

Please sign in to comment.