auto save on loss of power from a different pin (endstop?)



  • I want connect my UPS with have a low DC signal when it runs on battery to DuetWiFi.
    For safety I use an optocoupler between Duet and UPS

    And I wont a power save future so when the UPS goes on battery the printers stops printing, moves the head back and only heats the bed up so the print doesn't detach from bed.

    Can I archive it by using M581 command? I am going to use E1 endstop.
    The problem with I see is that when I configure the external trigger as pause I need to modify pause.g to shutdown head heating, lower motor current etc. but this will affect the normal work of the pause button. And when using sys/trigger#.g as far I know it doesn't automatic save the current position.


  • administrators

    @dragonn What you might want to do is use pause in combination with other steps within your trigger.g so pause first (with the associated head parking etc (at higher current on the motors etc) then turn off/down what you want.



  • You mean use M226 in trigger.g? But when I run this first it will block executing that macro? I could move head back a the point where pause.g moves it, the lower motors current, standby heater and then run M226.

    Will it be possible to configure a second trigger to resume printing?


  • administrators

    Yep should run pause.g... need to check if M226 save the position (I think it does but I have not tested that). Pause is not permanently blocking though, once the macro has finished running you can then carry out other commands.

    I would not have an automatic resume unless you are 100% sure that it wont cause issues. What about different bed temps in different prints, or if the power is down for long enough that the UPS runs out of power, the HB cools down and the print detaches?



  • Hmmm not sure, I think when I configure the resume trigger to rising edge it should not trigger when the UPS loss it power - since the input will be already high before Duet even boots up.

    Only problem will be when a next power cycles goes, this could trigger it.
    But yeah - I wont automatic resume only when the power doesn't go down.

    Different bed temps should be a problem since I will keep the bed on to it's set temperature when running from UPS.


  • administrators

    fair enough. you can test all of this using a switch plugged into the chosen pin before using the UPS so you can see if the ressuract file is being saved.



  • Trigger is already working. Some questions more:
    as far I know it is not possible to have different macros for rising and falling edge? It would be nice to put in on the firmware wish list.
    But I have a different idea - can I use in trigger2.g M583 to wait for E1 endstop to go back to high? When M583 stops executing the macro I could put the restore commands after it.

    And one question more. How can I suspend the hotend so I can restore it temp after power goes back? I see they is a M144 but it only works with beds.


  • administrators

    Yes you can have different macros for rising and falling edge.

    If you have only one hot end then you can do T-1 when pausing to put the hot end in standby. To reselect it, send T0 (assuming it is tool 0) followed by M116 to wait for it to reach temperature.



  • @dc42 Wait.. just use next trigger so it runs trigger3.g. Didn't think about that.
    Yes I have one hotend for now so it will work.

    But thinking further it would be better to use M583 then a second trigger. This would prevent any triggering when the UPS batteries run out of power and the power goes back. Other option would be to enable the restore trigger in the power save trigger. And with S-1 I can disable a trigger I am right?


  • administrators

    @dragonn, yes you can disable a trigger with S-1 in the M581 command.



  • It works! Only problem with I had was M226 didn't work, seems like it doesn't stop executing the macro until pause.g is finished. But M25 works perfectly fine, posting this because maybe it will be useful for someone else.


  • administrators

    M226 is intended for use in the GCode file being printed, for example to pause after a particular layer has completed. So it waits until all the moves in the queue have been completed. M25 is intended for use from a different source of GCodes.


  • administrators

    @dc42 said in auto save on loss of power from a different pin (endstop?):

    M226 is intended for use in the GCode file being printed, for example to pause after a particular layer has completed. So it waits until all the moves in the queue have been completed. M25 is intended for use from a different source of GCodes.

    I have updated the gcode documentation to reflect this.


 

Looks like your connection to Duet3D was lost, please wait while we try to reconnect.