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
[1.1.x] Fix M303 thermal protection #8103 #8126
[1.1.x] Fix M303 thermal protection #8103 #8126
Conversation
The temperature sanity checking logic was not being applied during M303 (pid autotuning) because instead of setting a target temperature, it directly manipulated the pwm values. When PIDTEMP/PIDTEMPBED is enabled, PWM values rather than the target temperature determine whether the heater is on. I changed this to look directly at the PWM amount when pid is enabled.
A good solution! |
Currently, PID autotuning stops if it overshoots the temperature by 20C or if if the temperature does not change for 20 minutes and it times out. I added calls to disable the heaters in these scenarios.
Very Good job .... 👍 |
Hello, sorry for int(er)mission, I checked the pid code and I think we can save up to 2K changing some things, but not sure if this is correct or not
What do you think? |
I wonder if there is some 'dead code' that is being eliminated by the compiler when you make those changes? Can you cut and paste your code here for people to discuss? It would be helpful if you can show in the comments what changed so people can discuss things easier. |
Honestly test was made on 2.0.x-bugfix branch with platformio, sadly with arduino there is no such optimization... |
This is really fun..I made same test again, on 2.0 with platformio, just to be sure I'm not crazy I confirm: o_O |
Aside from trimming potentially dead code, I've noticed Arduino and PlatformIO swapping places a handful of bytes +/- with nearly every change —no rhyme or reason. When I'm struggling to fit into a 128k board, I'll try both and use whichever comes out smaller :) |
Added changes suggested by GMagician.
I implemented the changes that @GMagician suggested which ended up saving me 62 bytes (116,272->116,210) on my arduino mega. |
… into bugfix-1.1.x-HD-CR10 * 'bugfix-1.1.x' of https://github.com/MarlinFirmware/Marlin: (94 commits) [1.1.x] Fix M303 thermal protection MarlinFirmware#8103 (MarlinFirmware#8126) Implement support for Dual X and Y endstops Add Dual Steppers / Endstops to configs Cleanup for DIGIPOTS settings (1.1.x) serious bug G33 Add scripts for .travis.yml to append config options Revert default BABYSTEP_MULTIPLICATOR to 1 Added MKS GEN L board (MarlinFirmware#8088) Concise SD_REPRINT_LAST_SELECTED_FILE description Clean up trailing whitespace (1.1.x) auto tune calibration parameters (MarlinFirmware#8031) Tweak neopixel self-test Add some Polish translations Fix FWRETRACT logic, apply common sense give this language an unique name Initial conflict resolution of SD_REPRINT_LAST_SELECTED_FILE (MarlinFirmware#8104) 1.1.x - save 1400 bytes of FLASH by using reduced font for some languages (MarlinFirmware#8095) More specific M100 description Fix spacing, use single instances of similar pins Encourage users to re-examine their configs ... # Conflicts: # Marlin/Configuration.h # Marlin/Configuration_adv.h
…re#8126) * Fixed M303 thermal protection The temperature sanity checking logic was not being applied during M303 (pid autotuning) because instead of setting a target temperature, it directly manipulated the pwm values. When PIDTEMP/PIDTEMPBED is enabled, PWM values rather than the target temperature determine whether the heater is on. I changed this to look directly at the PWM amount when pid is enabled. * Turn off heaters on M303 error Currently, PID autotuning stops if it overshoots the temperature by 20C or if if the temperature does not change for 20 minutes and it times out. I added calls to disable the heaters in these scenarios. * Removed unnecessary if statement. Added changes suggested by GMagician. * Update temperature.cpp * Update temperature.cpp * Update temperature.cpp
…re#8126) * Fixed M303 thermal protection The temperature sanity checking logic was not being applied during M303 (pid autotuning) because instead of setting a target temperature, it directly manipulated the pwm values. When PIDTEMP/PIDTEMPBED is enabled, PWM values rather than the target temperature determine whether the heater is on. I changed this to look directly at the PWM amount when pid is enabled. * Turn off heaters on M303 error Currently, PID autotuning stops if it overshoots the temperature by 20C or if if the temperature does not change for 20 minutes and it times out. I added calls to disable the heaters in these scenarios. * Removed unnecessary if statement. Added changes suggested by GMagician. * Update temperature.cpp * Update temperature.cpp * Update temperature.cpp
The temperature sanity checking logic was not applied during M303
(pid autotuning) because instead of setting a target temperature, PID_autotune
directly manipulated the pwm values. When PIDTEMP/PIDTEMPBED is
enabled, PWM values rather than the target temperature determine whether
the heater is on. I changed the temperature sanity checking logic to look directly at the PWM values
when pid is enabled.
I tested M303 with the changes and they fix #8103 .
Edit: I also added calls to disable the heaters if PID_autotune errors out.