Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Allow setting K values per mesh #28

Open
JohnTasto opened this issue Dec 3, 2020 · 2 comments
Open

Feature request: Allow setting K values per mesh #28

JohnTasto opened this issue Dec 3, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@JohnTasto
Copy link

The results from the Marlin calibration pattern don't seem to translate to real world prints, so I'd like to be able to calibrate K by printing an array of test objects, each with a different K.

Alternatively, if K could be adjusted in the 'ChangeAtZ' post processing plugin, one could create K towers similar to what Klipper provides for calibrating pressure advance. I've already made K towers for my printer by hand editing G Code, but other Marlin users might be interested in K arrays or K towers.

@kdkwarhead
Copy link

”if K could be adjusted in the 'ChangeAtZ' post processing plugin, one could create K towers”
I was about to do this but just found out that you cant do it with'ChangeAtZ'. I hope this will be added to Cura.

@fieldOfView fieldOfView added the enhancement New feature or request label Feb 23, 2021
@exzile
Copy link

exzile commented Jun 23, 2023

I have written a python script to do such, specifically for reprap. I changed this from one that was for marlin that i found on thingiverse. The link is included. This is a post processing script.

Cura PostProcessingPlugin

Author: Dryw Filtiarn

Date: March 01, 2019

Description: This plugin will allow you to create calibration GCode for

testing various values for Jerk on marlin-2.0.x

this plugin should be used alongside the attached test model

as can be found on Thingiverse https://www.thingiverse.com/thing:3463159

`
from ..Script import Script
from UM.Application import Application

class LinAdvanceCalibration(Script):
def init(self):
super().init()

def getSettingDataString(self):
    return """{
        "name": "Pressure Advance Calibration 1.0",
        "key": "PAC1",
        "metadata": {},
        "version": 2,
        "settings":
        {
            "start":
            {
                "label": "Starting value",
                "description": "The value for Jerk  the print will start at. A value of 0.02 is the Marlin default value (range 0.01 - 0.10, default 0.02)",
                "type": "float",
                "default_value": 0.02,
                "minimum_value": 0.01,
                "maximum_value": 0.10,
                "minimum_value_warning": 0.01,
                "maximum_value_warning": 0.10
            },
            "stepsize":
            {
                "label": "Stepping size",
                "description": "The increment with which Jerk  will be increased every 20 layers (range 0.005 - 0.100, default 0.010)",
                "type": "float",
                "default_value": 0.010,
                "minimum_value": 0.005,
                "maximum_value": 0.100,
                "minimum_value_warning": 0.005,
                "maximum_value_warning": 0.100
            }, 
            "layeradjustedat":
            {
                "label": "Layer Which Changes",
                "description": "The increment with which Linear Davnce will be increased every x layers",
                "type": "int",
                "default_value": 20,
                "minimum_value": 1,
                "maximum_value": 100
            },
            "lcdfeedback":
            {
                "label": "Display details on LCD?",
                "description": "This setting will insert M117 gcode instructions, to display current Jerk  value is being used.",
                "type": "bool",
                "default_value": true
            }
        }
    }"""

def execute(self, data):
    uselcd = self.getSettingValueByKey("lcdfeedback")
    start = self.getSettingValueByKey("start")
    incr = self.getSettingValueByKey("stepsize")
    # lps = 20
    lps = self.getSettingValueByKey("layeradjustedat")

    lcd_gcode = 'M118 S"M572 '
    jd_gcode = "M572 D0 S"

    jd = start
    i = 0

    for layer in data:
        lay_idx = data.index(layer)
        
        lcd_out = lcd_gcode + ('%.3f' % jd) + '"'
        jd_out = jd_gcode + ('%.3f' % jd)

        lines = layer.split("\n")
        for line in lines:
            if line.startswith(";LAYER:"):
                lin_idx = lines.index(line)

                if i % lps == 0:
                    lines.insert(lin_idx + 1, jd_out)
                    if uselcd:
                        lines.insert(lin_idx + 2, lcd_out)
                    jd += incr
                        
                i += 1
        
        result = "\n".join(lines)
        data[lay_idx] = result

    return data

    # for layer in data:
    #     display_text = lcd_text + str(i)
    #     layer_index = data.index(layer)
    #     lines = layer.split("\n")
    #     for line in lines:
    #         if line.startswith(";LAYER:"):
    #             line_index = lines.index(line)
    #             lines.insert(line_index + 1, display_text)
    #             i += 1
    #     final_lines = "\n".join(lines)
    #     data[layer_index] = final_lines
        
    # return data

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants