Calibrating a delta printer using conditional GCode


  • administrators

    I'm almost ready to release RRF 3.1beta with conditional GCode support. I've tested it using a G32 script to calibrate my delta printer. At the start, it homes the printer only if it hasn't already been homed. Then it calibrates the printer by probing a number of points, starting again if probing fails. If calibration yields a standard deviation that is above a limit, it repeats the calibration process. If calibration fails 5 times for any reason, it quits. Here is the script:

    ; Auto calibration routine for large delta printer
    M561                         ; clear any bed transform
    
    ; If the printer hasn't been homed, home it
    if !Move.Axes[0].Homed || !Move.Axes[1].Homed || !Move.Axes[2].Homed
      G28
    
    ; Probe the bed and do auto calibration
    G1 X0 Y140 Z10 F10000        ; go to just above the first probe point
    while true
      if iterations = 5
        abort "Too many auto calibration attempts"
      G30 P0 X0.00 Y140.00 Z-99999
      if result != 0
        continue
      G30 P1 X70.00 Y121.24 Z-99999
      if result != 0
        continue
      G30 P2 X121.24 Y70.00 Z-99999
      if result != 0
        continue
      G30 P3 X140.00 Y0.00 Z-99999
      if result != 0
        continue
      G30 P4 X121.24 Y-70.00 Z-99999
      if result != 0
        continue
      G30 P5 X70.00 Y-121.24 Z-99999
      if result != 0
        continue
      G30 P6 X0.00 Y-134.85 Z-99999
      if result != 0
        continue
      G30 P7 X-65.57 Y-113.57 Z-99999
      if result != 0
        continue
      G30 P8 X-112.29 Y-64.83 Z-99999
      if result != 0
        continue
      G30 P9 X-130.59 Y-0.00 Z-99999
      if result != 0
        continue
      G30 P10 X-115.90 Y66.91 Z-99999
      if result != 0
        continue
      G30 P11 X-69.45 Y120.29 Z-99999
      if result != 0
        continue
      G30 P12 X0.00 Y70.00 Z-99999
      if result != 0
        continue
      G30 P13 X60.62 Y-35.00 Z-99999
      if result != 0
        continue
      G30 P14 X-52.28 Y-30.19 Z-99999
      if result != 0
        continue
      G30 P15 X0 Y0 Z-99999 S8
      if result != 0
        continue
      if Move.CalibrationDeviation <= 0.03
        break
      echo "Repeating calibration because deviation is too high (" ^ Move.CalibrationDeviation ^ "mm)"
    ; end loop
    echo "Auto calibration successful, deviation", Move.CalibrationDeviation ^ "mm"
    G1 X0 Y0 Z150 F10000                ; get the head out of the way
    

    You can read what the commands mean at https://duet3d.dozuki.com/Wiki/GCode_Meta_Commands.



  • This is better than sliced bread!



  • I'm curious to know what might be used with the "Move" construct. The example shows "Move.Axes[]" and "Move.CalibrationDeviation", but I don't see anything showing what else is available.

    For example, the homing script might be modified to continue attempting to re-calibrate until either 5 iterations are reached, OR the difference between the "deviation before" and "deviation after" is less than 0.02.



  • @dc42 When dreams come true…

    Just one question: it looks like „iterations“ is an implicit property of the while loop. If so, can I change that property from within the loop? Or can I evaluate it in a conditional statement?


  • administrators

    @infiniteloop said in Calibrating a delta printer using conditional GCode:

    @dc42 When dreams come true…

    Just one question: it looks like „iterations“ is an implicit property of the while loop. If so, can I change that property from within the loop? Or can I evaluate it in a conditional statement?

    You can use it in any expression, including a condition ('if', 'while' etc.) but you can't change it. Currently you can't define your own variables, so I included 'iterations' to make counted loops possible.


  • administrators

    @garyd9 said in Calibrating a delta printer using conditional GCode:

    I'm curious to know what might be used with the "Move" construct. The example shows "Move.Axes[]" and "Move.CalibrationDeviation", but I don't see anything showing what else is available.

    See https://forum.duet3d.com/topic/13797/where-can-i-find-rrf3-0-object-model-reference-material.



  • Ooooohhhhhh yeah! More intelligent nozzle wipe process on toolchange possible soon!

    Anxiously awaiting the beta..



  • Wowzers!!! That is FANTASTIC and what a great starting 'proof'.

    Now I have a reason to go RRF3 on my Duet2 hardware!



  • wouldn't it be better to use '==' for comparison, rather than '='?


  • administrators

    @fma said in Calibrating a delta printer using conditional GCode:

    wouldn't it be better to use '==' for comparison, rather than '='?

    Why? But the syntax allows both anyway.



  • To avoid confusion with variable assignement, but I just saw in the documentation than you will use 'set' for that purpose. Good to have both notations.


Log in to reply