Marlin has a safety feature where any axis homed cannot then go negative. I’m not sure how you want this code to behave, but you can get around this particular problem by:
G28 Z
G92 Z19
G1 Z21 F150
G1 Z5 F150
I assume “G1 Z2 F150” is lifting the router so you can snatch the touch plate out.
The homing works fine, but after the homeing, the z wil not go down to 0. its stuck at +Z17.
so after enter the command G1 Z5 it stops at Z17
I really do not know why???
Are you using the exact code I wrote? Do you execute right after power up? While being stuck at 17 is strange, this code take the router to Z=5 just like your original code leaves the router. I saw no reason to go to Z=0 then bring the router up to Z=5. I’m not sure of your intent, but if you want to leave the bit at Z=0, change the last line to:
G1 Z0 F150
Note this is the code Ryan provides for his touch plate he sell in the store (modified for your touch plate height)
G28 Z
G92 Z19
G0 Z24 F480
This is the code I execute for my Z homing. Note that the speed is higher (F480). It leaves the bit at Z=24 which is 5 mm above your touch plate so that the touch plate can be unclipped and removed. You then would need to execute a G1 Z0 F450 to bring it down to 0.
G28 X Y ; home X and Y
M0 ; wait for place the probe
G28 Z ; home Z and x and y
G92 Z19.2 ; set z home position to top of probe
G0 Z24 F480 ; move up 24 mm
G90 ; use absolute positioning
G21 ; use mm
M17 ; enable motors
G1 X100 Y100 F4000 ; move to almost home x and y
G1 Z2 F480 ; move z 2 mm above surface
G92 X0 ; set new x home
G92 Y0 ; set new y home
G92 Z2 ; set new z home
M0 ; wait
These should not be needed, or if you are concerned, they should be at the beginning of the script or at least before the move to Z=24
M17 ; enable motors
Your steppers will already be engaged by the homing sequence, so this line is not needed. Any movement of the steppers engages them, and they stay engaged unless you unlock them.