dkoch83 / Marlin-1.1.9_Anycubic_Chiron

Anycubic Chiron Firmware based on Marlin-1.1.9
GNU General Public License v3.0
32 stars 19 forks source link

Z raise before power loss #9

Closed illuminati05 closed 4 years ago

illuminati05 commented 4 years ago

Hello dkoch83

I tried to modified your version. In the "power_loss_recovery.cpp" function "void save_job_recovery_info()" i want to integrate that if a ups is mounted and an outtage is occured the z axis should rise and/or the x axis should move. I tried several pieces of code

power_loss_recovery.cpp: ...

card.openJobRecoveryFile(false); (void)card.saveJobRecoveryInfo();

ifdef CHIRON_POWER_LOSS_RECOVERY

 #ifdef POWER_LOSS_UPS_MOUNTED

    // If power-loss pin was triggered, write just once then kill
    if (READ(POWER_LOSS_DETECT_PIN) == POWER_LOSS_DETECT_STATE)
    {
      #ifdef DEBUG_POWER_LOSS_RECOVERY
        SERIAL_PROTOCOLLNPGM("Power loss detected through input");
        SERIAL_EOL();
      #endif

       #ifdef POWER_LOSS_ZRAISE

          #ifdef DEBUG_POWER_LOSS_RECOVERY
            SERIAL_PROTOCOLLNPGM("Raise Z axis for security");
            SERIAL_EOL();
          #endif

          parser.parse("G91");  
          process_parsed_command();

      planner.synchronize();

          parser.parse("G1 Z5 F1500");  
          process_parsed_command();

      planner.synchronize();

          **NO MOVEMENT !!!**

          #ifdef DEBUG_POWER_LOSS_RECOVERY
            SERIAL_PROTOCOLLNPGM("Z axis raised");
            SERIAL_EOL();
          #endif

        #endif

        #ifdef POWER_LOSS_XMOVETOPOS

          #ifdef DEBUG_POWER_LOSS_RECOVERY
            SERIAL_PROTOCOLLNPGM("Move X axis for security");
            SERIAL_EOL();
          #endif

          parser.parse("G90");  
          process_parsed_command();

      planner.synchronize();

          parser.parse("G1 X5 F1500");  
          process_parsed_command();

      planner.synchronize();

         **NO MOVEMENT !!!**

          #ifdef DEBUG_POWER_LOSS_RECOVERY
            SERIAL_PROTOCOLLNPGM("X axis moved");
            SERIAL_EOL();
          #endif

        #endif

        #ifdef DEBUG_POWER_LOSS_RECOVERY
          SERIAL_PROTOCOLLNPGM("Power loss kill machine");
          SERIAL_EOL();
        #endif

        //Kill machine
        kill(PSTR(MSG_POWER_LOSS_RECOVERY));

    }
  #endif
#endif'