16
$\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$
3
  • 3
    $\begingroup$ * asterisk - Asterix is a character in a cartoon series. $\endgroup$ Commented Sep 25, 2019 at 10:33
  • 2
    $\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
    Commented Sep 25, 2019 at 14:43
  • $\begingroup$ Hmmm... maybe. The Romans did build a lot of things, like a 3-d printer does. $\endgroup$ Commented Sep 25, 2019 at 14:46

1 Answer 1

14
$\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.

$\endgroup$
3
  • 1
    $\begingroup$ Do you happen to know the checksum algorithm used here? $\endgroup$ Commented Dec 2, 2016 at 14:30
  • 4
    $\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$ Commented Dec 2, 2016 at 15:33
  • 2
    $\begingroup$ Just XOR: byte checksum = 0; byte count = 0; while(instruction[count] != '*') checksum = checksum^instruction[count++]; $\endgroup$
    – Mtl Dev
    Commented Dec 4, 2016 at 0:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .