CNC plotter overshooting

Hey everyone,

Sorry in advance if this gets a bit messy, I'll try my best to make this as understandable as possible. So, I've been trying to recreate this project with some kind of a personal touch. The most important differences are the following:

  1. I used A4988 motor drivers
  2. Inkscape appears to work somewhat differently than advertised when generating G-codes (I'm pretty sure I'm messing something up, but for the love of God I can't figure out what), so the command that moves the pen up seems to be G0 F3000, while the one that moves the pen down G1 F100.000000.
  3. I'm using an Arduino Nano instead of an Uno.

Obviously, this required that I tweak the code accordingly. Here's my version:

Code here

There is, however, a rather... weird problem I'm facing. I'm trying to draw a simple rectangle, and for some reason it gets a "handle". I'll add a picture trying to illustrate the problem.

I'd like to remark on the fact that the "handle" gets drawn both ways. Practically, the plotter is drawing two lines it's not supposed to.

You can find the G code that's running when I get this problem here. As you can see, there is nothing inside that would point to such behaviour.

Has anyone faced such a problem before? What are some troubleshooting steps I should go through? I tried looking at the debug output, but it didn't make me any wiser.

Thanks in advance!

Code here

If you want to post your code there, post your problem there.

If you want help HERE, post your code HERE.

Post the G code that Inkscape is generating, too.

It will use G0 for all pen-up moves - G0 means rapids, which are used for traversing between milling
operations in a CNC mill.

G1 is coordinated linear motion, using or defining the current feedrate. G1 will be for drawing,
G0 for moves without drawing.

You code treats G0 as equivalent to G1.