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

RFC: Cooperative Heaters predictive control #6837

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

nefelim4ag
Copy link
Contributor

@nefelim4ag nefelim4ag commented Feb 25, 2025

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 -N value 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.

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
@nefelim4ag nefelim4ag changed the title Cooperative Heaters predictive control RFC: Cooperative Heaters predictive control Feb 25, 2025
@nefelim4ag nefelim4ag force-pushed the heaters-predictive-control branch 2 times, most recently from 6d385ad to b56d658 Compare February 25, 2025 20:45
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
@nefelim4ag nefelim4ag force-pushed the heaters-predictive-control branch 3 times, most recently from 097a22c to 1b115b6 Compare February 26, 2025 01:42
@Sineos
Copy link
Collaborator

Sineos commented Feb 26, 2025

Nice!
It seems to follow the same logic as display templates. Maybe stick to the general wording and naming from there?

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
@nefelim4ag nefelim4ag force-pushed the heaters-predictive-control branch from e5001e1 to 5b36fbe Compare February 27, 2025 00:04
@nefelim4ag
Copy link
Contributor Author

Maybe stick to the general wording and naming from there?

I imported some changes from there, and I hope, now it is a little better.

@Sineos
Copy link
Collaborator

Sineos commented Feb 27, 2025

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.
Maybe I'm misunderstanding something?

@nefelim4ag
Copy link
Contributor Author

nefelim4ag commented Feb 27, 2025

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.
I'm looking for what can be done to make it similar to current integration with `[display_templates]'.
The current integration feels a little unintuitive from my perspective, but it is better to reuse it, of course.

Thanks for checking. I was totally unaware of that functionality, now I will try to wrap my head around it.

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
@nefelim4ag
Copy link
Contributor Author

I don't know how I feel about adding a G-code command to reload the template or directly alter the PWM output.
I also think it is wrong to add custom value get/set/log functions to all templates by incorporating them in display_template.
So, I dropped them for now.

So, for now, I only leave here a bare config binding between template and heater.
If it is needed, technically, temperature and read time can be propagated in the template context.
But I think they are mostly useless without state management inside macro.

Thanks.

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

Successfully merging this pull request may close these issues.

2 participants