E-Steps is working

This commit is contained in:
sergiuToporjinschi
2022-01-30 20:07:23 +02:00
parent e2a0710442
commit f045c5d1dd
8 changed files with 67 additions and 37 deletions
+2
View File
@@ -7,6 +7,8 @@ from octoprint_CalibrationTools import (api, hooks, models)
defaultSettings = { defaultSettings = {
"eSteps": { "eSteps": {
"userControlsTemp": True,
"turnOffHeater": True,
"extrudeTemp": 210, "extrudeTemp": 210,
"extrudeLength": 100, "extrudeLength": 100,
"extrudeSpeed": 50, "extrudeSpeed": 50,
+3 -1
View File
@@ -34,8 +34,9 @@ class API(octoprint.plugin.SimpleApiPlugin):
) )
def on_api_command(self, command, data): def on_api_command(self, command, data):
self._logger.debug("api command [%s] received", command) self._logger.debug("api command [%s] received payload [%s]", command, data)
if command == CMD_LOAD_STEPS: if command == CMD_LOAD_STEPS:
self._logger.debug("Load steps from EEPROM")
if not self._printer.is_ready(): if not self._printer.is_ready():
self._logger.warning("Printer not ready, operation canceled") self._logger.warning("Printer not ready, operation canceled")
return flask.abort(503, { return flask.abort(503, {
@@ -64,6 +65,7 @@ class API(octoprint.plugin.SimpleApiPlugin):
return return
if command == CMD_SAVE_E_STEPS: if command == CMD_SAVE_E_STEPS:
self._printer.commands(["M92 E%(newESteps)s" % data, "M500"])
return return
if command == CMD_TEST: if command == CMD_TEST:
+1 -2
View File
@@ -13,8 +13,7 @@ class Hooks():
events = [] events = []
def gCodeReceived(self, comm, line, *args, **kwargs): def gCodeReceived(self, comm, line, *args, **kwargs):
if not self.collectCommand: if not self.collectCommand: return line
return line
self._logger.debug("collectCommand is true, collecting info") self._logger.debug("collectCommand is true, collecting info")
reg = re.compile("echo:\s*(?P<command>(?P<gCode>M\d{1,3}) X(?P<xVal>\d{1,3}.\d{1,3}) Y(?P<yVal>\d{1,3}.\d{1,3}) Z(?P<zVal>\d{1,3}.\d{1,3}) E(?P<eVal>\d{1,3}.\d{1,3}))") reg = re.compile("echo:\s*(?P<command>(?P<gCode>M\d{1,3}) X(?P<xVal>\d{1,3}.\d{1,3}) Y(?P<yVal>\d{1,3}.\d{1,3}) Z(?P<zVal>\d{1,3}.\d{1,3}) E(?P<eVal>\d{1,3}.\d{1,3}))")
@@ -14,7 +14,6 @@ $(function () {
self.steps["Y"] = ko.observable(); self.steps["Y"] = ko.observable();
self.steps["Z"] = ko.observable(); self.steps["Z"] = ko.observable();
self.steps["E"] = ko.observable(); self.steps["E"] = ko.observable();
self.results = {};
self.testParam = {}; self.testParam = {};
self.testParam["extrudeTemp"] = ko.observable(210); self.testParam["extrudeTemp"] = ko.observable(210);
@@ -22,17 +21,23 @@ $(function () {
self.testParam["extrudeSpeed"] = ko.observable(50); self.testParam["extrudeSpeed"] = ko.observable(50);
self.testParam["markLength"] = ko.observable(120); self.testParam["markLength"] = ko.observable(120);
self.results = {};
self.results["remainedLength"] = ko.observable(20); self.results["remainedLength"] = ko.observable(20);
self.results["actualExtrusion"] = ko.computed(function () { self.results["actualExtrusion"] = ko.computed(function () {
return (self.testParam.markLength() - self.results.remainedLength()).toFixed(3); return (self.testParam.markLength() - self.results.remainedLength()).toFixed(3);
}); });
self.results["newSteps"] = ko.computed(function () { self.results["newSteps"] = ko.computed(function () {
return (self.steps.E() / self.results.actualExtrusion() * 100).toFixed(3); return (self.steps.E() / self.results.actualExtrusion() * 100).toFixed(3);
}); });
self.results["newStepsDisplay"] = ko.computed(function () {
return "M92 E" + self.results.newSteps() ;
});
self.onBeforeBinding = self.onUserLoggedIn = self.onUserLoggedOut = function () { self.onBeforeBinding = self.onUserLoggedIn = self.onUserLoggedOut = function () {
self.testParam.extrudeTemp(self.settingsViewModel.settings.plugins.CalibrationTools.eSteps.extrudeTemp());
self.testParam.extrudeLength(self.settingsViewModel.settings.plugins.CalibrationTools.eSteps.extrudeLength());
self.testParam.extrudeSpeed(self.settingsViewModel.settings.plugins.CalibrationTools.eSteps.extrudeSpeed());
self.testParam.markLength(self.settingsViewModel.settings.plugins.CalibrationTools.eSteps.markLength());
self.is_admin(self.loginStateViewModel.isAdmin()); self.is_admin(self.loginStateViewModel.isAdmin());
} }
@@ -51,7 +56,7 @@ $(function () {
} }
self.loadESteps = function () { self.loadESteps = function () {
OctoPrint.simpleApiCommand("CalibrationTools","loadSteps").done(function (response) { OctoPrint.simpleApiCommand("CalibrationTools", "loadSteps").done(function (response) {
self.from_json(response); self.from_json(response);
}) })
} }
@@ -71,7 +76,15 @@ $(function () {
OctoPrint.system.executeCommand("core", "restart"); OctoPrint.system.executeCommand("core", "restart");
} }
self.saveESteps = function () { self.saveESteps = function () {
OctoPrint.system.executeCommand("core", "restart"); OctoPrint.simpleApiCommand("CalibrationTools", "saveESteps", {
"newESteps": self.results.newSteps()
}).done(function () {
new PNotify({
title: "Saved",
text: self.results.newSteps() + " steps/mm had been set for E axe",
type: "info"
});
});
} }
self.onAllBound = self.onEventConnected = function () { self.onAllBound = self.onEventConnected = function () {
@@ -1,29 +1,26 @@
{% import "macros.jinja2" as snipped %} {% import "macros.jinja2" as snipped %}
{{ snipped.subSection("E-Steps default settings", true) }} {{ snipped.subSection("E-Steps default settings", true) }}
<div class="row-fluid">
<div class="span6"><label class="checkbox pull-right" style="margin-top: 5px;" for="userControlsTemp">Let me to control temperature</label></div>
<div class="span6"><input id="userControlsTemp" type="checkbox" data-bind="checked: settings.plugins.CalibrationTools.eSteps.userControlsTemp"></div>
</div>
<div class="row-fluid">
<div class="span6"><label class="checkbox pull-right" style="margin-top: 5px;" for="turnOffHeater">Cooldown extruder when saving to EEPROM</label></div>
<div class="span6"><input id="turnOffHeater" type="checkbox" data-bind="checked: settings.plugins.CalibrationTools.eSteps.turnOffHeater"></div>
</div>
{{ snipped.field("Extrusion temperature", "The temperature used to extrude in testing&#013;Is better to be a bit higher then usual for reducing the nuzzle pressure", {{ snipped.field("Extrusion temperature", "The temperature used to extrude in testing&#013;Is better to be a bit higher then usual for reducing the nuzzle pressure",
"number", "settings.plugins.CalibrationTools.eSteps.extrudeTemp", "true", "&ordmC", 1) }} "number", "settings.plugins.CalibrationTools.eSteps.extrudeTemp", "true", "&ordmC", 1) }}
{{ snipped.field("Filament extrusion length", "The length of filament to be extruded in testing", {{ snipped.field("Filament extrusion length", "The length of filament to be extruded in testing",
"number", "settings.plugins.CalibrationTools.eSteps.extrudeLength", "true", "mm", 1) }} "number", "settings.plugins.CalibrationTools.eSteps.extrudeLength", "true", "mm", 1) }}
{{ snipped.field("Filament extrusion speed", "How fast the filament should be extruded in test&#013;A lower value is recommended for avoiding skipping steps", {{ snipped.field("Filament extrusion speed", "How fast the filament should be extruded in test&#013;A lower value is recommended for avoiding skipping steps",
"number", "settings.plugins.CalibrationTools.eSteps.extrudeSpeed", "true", "mm/s", 1) }} "number", "settings.plugins.CalibrationTools.eSteps.extrudeSpeed", "true", "mm/s", 1) }}
{{ snipped.field("Filament mark length", "The length marked on filament", {{ snipped.field("Filament mark length", "The length marked on filament",
"number", "settings.plugins.CalibrationTools.eSteps.markLength", "true", "mm") }} "number", "settings.plugins.CalibrationTools.eSteps.markLength", "true", "mm") }}
<!-- <div class="row-fluid"> {{ snipped.subSection("X-Y-Z-Steps", true) }}
<div class="span6">
<label for="temperature" class="pull-right" style="margin-top: 5px;" title="x"> {{ snipped.subSection("PID", true) }}
Heating
</label>
</div>
<div class="span6">
<div class="input-prepend input-append">
<span class="add-on" title="Command to preheat the tool before testing">M104 &nbsp&nbsp&nbspS</span>
<input type="number" id="temperature" title="The temperature used to extrude in testing&#013;Is better to be a bit higher then usual for reducing the nuzzle pressure" class="input-mini" step="1"
data-bind="value: $root.testParam.extrudeTemp">
</div>
</div>
</div> -->
@@ -11,9 +11,10 @@
</div> </div>
{% endmacro %} {% endmacro %}
{% macro quote(content, class) %} {% macro quote(content, cite, class) %}
<blockquote> <blockquote>
<p class="{{ class }}">{{ _(content) }}</p> <p class="{{ class }}">{{ _(content) }}</p>
<small>{{ cite }}</small>
</blockquote> </blockquote>
{% endmacro %} {% endmacro %}
@@ -27,7 +28,7 @@
</div> </div>
<div class="span6"> <div class="span6">
<div class="input-append"> <div class="input-append">
<input type="{{ type }}" id="{{ label }}" title="{{ title }}" class="input-small" step="{{ step }}" data-bind="value: {{ binding }}, enable: {{ enable }}"> <input type="{{ type }}" id="{{ label }}" title="{{ title }}" class="input-small" step="{{ step }}" data-bind="value: {{ binding }}, enable: {{ enable }}">
<span class="add-on" title="{{ title }}">{{ _(unit) }}</span> <span class="add-on" title="{{ title }}">{{ _(unit) }}</span>
</div> </div>
</div> </div>
@@ -1,3 +1,4 @@
Something in documentation tab... Something in documentation tab...
<strong data-bind="text: gettext('test')"></strong>
@@ -2,7 +2,7 @@
{{ snipped.subSection("Test parameters", true) }} {{ snipped.subSection("Test parameters", true) }}
<!-- G1 E100 F50 command --> <!-- M104 S210 command -->
<div class="row-fluid"> <div class="row-fluid">
<div class="span6"> <div class="span6">
<label for="temperature" class="pull-right" style="margin-top: 5px;" title="x"> <label for="temperature" class="pull-right" style="margin-top: 5px;" title="x">
@@ -11,13 +11,14 @@
</div> </div>
<div class="span6"> <div class="span6">
<div class="input-prepend input-append"> <div class="input-prepend input-append">
<span class="add-on" title="Command to preheat the tool before testing">M104 &nbsp&nbsp&nbspS</span> <span class="add-on" title="Command to preheat the tool before testing">M104&nbsp;&nbsp;&nbsp;S</span>
<input type="number" id="temperature" title="The temperature used to extrude in testing (&#186;C)&#013;Is better to be a bit higher then usual for reducing the nuzzle pressure" class="input-mini" step="1" <input type="number" id="temperature" title="The temperature used to extrude in testing (&#186;C)&#013;Is better to be a bit higher then usual for reducing the nuzzle pressure" class="input-mini" step="1"
data-bind="value: $root.testParam.extrudeTemp"> data-bind="value: $root.testParam.extrudeTemp">
</div> </div>
</div> </div>
</div> </div>
<!-- G1 E100 F50 command -->
<div class="row-fluid"> <div class="row-fluid">
<div class="span6"> <div class="span6">
<label for="extrusionLenSpeed" class="pull-right" style="margin-top: 5px;" title="x"> <label for="extrusionLenSpeed" class="pull-right" style="margin-top: 5px;" title="x">
@@ -26,10 +27,10 @@
</div> </div>
<div class="span6"> <div class="span6">
<div class="input-prepend input-append"> <div class="input-prepend input-append">
<span class="add-on" title="Command to extrude filament for testing">G1&nbsp&nbsp&nbspE</span> <span class="add-on" title="Command to extrude filament for testing">G1&nbsp;&nbsp;&nbsp;E</span>
<input type="number" id="extrusionLenSpeed" title="The length of filament to be extruded in testing (in millimeters)" class="input-mini" step="1" <input type="number" id="extrusionLenSpeed" title="The length of filament to be extruded in testing (in millimeters)" class="input-mini" step="1"
data-bind="value: $root.testParam.extrudeLength"> data-bind="value: $root.testParam.extrudeLength">
<span class="add-on" title="Command to extrude filament for testing">&nbsp&nbsp&nbspF</span> <span class="add-on" title="Command to extrude filament for testing">&nbsp;&nbsp;&nbsp;F</span>
<input type="number" id="extrusionLenSpeed" title="The speed to extrude filament in testing&#013;Lowest possible (mm/s)" class="input-mini" step="1" <input type="number" id="extrusionLenSpeed" title="The speed to extrude filament in testing&#013;Lowest possible (mm/s)" class="input-mini" step="1"
data-bind="value: $root.testParam.extrudeSpeed"> data-bind="value: $root.testParam.extrudeSpeed">
</div> </div>
@@ -72,7 +73,22 @@
{{ snipped.field("Length after extrusion", "The remained length between filament mark and extruder entry", "number", "$root.results.remainedLength", "true", "mm") }} {{ snipped.field("Length after extrusion", "The remained length between filament mark and extruder entry", "number", "$root.results.remainedLength", "true", "mm") }}
{{ snipped.field("Actual extrusion", "How much filament has been extruded", "number", "$root.results.actualExtrusion", "false", "mm") }} {{ snipped.field("Actual extrusion", "How much filament has been extruded", "number", "$root.results.actualExtrusion", "false", "mm") }}
{{ snipped.field("New steps/mm", "The new number of steps/mm which should be set on EEPROM", "number", "$root.results.newSteps", "false", "steps/mm") }}
<!-- M92 E900 -->
<div class="row-fluid">
<div class="span6">
<label for="newESteps" class="pull-right" style="margin-top: 5px;" title="The new calculated number of steps/mm for E axe">
New E axe steps/mm
</label>
</div>
<div class="span6">
<div class="input-prepend input-append">
<span class="add-on" title="Command to change number of steps/mm for E axe" data-bind="text: $root.results.newStepsDisplay"></span>
<span class="add-on" title="Command for saving steps in EEPROM">M500</span>
</div>
</div>
</div>
<div class="row-fluid" style="margin-bottom: 5px;"> <div class="row-fluid" style="margin-bottom: 5px;">
<div class="span6"></div> <div class="span6"></div>
<div class="span6"> <div class="span6">
@@ -87,10 +103,9 @@
{{ snipped.subSection("Process description", true) }} {{ snipped.subSection("Process description", true) }}
{{ snipped.quote(" {{ snipped.quote("
First <a href='https://teachingtechyt.github.io/calibration.html#esteps' target='_blank'>Read this</a><br><br>
This calibration is best done with the extruder detached from the hot end, so no restriction is present on the movement. If it is convenient, you can partially disassemble the printer so the output of the extruder is This calibration is best done with the extruder detached from the hot end, so no restriction is present on the movement. If it is convenient, you can partially disassemble the printer so the output of the extruder is
open and the filament exits in free air. If this is inconvenient, the process below aims to minimize restrictions by extruding very slowly and with a slightly higher temperature. The results from this should still be open and the filament exits in free air. If this is inconvenient, the process below aims to minimize restrictions by extruding very slowly and with a slightly higher temperature. The results from this should still be
reliable. reliable.
", "text-warning" ) }} ", "
<a href='https://teachingtechyt.github.io/calibration.html#esteps' target='_blank'>teachingtechyt.github.io</a>
<strong data-bind="text: gettext('test')"></strong> ", "text-warning") }}