-
Notifications
You must be signed in to change notification settings - Fork 14
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
Shutdown printer #56
Comments
Most of us initially involved only had the 5m available. It is likely the software power button was never implemented properly. @consp , @xblax I would be a bit against a full shutdown. If the printer is turned off right after a print is completed, without cooling the nozzle down first, there is a real risk of clogging while using materials like PLA because of the heat creep. |
Shutdown in Mainsail just does the same as Pretty sure it can be implemented but someone with the 5M Pro has to reverse engineer how that function works with the stock firmware. There are some hidden pins in the printer config, that I assume are used for this in the stock firmware.
@KaruroChori Afaik Afaik that physical power button on the Pro actually cuts the power (including the PSU). But somebody has to confirm that. Would also be good to know how the power button is wired to the Mainboard. Could be an interesting upgrade for 5M non pro as well. |
I have read multiple reports of people complaining about the psu fan noise while putting the printer in stand-by with that button, which is where my assumptions came from. I have to check the schematics in the research repo of @g992 |
Looking at the PCBs the Pro has a different power connector with a mosfet next to it. |
https://github.com/g992/flashforge-ad5m-5mpro-research/blob/main/photo/_5m_full_view_marked.png On the base model the area marked as 6 is just not populated. |
If that's for the power switch, i would really like to know what they switch with it 🤣 it's a lot of stuff for a simple momentary button and software shutdown. Btw, I ordered a pro. My custom old enclosures hinges broke yesterday and figured might as well replace it with a pro since I do not want to glue everything together again, so I'll be able to test that as well. |
Would have been my guess anyway (sarcasm doesn't show well in text), but does it do it via the NC32 chip (and thus klipper), the sunxi chip or is it wired straight through? |
|
Should be doable to do a partial shutdown (sync, umount usb, shutdown everything which might write except for klipper) and then kill the power if it's controllable from the linux part. Complete proper shutdown would be more difficult if it needs uart to klipper but not impossible. Wonder if it's a latch with multiple inputs or something else entirely, maybe I'm overthinking it. |
Sending 0 to power_off does a hard shutdown (kills power and psu goes into "low" mode) I see no real point in exposing the power pins directly though, maybe something like this for start?
Can be triggered by the power button in that case. Could also make a shutdown script to complete first (sync, umount usb, shutdown all except klipper, kill power) |
@consp Power pins should not be exposed directly. Via Macro it's also easier to have it only for the 5M Pro. Maybe the macro should not be allowed while printing (look at REBOOT_STOCK_SYSTEM for example). Sync before shutdown should be enough. I always shutdown the printer by just killing the power. Had no problem with this so far. |
The doPowerOff function calls I would not be surprised if the other pin is just set during boot (at default value) and not used otherwise like the PE1 pin for the runout sensor. Can find no reference to it at least. There is also a "powerSavingMode" but I cannot make heads or tails of it what it does, doesn't call any macro's at least. |
So this is the idea: Add _POWER_OFF gcode, not to be triggered by the user:
Add script to stop everything (so it should be graceful, log wise etc)
And the main course gcode (synchonous is by design):
And code to trigger via button press, it triggers M105 (report temps):
Triggering SHUTDOWN should be a "graceful" end of operation. Todo is a nice fat warning in klipperscreen before commencing but that's for another day as it requires communication. Let me know if this is desireable. Another question I have if someone knowns if klipper has shutdown guards, e.g. a variable which says "of this is not [something] you cannot shutdown", if it does it should be checked before triggering. |
@consp We can also make the Macro compatible with the regular 5M, by issuing I think the warning can be done similar to the exiting Reboot macros. Or does that not work with klipperscreen? |
Probably better yes, was my initial thought as well but I had some issues with it ignoring the ignoring of the klipper shutdown. So this was a first attempt.
Good point, that should work universally since the power is off anyway for the pro. User must still disable it then for the non-pro. Can also send an image to the FB, should be on display until power off, like the infamous windows 95 "it's safe to turn off your computer now".
I must confess I have not looked into it yet. You mean the (firmware) restart macros? I know notifications show up but not interactive messages. |
Should be interactive confirm, but have not tried it in Klipperscreen. Can do it tonight.
On second though, regular 5M already has safe shutdown via the default Shutdown menu in Mainsail/Fluidd. That triggers "systemctl poweroff" command via Moonraker (afaik not a Klipper Macro). We can just add the "safe to turn off" now as S00shutdown_screen script init init.d |
No message is displayed in klipperscreen (bit as expected). It's an internal mainsail/fluidd thing. |
But KlipperScreen Docs say it supports Macro Prompts: |
Yes, figured that out while you posted:
Shows the prompt. |
Version now ask the question, shuts down all except klipper, sync and umounts and then either does "systemctl poweroff" or kills the power. Last thing to do is the shutdown message. Also responds to button with the same question and effect. Tweaking it a little bit and then I'll push a feature branch. |
Pushed to https://github.com/xblax/flashforge_adm5_klipper_mod/tree/feature/shutdown The shutdown in mainsail/fluidd does not trigger it (for now), only the macro. |
After a klipper reset it triggers the shutdown (just the warning message), I wonder if the default state of the button is messing about. fixed in e7e3287 The button must be reset (which was kind of obvious by the name of the second button pin) after pressing. It might also trigger 0-2 times during reset which is avoided by delaying the availability of the command by one second. |
Ah, I also run in that issue when testing it yesterday. Thought it was caused by by the M105 being called from Moonraker/Mainsail on start but didn't have time to test that assumption. I think it's not the best idea to repurpose the M105. Is there any reason why it can't be a Macro like _SHUTDOWN_BUTTON_TRIGGER ? |
No reason, just sticked to the original firmware. Since we modify the printer.cfg anyway there is no reason not to change it. Changed it in the feature branch. Also fixed the prompt staying up in fluidd. |
Pushed this to master now. Noticed the shutdown image is missing, but can add this when I also improve the wording of the installation screen, unless you have already prepared one. |
Made one, it's in the images dir (mod_shutdown.png), thought they were autogenerated, apperantly not :) |
Added it to master. The shutdown screen is working semi-well because it's only displayed briefly. Tried to manually unbind the driver, but has the same effect: But it's not critical, unless someone has an idea how to avoid it. |
I guess it's hardcoded in the display driver module. Since it's baked into the kernel I don't really see a way of working around it. |
There probably is a better way to do a auto shutdown feature but I found this https://github.com/tinntbg/auto-power-off-klipper and then made some small changes to work with this version. Would be nice to have something like a toggle button in KlipperScreen to enable/disable auto shutdown. Add to Machine end g-code: Add to macros.cfg:
|
That would be custom code, if you have any good suggestions how to do this they are welcome. Maybe it can be done by firing a macro which sets a variable/flag (see the delayed "enabling" of the shutdown gcode). Adding the configuration variable is quite easy fortunately. |
This is only needed for a "wait for print, cooldown and then shutdown" if I understand it correctly? |
That is how I understand it also :) |
I've been looking at it and I think it's better to add it to your slicer config. I do not think it is cancelable and that would give the wrong impression with a toggle switch. Unless it is but I do not know how at the moment. Macro has been added at least. |
Is it possible to do a "wake on lan" feature? |
|
The following features are either included, are on the master branch or are on the feature branch of the specific variant:
Am I missing something? Is there something else still needed? For the auto shutdown switch: If someone can guide me to how to cancel a macro it's probably doable to add a switch somewhere in the gui(s) but I'm hesitant to include it if it's not possible. |
I've updated the macros so I can cancel the auto shutdown but I'm not really pleased of how everything works. For example if some other macro is executed after the
|
I'm not that well versed into klipper macro's, someone else will definetly have to look into this 😅 looks like a possible race condition |
Since the macro has been added, it works as expected (I think) and the prompt is issued I'm closing this item. |
The power button on the 5M Pro does nothing. When I select "Shutdown" in Mainsail something shuts down but not the entire printer. The printer becomes unresponsive and the LED light, fans etc stays on.
In the original firmware there is an option to enable auto shutdown when printer has been idle for some time (30 min?). Is there a way to implement this?
The text was updated successfully, but these errors were encountered: