• Tags
  • Documentation
  • Order
  • Register
  • Login
Duet3D Logo Duet3D
  • Tags
  • Documentation
  • Order
  • Register
  • Login

PID Tuning macro - not waiting for procedure to finish

Scheduled Pinned Locked Moved
Tuning and tweaking
3
8
606
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • undefined
    flobler
    last edited by 2 May 2021, 14:02

    Hello everyone,

    I am trying to create a macro for PID tuning the bed at 80C, that automatically saves the values to config-override.g. The problem I have is that once I execute the macro, both commands that should update the PID values (M307) and save them (M500) are executed right after the tuning procedure starts and are not waiting for the tuning procedure to finish.
    I have added M400 after the tuning command which did not seem to help.

    Board: Mini 5+ v1.0
    Firmware: RRF 3.3RC1
    DWC: 3.3.0-rc1

    This is the macro I use:

    ; PID Bed
    ; pid tuning routine for the bed at 80C
    M291 P"Do you want to start the PID tuning routine of the BED at 80C? Press OK to start or CANCEL to abort" S3 ; requesting input to start or abort PID tuning routine
    M303 H0 S80 ; perform tuning routine at 80C
    M400 ; wait for current moves to finish
    M307 H0 ; report values for heater 0
    M500 ; save to config-override.g
    M291 P"PID tuning for the BED complete! Values saved." S2

    Am I doing something wrong?

    undefined 1 Reply Last reply 2 May 2021, 22:43 Reply Quote 0
    • undefined
      Phaedrux Moderator
      last edited by 2 May 2021, 16:10

      The tuning process runs in a separate thread so it can't be called from a macro like this. The reason I think was that because it's a long running process you may want to be able to still use the system in some way rather than it be a potentially hour long blocking process.

      Z-Bot CoreXY Build | Thingiverse Profile

      1 Reply Last reply Reply Quote 1
      • undefined
        OwenD @flobler
        last edited by OwenD 5 Feb 2021, 22:45 2 May 2021, 22:43

        @flobler
        You could check if the machine state is "tuning" in the object model and do a wait (G4) using a while statement.
        Whether it's wise or not to do so, I can't say.
        It would have the effect of making the interface appear non responsive most likely as you'd be in a loop during this period.

        1 Reply Last reply Reply Quote 1
        • undefined
          flobler
          last edited by 3 May 2021, 07:28

          @Phaedrux, @OwenD thanks to both of you!

          I will try the object model suggestion and see if that works.

          Reason is usability for our users (bear project). We want procedures like PID tuning to be just a simple "menu item" that can be selected, then runs and results are applied automatically without further user input needed.

          I will report back.

          1 Reply Last reply Reply Quote 0
          • undefined
            Phaedrux Moderator
            last edited by 3 May 2021, 16:59

            As long as the DWC temp graph still gets updated so that users could see any abnormalities.

            Maybe a two step process? Initiate tune, then M500 to save?

            Z-Bot CoreXY Build | Thingiverse Profile

            1 Reply Last reply Reply Quote 0
            • undefined
              flobler
              last edited by 3 May 2021, 18:22

              @Phaedrux , @OwenD using the object model seems to work. Here is what I am doing:

              ; PID Bed
              ; pid tuning routine for the bed at 80C
              M291 P"Do you want to start the PID tuning routine of the BED at 80C? Press OK to start or CANCEL to abort" S3 ; requesting input to start or abort PID tuning routine
              M303 H0 S80 ; perform tuning routine at 80C
              while heat.heaters[0].state = "tuning"
              G4 S10
              M307 H0 ; report values for heater 0
              M500 ; save to config-override.g
              M291 P"PID tuning for the BED complete! Values saved." S2

              It looks like both the temperature values and the graph are being updated while the tuning procedure is in progress. I can also navigate through DWC and on the PanleDue at the same time.

              A couple of questions:

              • If I understand the new procedure correctly I could also put the nozzle close to the bed and turn the part cooling fan on to simulate the printer printing. Am I turning the fan on within the initial "M303" command and then it will be only used within the right phase of the procedure?

              • It looks like there is no "phase 2" in my console output. The procedure jumps from "phase 1: heater on" to "phase 3: settling". Is this expected?

              • Do you think I can use the object model to keep everything within one macro or is there anything that makes this approach "unsafe"?

              Thank you!

              1 Reply Last reply Reply Quote 0
              • undefined
                flobler
                last edited by flobler 5 Mar 2021, 19:00 3 May 2021, 18:59

                Ok, I answered the fan question myself (I misunderstood the F parameter). I will just turn the fan on at the start of the procedure, the macro now looks like this:

                ; PID PETG Nozzle
                ; pid tuning routine for the nozzle at 245C
                M291 P"Do you want to start the PID tuning routine for the NOZZLE at 245C? Press OK to start or CANCEL to abort!" S3 ; requesting input to start or abort PID tuning routine
                if !move.axes[0].homed || !move.axes[1].homed || !move.axes[2].homed ; not all axes are homed
                G28 ; home all
                M140 S80 ; set bed temp to 80C
                G90 ; absolute positioning
                G1 X125 Y105 Z10 ; move the nozzle to the center, 10mm above the bed
                M190 S80 ; wait for bed temp to reach 80C
                M106 P0 S0.3 ; set part cooling fan to 30%
                M303 H1 S245 ; perform tuning routine at 245C
                while heat.heaters[1].state = "tuning" ; while the tuning procedure is active
                G4 S10 ; wait for 10 seconds
                M307 H1 ; report values for heater 1
                M500 ; save to config-override.g
                M104 S0 ; turn off hotend heater
                M140 S0 ; turn off bed heater
                M291 P"PID tuning for the NOZZLE complete! Values saved." S2 ; message to confirm the procedure was successful and values are saved, requires user input to close message
                undefined 1 Reply Last reply 3 May 2021, 19:01 Reply Quote 0
                • undefined
                  Phaedrux Moderator @flobler
                  last edited by 3 May 2021, 19:01

                  @flobler said in PID Tuning macro - not waiting for procedure to finish:

                  M106 P0 S0.3 ; set part cooling fan to 30% M303 H1 S245 ; perform tuning routine at 245C

                  YOu are tuning the fan on manually. To let the firmware control the fan and take that into account you. need to leave the fan off and use M303 T0 S245 instead. That tunes the heater as part of the tool it's associated with. T0.

                  Z-Bot CoreXY Build | Thingiverse Profile

                  1 Reply Last reply Reply Quote 1
                  1 out of 8
                  • First post
                    1/8
                    Last post
                  Unless otherwise noted, all forum content is licensed under CC-BY-SA