-
-
Notifications
You must be signed in to change notification settings - Fork 435
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
[FR] PSU ON/OFF trigger 🔌 #167
Comments
Don't think the auto ON is possible, since for giving a gcode command Klipper needs to be connected. And klipper is not connected when the psu is off. For the auto off you just need to place the printer off in klippers idle_timeout Here as example my setup
|
Hi @MarcPot I'm using Arduino Mega + RAMPS 1.6, the board is powering with USB cable from Raspberry Pi. The main power 12V / 24V (PSU) is connect via power input terminal in the RAMPS. With this config the controller board still powered on when PSU is off. I'm using similar klipper's idle timeout config for auto turn off PSU and The probem is other command like homing, manual move, temperature pre-heat from UI or custom gcode in the console will need manual turn on PSU every time and I often forgot this step. BTW, I don't think auto parking or move tool head like your idle timeout macro is a good idea. It can caused unexpected move when we not prepared for it yet like when you're maintaining the hotend or anything on the bed can caused collision 💥. |
That auto parking thing is a personal thing, it doesn't matter for me since I don't work with the electricity on, and seeing the Z10 I'll never hit a part. Yea okay you're the exception where that auto on would have use, for a temp solution:
Although I admit this is a very ugly solution. Another option would be to just stop powering the board through usb, that way you have to turn it on first. What you could also do is just start a delayed gcode after the idle timeout that resets every second, then when the printer status moves away from idle it'll call a PRINTER_ON. |
Overwrite base gcode commands is a doable solution. I'm looking for something like gcode command event hook, but seem it will only work via API and not LCD menu. |
Do I need to change "printer" to my TPLINK switch name? |
I also have a very similar printer setup, I like keeping the main power off to conserve power, however I often forget to turn it back on so the printer gets mad when its steppers won't wake up 😅 |
Thank @MarcPot reference config, I've using it to make the workaround solution. Here is what's I had done: Implement custom Moonraker config
Klipper macro
|
uocnb, Did you ever get this working as you would prefer? I have several marcos that I use from time to time and I always forget to power the mains relay before those macros. I use GPIO on my RPI4 to control a relay to power the M/B with mains power. I tried this code and instantly got an error on reboot. [gcode_macro G28] So weird that the Home All button doesen't do a check to see if the printer is powered. Or really that any command doesn't do a power check. |
After a lot more digging, I was able to use the following script to power on the mains relay via the RPI4. Now when I click the HOME ALL button, the power switches on automatically. I will now be able to use the same script commands for things like bed leveling and bed cleaning marcos. Added to mainsail.cfg [gcode_macro G28] I used these instructions https://moonraker.readthedocs.io/en/latest/configuration/#power-on-g-code-uploads Be careful, there is a typo in the linked instructions, but the code in the instructions is correct. |
@Primer-Merc I'm still using |
I have just switched to Moonraker/Klipper/MainsailOS from OctoPrint and really liking it so far. I'm having issues getting this to work though. I tried the setting by @uocnb above, but for some reason it does not power on my PSU properly when a print starts. If I run Isn't there any way the PSU can be turned on without involving g-code, like PSU Control in OctoPrint? I think the settings such as |
I have this in my moonraker.cfg , but I use the RP4 to control a relay for my mains power. EDIT: to clarify I'm not controlling the 120VAC power. I am controlling the 24v power to the printer mainboard. [power printer] Because I was always forgetting to power the printer with the little "Power Printer" in the upper right-hand menu. I discovered with @uocnb 's I could edit the macros. For instance, when I want to call the "built in" bed level macro I first call the G28 macro which powers the printer. Because G28 is also a "built in" macro, I need to temporarily rename it and then run the gcode. It may not be pretty but it works now everytime. [gcode_macro Level_Bed] [gcode_macro G28] |
Hi @iceaway, AFAIK there are no plugin or event handling with the current klipper's config. The custom / overwrite (inheritable) macros is the only option we have currently with this setup. IMO, it is similar to the event driven we are looking for, just in a different form. If your macro is working with the console, it should work. Possibly you put it in the wrong custom g-code config section in your slicer software, you should check the generated gcode file to verify it. Here is my config with few slicers, the configured macro can be found in the beginning of the generated gcode file. @Primer-Merc I've just recall why I'm using |
Thanks for the ideas, I will try it some more. Every time it fails it's a bit of a hassle for some reason to get it working again. I have to go to the printer, unplug the USB-cable, restart some things etc, not really sure exactly which steps I have to do to get it back again. In my final g-code there is only a single command before my |
I tried adding a 3 second delay using |
Sound like you're having issue with klipper config, possibly in the |
I created a super simple test-file with the following contents:
It "printed" without any errors. The klippy.log showed the following:
I am not really sure what I am looking for. Any ideas? |
I found it while looking an |
The documentation regarding this functionality has recently been updated with further details. It is now possible to add Separately, I thought I would address the OPs original request and explain why the way Octoprint's plugin handles this can't be implemented in Moonraker. Specifically, there is a philosophical difference between the way Octoprint and Moonraker handle G-Code commands. Octoprint generally processes each G-Code command, including those in a G-Code file, and provides hooks through which plugins can react or manipulate such commands. Moonraker does not do this. G-Code commands received through the console or API call are not inspected, they are passed directly to Klipper. Likewise G-Code files and not processed by Moonraker, Klipper's The reasons for this philosophical approach are two-fold:
|
@Arksine That sounds great, I will try that! I like the idea of disabling it in the GUI just to avoid accidentally turning it off during a print. I'm still not really clear on how mainsail/moonraker/klipper are all integrated with one another, but wouldn't it be possible to attach the "Turn on PSU"-hook to when a print is started? Such as when you click "Print" or "Upload and print" from i.e. PrusaSlicer? |
It is possible, but not necessary as it can be accomplished by overriding The docs provide a specific example of this use case. |
The |
Hi, I have similar problem. Is there any way to execute shell script after switching PSU ON ? I've tried klipper's gcode_shell_command plugin, but klipper is dead without PSU... ;) Thanks in advance! |
Hi guys 👋
Thank you for the great API server!
I'm using
power
config to control PSU and I think it would be great to have PSU trigger control with following conditions:40 °C
.G0,G1,G2,G3,G10,G11,G28,G29,G32,M104,M106,M109,M140,M190
.Would be configurable in the settings and work with existing Power control.
Inspired by Octoprint's PSUControl.
The text was updated successfully, but these errors were encountered: