Am seeing the following behavior in Marlin:
When moving the printhead, if an end stop is hit, a position report (M114) erroneously reports the print head position as where it was trying to go, as opposed to where it's position actually is.
For example (using pronsole):
> M114 X:1.00 Y:1.00 Z:1.00 E:0.00 Count A: 142 B:0 Z:1260 > G0 Z100 endstops hit: Z:16.88 > M114 X:1.00 Y:1.00 Z:100.00 E:0.00 Count A: 142 B:0 Z:21263
In this example, the Z endstop was hit at (z:16.88), but the printer appears to think it is at the target location (z:100).
The "Count" Z appears to remain accurate however.
Question: Is this a bug in Marlin, or is this correct behavior and I am misunderstanding something?
Some info on the subject: few stepper motors have any way of knowing their exact position during operation, which means Marlin will have to assume the steppers always are in the right place.
In other words, all g-code commands are executed relative to their current position, not with regards to the real positions. So if you forcefully move the printhead during print, the printer will just continue printing the same patterns in mid-air (this is basically what is called layer shifting).
The only way the printer can know the real position of the steppers is when the endpoint switches are triggered. This is why the homing action is done to before prints in order to reset the internal positional bookkeeping of the steppers in Marlin. So if the endpoints are triggered without the printer actually being at the endstops, you will seriously confuse Marlin.
I agree that is sounds weird that Marlin does not reset the positions of it's steppers when an endstop is triggered (during print?), but then again, if it happens accidentally (and not as part of a re-calibration procedure), I believe the default actions should be to abort all operation since this would indicate the printer being out of control. Perhaps there simply is no routine to handle movement after the program has been aborted - a situation where probably nothing would be right anyway..