Bed pid working
This commit is contained in:
@@ -24,6 +24,10 @@ allPIDsFormats = r".*p:{0,1}\s{0,1}?(?P<p>\d{1,3}.\d{1,3})\sk*i:{0,1}\s{0,1}?(?P
|
||||
class API(octoprint.plugin.SimpleApiPlugin):
|
||||
pidHotEndCycles = []
|
||||
pidCurrentValues = {}
|
||||
pidHotEndCycles = {
|
||||
"hotEnd": [],
|
||||
"bed":[]
|
||||
}
|
||||
#catch for "echo: p:28.27 i:2.82 d:70.81" or "M301 P27.08 I2.51 D73.09"
|
||||
getPid = re.compile(allPIDsFormats, flags=re.IGNORECASE)
|
||||
@staticmethod
|
||||
@@ -32,7 +36,7 @@ class API(octoprint.plugin.SimpleApiPlugin):
|
||||
CMD_PID_LOAD_CURRENT_VALUES: [],
|
||||
CMD_PID_SAVE : [],
|
||||
CMD_PID_GET_VALUES: [],
|
||||
CMD_PID_START: ["fanSpeed", "noCycles", "hotEndIndex", "targetTemp"]
|
||||
CMD_PID_START: ["heater", "fanSpeed", "noCycles", "hotEndIndex", "targetTemp"]
|
||||
}
|
||||
|
||||
def apiGateWay(self, command, data):
|
||||
@@ -52,16 +56,16 @@ class API(octoprint.plugin.SimpleApiPlugin):
|
||||
})
|
||||
|
||||
if command == CMD_PID_START:
|
||||
self.pidHotEndCycles = {
|
||||
"hotEnd": [],
|
||||
"bed":[]
|
||||
}
|
||||
self.pidHotEndCycles[data["heater"]] = []
|
||||
#Two cycles are for tuning
|
||||
for i in range(0, data['noCycles'] - 2):
|
||||
#response type !!DEBUG:send Kp: 30.56 Ki: 3.03 Kd: 77.16
|
||||
self.registerRegexMsg(self.getPid, self.m106CodeResponse, data["heater"])
|
||||
|
||||
self._printer.commands(["M106 S%(fanSpeed)s" % data, "M303 C%(noCycles)s E%(hotEndIndex)s S%(targetTemp)s U1" % data])
|
||||
if data["heater"] == "bed":
|
||||
data["hotEndIndex"] = -1
|
||||
|
||||
self._printer.commands(["M106 S%(fanSpeed)s" % data, "M303 C%(noCycles)s E%(hotEndIndex)s S%(targetTemp)s U1" % data, "M500"])
|
||||
|
||||
if command == CMD_PID_SAVE:
|
||||
self._logger.debug("DIPSave-")
|
||||
|
||||
@@ -68,6 +68,7 @@ $(function () {
|
||||
|
||||
self.startPidHotEnd = function () {
|
||||
OctoPrint.simpleApiCommand("CalibrationTools", "pid_start", {
|
||||
"heater": "hotEnd",
|
||||
"fanSpeed": Number(self.pid.hotEnd.fanSpeed()),
|
||||
"noCycles": Number(self.pid.hotEnd.noCycles()),
|
||||
"hotEndIndex": Number(self.pid.hotEnd.hotEndIndex()),
|
||||
@@ -93,7 +94,7 @@ $(function () {
|
||||
"heater": "bed",
|
||||
"fanSpeed": self.pid.bed.fanSpeed(),
|
||||
"noCycles": self.pid.bed.noCycles(),
|
||||
"hotEndIndex": self.pid.bed.hotEndIndex(),
|
||||
"hotEndIndex": -1,
|
||||
"targetTemp": self.pid.bed.targetTemp()
|
||||
}).done(function (response) {
|
||||
new PNotify({
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
<button class="btn btn-success" data-bind="click: $root.startPidHotEnd, enable: $root.controlViewModel.isOperational() && (!$root.controlViewModel.isPrinting())"
|
||||
title="This will trigger PID auto tuning (M106 Sx; M303 Ex Sx U1; M500)">
|
||||
<i class="fas fa-play" style="color:false" data-color="false"></i>  
|
||||
Start hot-end PID tunning
|
||||
Start hot-end PID auto-tunning
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -106,7 +106,7 @@
|
||||
<div class="input-prepend input-append">
|
||||
{{ snipped.linkToMarlin("M106", "Marlin website") }}
|
||||
<span class="add-on" title="Command for turning the fan to 100%">M106 S</span>
|
||||
<input type="number" id="fanSpeed" title="Command for turning the fan to 100%" class="input-mini" step="1" min="0" max="255" data-bind="value: $root.pid.fanSpeed">
|
||||
<input type="number" id="fanSpeed" title="Command for turning the fan to 100%" class="input-mini" step="1" min="0" max="255" data-bind="value: $root.pid.bed.fanSpeed">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -119,12 +119,12 @@
|
||||
<div class="span7">
|
||||
<div class="input-prepend input-append">
|
||||
{{ snipped.linkToMarlin("M303", "Marlin website") }}
|
||||
<span class="add-on" title="Command for triggering bed PID tunning">M304 C</span>
|
||||
<span class="add-on" title="Command for triggering bed PID tunning">M303 C</span>
|
||||
<input type="number" id="tunningPIDNoCycles" class="input-mini" step="1" min="0" title="Number of cycles to run in tuning" data-bind="value: $root.pid.bed.noCycles">
|
||||
<span class="add-on" title=""> E</span>
|
||||
<input type="number" id="tunningPIDBed" class="input-mini" step="1" min="0" title="Bed index" data-bind="value: $root.pid.bed.index, enable: false">
|
||||
<span class="add-on" title=""> S</span>
|
||||
<input type="number" id="tunningPIDBedTemp" class="input-mini" step="1" min="20" max="80" title="Target temperature" data-bind="value: $root.pid.bed.targetTemp">
|
||||
<input type="number" id="tunningPIDBedTemp" class="input-mini" step="1" min="10" max="100" title="Target temperature" data-bind="value: $root.pid.bed.targetTemp">
|
||||
<span class="add-on" title=""> U1</span>
|
||||
{{ snipped.m500Icon() }}
|
||||
</div>
|
||||
@@ -135,9 +135,9 @@
|
||||
<div class="span5"></div>
|
||||
<div class="span7">
|
||||
<button class="btn btn-success" data-bind="click: $root.startPidBed, enable: $root.controlViewModel.isOperational() && (!$root.controlViewModel.isPrinting())"
|
||||
title="This will trigger PID auto tuning (M304 E-1 Sx U1; M500)">
|
||||
title="This will trigger PID auto tuning (M303 E-1 Sx U1; M500)">
|
||||
<i class="fas fa-play" style="color:false" data-color="false"></i>  
|
||||
Start bed PID tunning
|
||||
Start bed PID auto-tunning
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user