Trying to setup a command button to check the Z axis is moving the prescribed amount. Here's the code; G91G21 G0Z10.0; G0X50.0Y50.0; G1Z-5.0F300; G4 P5.0; G1Z5.0F300; G0X0.0Y0.0; M2. Everything works fine up to the final X0Y0, it will not return to the starting point. What am I leaving out. Any assistance appreciated.
You are in relative (G91) mode - moves are the specified distance from where you are at the beginning of the line. If you want to go back to where you set the workplace coordinates system zero (not necessarily where you started this routine) you need to put G90 before the last move. To guarantee going back to where you started, calculate how far you have moved away from the start position and use a G0 command (in relative mode) to move back that distance. Alex.