Originally Posted by
mmoe
"G91 G28 Z0" is as follows:
G91 tells the machine to switch to incremental moves. This means that each value given is the distance from the current position which the machine should go. G28 tells the machine to go to the Machine Zero through the current current move. Z0 tells the machine to move Z0, which in incremental means no distance from the current position (in absolute it would mean move to the coordinate Z0 in the current work coordinates). The result is that the machine moves to the Z0 of machine coordinates from the current Z position. If, for example, the code said "G91 G28 Z1", the Z axis would first move up Z1 (one increment), then move to Z0 in machine coordinates from that position, or in other words going to Machine Zero through the move of Z1. Again, Z0 is not really a move, so to go through Z0 in incremental positioning, it doen't have to move at all before going to Machine Zero. It's a very complicated command that really should not be used IMHO. The other problem is that you clearly have set your machine zero below the part zero, which should never be done. Machine zero (Z0 in absolute, machine coordinates) should be the highest position the Z axis can go, or very near it, while your work coordinates zero should therefor be below that point. That is what prevents this kind of move from damaging your part.
In my opinion, you should first learn to home the machine to the top of the Z stroke. Then, you should use G53 instead of G91 G28. I've never understood why a person would use G28 instead of G53. G53 is a single line parameter which cancels itself on the next line automatically (non-modal) that tells the machine to make following moves in machine coordinates, and in the current mode (incremental vs. absolute). A line of "G53 G0 Z0" in absolute mode (which is obviously what you are programming in) would move the Z to Machine Zero. In your case, the result would have been the same because the homing was not done kosher (machine Z higher than work Z). However, there is less chance of getting stuck back in incremental by accident (G28 is almost always paired with incremental positioning as it is here).
I have the following at the start and end of my programs, added in the post processor:
G53 G0 Z0
G53 X0 Y0
Just my preference and I've yet to hear a reason why it would be better done with G28. G28 made more sense back when memory on the machines was limited to 25kb per program since we all programmed in incremental much more, including a lot of subroutines. With modern controllers, just about everyone now programs in absolute because there is no reason not to when you can run programs of several gigabytes in size. If you were in incremental, G28 was the way to go since it was a move to home through the current move, requiring no knowledge of the current position which is commonly hard to figure out in incremental since it's always just relative position. You also never had to switch modes to do the move, so it made more sense that way as well. In absolute, I strongly believe that G53 is the better solution.