Glad you got it working.
I like your use of declared parameters at the top of the code.
For others, the following is probably the simplest / cleanest code:
This has not yet been tested, I'm currently building a new machine
Code:
o100 sub
#<plate> = 1.47 (plate thickness)
#<retouch> = 1 (distance to move up before slow retouch)
(Notes: This code does an incremental fast probe down, sets Z0 offset the declared #<plate> thickness, rapids up #<retouch> distance, then does a slow probe down a maximum of 0.5mm more than #<retouch>, then sets Z0 offset the declared #<plate> thickness, finally performing a rapid up to Z25 above material. G90 = absolute distance mode, G91 = incremental distance mode)
G21 (metric units)
(DEBUG,PROBE is ACTIVE)
G91 G38.2 Z-20 F50 (1st probe move, incremental move down max of Z-20 at 50mm/min)
G10 L20 P0 Z#<plate> (Set Z0 offset plate thickness)
G90 G0 Z#<retouch> (move #<retouch> distance above PCB plate for 2nd touch)
G38.2 Z-#<retouch>+0.5 F10 (slow second touch to max of #<retouch> distance + 0.5mm)
G10 L20 P0 Z#<plate> (Set Z0 offset plate thickness)
G90 G0 Z25 (rapid up to 25 above material)
(DEBUG,REMOVE TOUCH PLATE AND PRESS START TO CONTINUE)
o100 endsub