12
$\begingroup$

Doing some low level monitoring, the following sequence is sent to the printer:

N0 M106*36 
N1 G28*18 
N2 M107*39

This sequence just turns the fan on, homes the printer, then turns the fan off.

Question: What is the purpose of the asterix/star/(*) and the two succeeding digits on each line?

$\endgroup$
  • 2
    $\begingroup$ * asterisk - Asterix is a character in a cartoon series. $\endgroup$ – Andrew Morton Sep 25 '19 at 10:33
  • 1
    $\begingroup$ @AndrewMorton So that would make the gcode the Romans then - with Asterix being their checksum, stopping corruption in his local area? $\endgroup$ – Mtl Dev Sep 25 '19 at 14:43
  • $\begingroup$ Hmmm... maybe. The Romans did build a lot of things, like a 3-d printer does. $\endgroup$ – Andrew Morton Sep 25 '19 at 14:46
11
$\begingroup$

That is a checksum. It's added by the host software to the G-code, to allow some basic verification by the firmware that the G-code was transmitted unchanged. It doesn't change the meaning of the G-code, and what your sequence actually represents is just M106, G28, M107. The N0,N1,N2,... are line numbers, and the combination of line numbers and checksums is used to request a re-send of any lines that were corrupted during transmission.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Do you happen to know the checksum algorithm used here? $\endgroup$ – Carl Witthoft Dec 2 '16 at 14:30
  • 3
    $\begingroup$ In Marlin, all the bytes for the individual characters are XOR-ed together, and the result should be the same as the checksum. $\endgroup$ – Tom van der Zanden Dec 2 '16 at 15:33
  • 1
    $\begingroup$ Just XOR: byte checksum = 0; byte count = 0; while(instruction[count] != '*') checksum = checksum^instruction[count++]; $\endgroup$ – Mtl Dev Dec 4 '16 at 0:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.