Help understanding M26 and M27
-
I have an application where I'll need to store the SD position and then reference that position later on (for instance, at each layer-change)
Is M27 and M26 the correct way to do this?
The GCode dictionary entry for M26 mentions that the SD position is referenced by the number of bytes in the print file.
Does referencing the number of bytes ensure that the position is always at the start of a line?
-
@HebigT to save the position I suggest you do the following:
- If you want to save it using a command in the print file itself, use M400 to wait until movement stops. That will ensure that the file position is the start of the line following the M400 command.
- Retrieve object model variable job.filePosition
- Save it in a global variable, or wherever else you will need it.
If you do this from within a macro, then the position will be the start of the line following the call to the macro.
The M27 command only exists for Marin compatibility and is deprecated. Its purpose was to give an indication of how much of the job has completed when the controller is fed bytes over a USB or serial link. However, I think it should give the same result.
The M26 command is designed only to be used between a M23 command (which specifies a file to print) and a M24 command (which starts printing it). Currently, it will not change the file position of a file that is already being printed.
-
@dc42 Thank you for the detailed explanation!