PID Tuning macro - not waiting for procedure to finish
-
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-rc1This 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?
-
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.
-
@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. -
@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.
-
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?
-
@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!
-
-
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 -
@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.