RFC: Cooperative Heaters predictive control#6837
RFC: Cooperative Heaters predictive control#6837nefelim4ag wants to merge 2 commits intoKlipper3d:masterfrom
Conversation
097a22c to
1b115b6
Compare
|
Nice! |
1b115b6 to
e5001e1
Compare
e5001e1 to
5b36fbe
Compare
I imported some changes from there, and I hope, now it is a little better. |
|
From the eyes emoticon, I gather you found my comment confusing. What I tried to say: The display template functions in Klipper for LEDs and fans (example) seem to be using the same overarching logic, albeit with a bit of different nomenclature. |
I got the idea of what you meant after your comment in the temperature_fan PR. Thanks for checking. I was totally unaware of that functionality, now I will try to wrap my head around it. |
|
I don't know how I feel about adding a G-code command to reload the template or directly alter the PWM output. So, for now, I only leave here a bare config binding between template and heater. Thanks. |
|
Interesting. I'm not sure this implementation is safe though, as the PID I suspect we could alter the target temperature from templates without thread issues (or set a temperature offset), but I'm not sure if that's what you are looking for. Still interesting though. |
I will change it to run in a similar fashion to current fan/led templates in the main/reactor thread.
AFAIK, it is only useful if the target is to use variable extrusion temperature based on the flow. AFAIK, there is at least one project for that: https://github.com/sb53systems/G-Code-Flow-Temperature-Controller It can be made on the Klipper side, but I suspect it is requires different design to trigger temperature changes ahead and do other stuff like accounting for thermal inertia/slow down printing. Thanks. |
|
Thank you for your contribution to Klipper. Unfortunately, a reviewer has not assigned themselves to this GitHub Pull Request. All Pull Requests are reviewed before merging, and a reviewer will need to volunteer. Further information is available at: https://www.klipper3d.org/CONTRIBUTING.html There are some steps that you can take now:
Unfortunately, if a reviewer does not assign themselves to this GitHub Pull Request then it will be automatically closed. If this happens, then it is a good idea to move further discussion to the Klipper Discourse server. Reviewers can reach out on that forum to let you know if they are interested and when they are available. Best regards, PS: I'm just an automated script, not a human being. |
77f03eb to
fbfecee
Compare
|
I realized there is no example, so this one is for the extruder heater with accounting for fan losses and the losses due to the volumetric flow. |
|
Example of 2 termistors bed control to limit the bed heater temperature. [display_template bed_limiter]
text:
{% set bed_heater_temp = printer['temperature_sensor bed_heater'].temperature | float %}
{% set max_temp = 100 %}
{% set range = 5 %}
{% set proportional_damping = (bed_heater_temp - (max_temp - range / 2))/range %}
{0 if proportional_damping < 0 else proportional_damping * -1 }
[heater_pc heater_bed]
macro_template: bed_limiterThis is my example of reducing the chamber heater power until the heater bed is done to heat, to limit the peak power. [display_template chamber]
text:
{ -1.0 * printer["heater_bed"].power }
[heater_pc chamber]
macro_template: chamber
|
400fda4 to
3e5fc95
Compare
3e5fc95 to
bbfffa7
Compare
15daf6d to
40054ce
Compare
40054ce to
04b7f25
Compare
2909ce7 to
c6937ee
Compare
c6937ee to
2517b47
Compare
2517b47 to
aa4484e
Compare
|
I had a long idea that my initial implementation with hooks into the PID loop is hacky. So, here is internal refactoring for the heaters' control, which now returns control output. The same refactoring can be done for the fans, where the same control loop can be reused; the only difference is that temperature fans need to invert the control output, basically do With that, it is possible to later reuse the existing PID_CALIBRATE for the fans. Thanks, Hmmm, Reused |
This allows to chain the control later, or reuse same control loops for the fan for example Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
Allows for the amendment of the real control loop with feed-forward control Feed-forward allows for the implementation of advanced control, such as "dual loop", using data from several temperature sensors. Increase/decrease power beforehand without PID reactive lag. Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
aa4484e to
043bb12
Compare
Some time ago I dug heaters a little on the Discourse
I don't think PID is bad or needs to be replaced.
I tried to do some fun stuff, like train DNN or write my own algo to control the power.
In the end, everything looks the same.
There are historically various topics, that try to replace it or tune it differently.
I think the only practical reason is to handle something important for that human being.
So, there is an ultimate solution, I think.
Pid is still under the control of a heater and is able to drive it.
The end-user has the ability to adjust it freely, like in my doc example - drive PWM in a feedforward way if the fan is suddenly enabled, like for bridges.
If it is needed, it is definitely possible to get the current chamber temperature, adjust to the fan curve, try to parse the extruder moving queue (IDK) and drive PWM higher before the temperature falls and PID will reactively compensate for that.
I hope that will add enough flexibility to stop rituals like "how to do PID autotune properly".
Another example, for some reason people do not insulate the heating beds, adding thermistors inside a thick aluminum plate and then want sort of PID control by two thermistors, and feel that combined sensor is not good enough.
Well, now it is possible to literally query the sensors and decide what to do, like return the
-Nvalue and decrease bed heater power on demand.I hope it is made in a way to is safe and acceptable, leaves all existing safety measures in place, and mostly does not touch safety-critical code.
Thanks.
Btw, I will try to add templates to temperature FANs in a similar way, to fit most of the wishes, like curves, formulas & etc.