I'm having an issue whereby at the end of the first pass the z axis zero appears to automatically reset at the last max depth so when the next pass starts it starts at the last max depth not the original zero value. Has anyone any ideas where to start looking as I can't see anything obviously wrong with the code or the machine.
Post your code. Watch the DROs and see if its actually resetting to zero. (you can slow the feed rate down to make it easier to spot) If not, check your lock collar on your z lead screw. This has happened to me and the lock collar came loose.
or it is missing steps on the rapid retract. halve the maxspeed and/or acceleration for Z in the GRBL settings and run to check. if it is hardware then the Z offset reported by GRBL will not change during the run, so after you first set Z hover your mouse over the Z display and when the popup tells you the machine coordinate write it down. is it the same at the end of the run? If so, then you have a loose collar or acceleration/maxspeed issue. if it has changed then 'something' is actually changing the Z offset during the run, which is a different kettle of fish