# Internal error on command:"G2"

**URL:** <https://klipper.discourse.group/t/internal-error-on-command-g2/12227>\
**Category:** General Discussion\
**Created:** [December 11, 2023, 11:34pm UTC](https://klipper.discourse.group/t/internal-error-on-command-g2/12227 "2023-12-11T23:34:43Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![mggevaer](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@mggevaer](https://klipper.discourse.group/u/mggevaer)\
**Post date:** [December 11, 2023, 11:34pm UTC](https://klipper.discourse.group/t/internal-error-on-command-g2/12227/1 "2023-12-11T23:34:44Z")

</div>

### Basic Information:

Printer Model: Voron trident (Rpi Zero 2 w)  
 MCU / Printerboard: Octopus + BTT EBB36  
 `klippy.log`  
[klippy.log](https://klipper.discourse.group/uploads/short-url/6Ux7JJ9gZQHdodhm7zse8m1ALxq.log) (1.9 MB)

### Describe your issue:

I turned on Arc fitting in PrusaSlicer (G2/3 I J), to reduce the size of my gcode files a bit, and this seemed to work fine on a bunch of files, however, I’m getting an error with a specific gcode files, specifically the klipper error looks like this:

```auto
move 840: pt=854.226472 mt=0.000345 sv=4.713956 a=-129.302121 sp=(739.592934,-0.000000,0.000000) ar=(1.000000,1.000000,0.000000)
Requested toolhead position at shutdown time 854.126698: (176.7658024588731, 116.44171951165774, 0.32990518317924533)
b'stepcompress o=12 i=0 c=3 a=0: Invalid sequence'
b'stepcompress o=12 i=0 c=3 a=0: Invalid sequence'
b'stepcompress o=12 i=0 c=3 a=0: Invalid sequence'
b'stepcompress o=12 i=0 c=3 a=0: Invalid sequence'
b'stepcompress o=12 i=0 c=3 a=0: Invalid sequence'
b'stepcompress o=12 i=0 c=3 a=0: Invalid sequence'
b'stepcompress o=12 i=0 c=3 a=0: Invalid sequence'
b'stepcompress o=12 i=0 c=3 a=0: Invalid sequence'
b'stepcompress o=12 i=0 c=3 a=0: Invalid sequence'
b'stepcompress o=12 i=0 c=3 a=0: Invalid sequence'
b'stepcompress o=12 i=0 c=3 a=0: Invalid sequence'
b'stepcompress o=12 i=0 c=3 a=0: Invalid sequence'
b'stepcompress o=12 i=0 c=3 a=0: Invalid sequence'
Internal error on command:"G2"
Traceback (most recent call last):
  File "/home/printer_white/klipper/klippy/gcode.py", line 211, in _process_commands
    handler(gcmd)
  File "/home/printer_white/klipper/klippy/extras/gcode_arcs.py", line 48, in cmd_G2
    self._cmd_inner(gcmd, True)
  File "/home/printer_white/klipper/klippy/extras/gcode_arcs.py", line 112, in _cmd_inner
    self.gcode_move.cmd_G1(g1_gcmd)
  File "/home/printer_white/klipper/klippy/extras/gcode_move.py", line 143, in cmd_G1
    self.move_with_transform(self.last_position, self.speed)
  File "/home/printer_white/klipper/klippy/extras/bed_mesh.py", line 215, in move
    self.toolhead.move(split_move, speed)
  File "/home/printer_white/klipper/klippy/toolhead.py", line 454, in move
    self.move_queue.add_move(move)
  File "/home/printer_white/klipper/klippy/toolhead.py", line 187, in add_move
    self.flush(lazy=True)
  File "/home/printer_white/klipper/klippy/toolhead.py", line 176, in flush
    self.toolhead._process_moves(queue[:flush_count])
  File "/home/printer_white/klipper/klippy/toolhead.py", line 345, in _process_moves
    self._advance_move_time(next_move_time)
  File "/home/printer_white/klipper/klippy/toolhead.py", line 304, in _advance_move_time
    self._advance_flush_time(flush_time)
  File "/home/printer_white/klipper/klippy/toolhead.py", line 288, in _advance_flush_time
    sg(sg_flush_time)
  File "/home/printer_white/klipper/klippy/stepper.py", line 228, in generate_steps
    raise error("Internal error in stepcompress")
stepper.error: Internal error in stepcompress
Internal error on command:"G2"
virtual_sdcard dispatch
Traceback (most recent call last):
  File "/home/printer_white/klipper/klippy/extras/virtual_sdcard.py", line 264, in work_handler
    self.gcode.run_script(line)
  File "/home/printer_white/klipper/klippy/gcode.py", line 229, in run_script
    self._process_commands(script.split('\n'), need_ack=False)
  File "/home/printer_white/klipper/klippy/gcode.py", line 211, in _process_commands
    handler(gcmd)
  File "/home/printer_white/klipper/klippy/extras/gcode_arcs.py", line 48, in cmd_G2
    self._cmd_inner(gcmd, True)
  File "/home/printer_white/klipper/klippy/extras/gcode_arcs.py", line 112, in _cmd_inner
    self.gcode_move.cmd_G1(g1_gcmd)
  File "/home/printer_white/klipper/klippy/extras/gcode_move.py", line 143, in cmd_G1
    self.move_with_transform(self.last_position, self.speed)
  File "/home/printer_white/klipper/klippy/extras/bed_mesh.py", line 215, in move
    self.toolhead.move(split_move, speed)
  File "/home/printer_white/klipper/klippy/toolhead.py", line 454, in move
    self.move_queue.add_move(move)
  File "/home/printer_white/klipper/klippy/toolhead.py", line 187, in add_move
    self.flush(lazy=True)
  File "/home/printer_white/klipper/klippy/toolhead.py", line 176, in flush
    self.toolhead._process_moves(queue[:flush_count])
  File "/home/printer_white/klipper/klippy/toolhead.py", line 345, in _process_moves
    self._advance_move_time(next_move_time)
  File "/home/printer_white/klipper/klippy/toolhead.py", line 304, in _advance_move_time
    self._advance_flush_time(flush_time)
  File "/home/printer_white/klipper/klippy/toolhead.py", line 288, in _advance_flush_time
    sg(sg_flush_time)
  File "/home/printer_white/klipper/klippy/stepper.py", line 228, in generate_steps
    raise error("Internal error in stepcompress")
stepper.error: Internal error in stepcompress
Exiting SD card print (position 161472)

```

Does this point to a mistake in my config? Should I open a github issue?

---

<div class="post-metadata">

**Author:** ![LifeOfBrian](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/lifeofbrian/32/2380_2.png) [@LifeOfBrian](https://klipper.discourse.group/u/LifeOfBrian)\
**Post date:** [December 12, 2023, 7:42am UTC](https://klipper.discourse.group/t/internal-error-on-command-g2/12227/2 "2023-12-12T07:42:38Z")

</div>

Either in addition or related to the above error your have the following as well:

```auto
MCU 'toolboard' shutdown: Timer too close

```

See here:

> [@Timer too close](https://klipper.discourse.group/t/timer-too-close/6634):
>
> Timer too close Background A “Timer too close” error occurs when the MCU is asked to schedule an action at a time that is already in the past. This typically results from delayed communication between the host and the MCU - for instance, if the host was busy or the message was blocked en route. warning Important: Klipper can identify what command was too late, but cannot determine why the delay occurred. The root cause is often external - such as USB congestion from a webcam or high system …

A side note from @Sineos to the original topic:

> General note: Log lines like `stepcompress o=4 i=0 c=17 a=0: Invalid sequence` often are a consequence of errors / events that happened before. This means they are rather a symptom but not the root cause.

What is connected to your Pi Zero 2?

---

<div class="post-metadata">

**Author:** ![EddyMI3D](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/eddymi3d/32/1981_2.png) [@EddyMI3D](https://klipper.discourse.group/u/EddyMI3D)\
**Post date:** [December 12, 2023, 7:53am UTC](https://klipper.discourse.group/t/internal-error-on-command-g2/12227/3 "2023-12-12T07:53:09Z")

</div>

Would be interesting to see the parameters of the G2 command.

Do you have some code lines?

---

<div class="post-metadata">

**Author:** ![LifeOfBrian](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/lifeofbrian/32/2380_2.png) [@LifeOfBrian](https://klipper.discourse.group/u/LifeOfBrian)\
**Post date:** [December 12, 2023, 8:07am UTC](https://klipper.discourse.group/t/internal-error-on-command-g2/12227/4 "2023-12-12T08:07:51Z")

</div>

If I’m reading the log right this should be the recent code:

```auto
Y115.309 E.14327
G1 X73.011 Y115.323 E.00269
;WIDTH:0.41646
G1 X72.928 Y115.337 E.0025
;WIDTH:0.38292
G1 X73.098 Y114.687 E.01814
M204 S3000
M204 S5000
G1 X72.902 Y116.075 F24000
M204 S4000
;WIDTH:0.449999
G1 F12000
G1 X75.948 Y113.029 E.13925
G1 X76.05 Y112.901 E.00529
;WIDTH:0.41646
G1 X76.152 Y112.772 E.00488
;WIDTH:0.38292
G3 X76.091 Y112.712 I-.02 J-.04 E.00307
G1 X76.163 Y112.731 E.00201
M204 S3000
M204 S5000
G1 X75.901 Y113.564 F24000
M204 S4000
G1 F12000
G1 X75.83 Y113.545 E.00198
G2 X75.89 Y113.605 I.04 J.02 E.00301
;WIDTH:0.41646
G1 X75.79 Y113.734 E.00484
;WIDTH:0.449999
G1 X75.691 Y113.863 E.00526
G1 X72.735 Y116.819 E.13513
G1 X72.579 Y117.55 E.02416
G1 X75.457 Y114.672 E.13157
G1 X75.555 Y114.543 E.00524
;WIDTH:0.41646
G1 X75.653 Y114.414 E.00481
;WIDTH:0.38292
G3 X75.593 Y114.354 I-.02 J-.04 E.00301
G1 X75.664 Y114.373 E.00198
M204 S3000
M204 S5000
G1 X75.24 Y115.464 F24000
M204 S4000
;WIDTH:0.449999
G1 F12000
G1 X72.723 Y117.982 E.11509
G1 X72.657 Y118.026 E.00256
G1 X72.485 Y117.992 E.00567

```

---

<div class="post-metadata">

**Author:** ![EddyMI3D](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/eddymi3d/32/1981_2.png) [@EddyMI3D](https://klipper.discourse.group/u/EddyMI3D)\
**Post date:** [December 12, 2023, 8:41am UTC](https://klipper.discourse.group/t/internal-error-on-command-g2/12227/5 "2023-12-12T08:41:37Z")

</div>

According to this:

> [@Internal error in MCU 'mcu' stepcompress](https://klipper.discourse.group/t/internal-error-in-mcu-mcu-stepcompress/6644):
>
> Internal error in MCU ‘mcu’ stepcompress Background An unforeseen issue in the stepcompress logic has happened. Reasons This is an error that should not happen under normal operating conditions Often this appears in the log as a consequential error of an error that occurred earlier Potential solutions Scroll upwards in the klippy.log from this error. If there is another error then this is likely the source of the issue and should be looked at If there is no upstream error and it is repr…

@koconnor may have a look on this.

---

<div class="post-metadata">

**Author:** ![mggevaer](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@mggevaer](https://klipper.discourse.group/u/mggevaer)\
**Post date:** [December 12, 2023, 8:48am UTC](https://klipper.discourse.group/t/internal-error-on-command-g2/12227/6 "2023-12-12T08:48:33Z")

</div>

Connected to the Rpi I have the Octopus board, a BTT EBB36, and also a “Microsoft Modern webcam”, but I have it capped at 1 fps, and 640\*360, so very low.  
Everything runs over USB.  
I can try to run the file again with the webcam disabled if that rules out any MCU timeout issues.  
I had been running the webcam at 5fps for some time without issues, and CPU load didn’t look to bad in Mainsail(\<15% at all times during printing).

---

<div class="post-metadata">

**Author:** ![LifeOfBrian](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/lifeofbrian/32/2380_2.png) [@LifeOfBrian](https://klipper.discourse.group/u/LifeOfBrian)\
**Post date:** [December 12, 2023, 9:10am UTC](https://klipper.discourse.group/t/internal-error-on-command-g2/12227/7 "2023-12-12T09:10:37Z")

</div>

If

```auto
G2 X75.89 Y113.605 I.04 J.02 E.00301

```

is the culprit here this is maybe just too tiny for the (step) calculation.

In your printer.cfg you have set:

```auto
[gcode_arcs]
resolution: 0.05

```

The default is **1.0**  
Maybe you can just for testing purpose set it again to 1.0 and retry your failing gcode after a **save and restart**.

---

<div class="post-metadata">

**Author:** ![Sineos](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/sineos/32/18_2.png) [@Sineos](https://klipper.discourse.group/u/Sineos)\
**Post date:** [December 12, 2023, 9:46am UTC](https://klipper.discourse.group/t/internal-error-on-command-g2/12227/8 "2023-12-12T09:46:59Z")

</div>

As mentioned by @LifeOfBrian the initial error is a “Timer too close”. The rest of the errors are IMHO purely consequential to this and should be disregarded.

Hard to tell if this is related to using arcs or not.

Generally, I do not see any valid reason to use arcs with Klipper:

- A 3D printer is not able to move in a circular motion → An arc always needs to be broken down in discrete steps as movements of X and Y
- This is nice for firmwares that suffer from bottlenecked serial connection bandwidth → Klipper does not
- The arcs IMO come out of a time where CNC have been programmed by hand and today and especially with 3D printers I personally see no real use
- On the contrary, it might even introduce yet another approximation step

---

<div class="post-metadata">

**Author:** ![mggevaer](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@mggevaer](https://klipper.discourse.group/u/mggevaer)\
**Post date:** [December 12, 2023, 10:26am UTC](https://klipper.discourse.group/t/internal-error-on-command-g2/12227/9 "2023-12-12T10:26:34Z")

</div>

Did a test with the resolution set to 1.00 and did not see issues. I had the arc value at 0.05 because I think this is what is used by Octoprint arc welder, although I don’t know if that value translates directly to Klipper.  
1.00 seems very high, considering I often have arcs with radius 0.5 in my parts. (0.25mm nozzle)

For me the reasons I wanted to use arcs:

- smaller GCode files.
- I felt as if it was a way for the printer to get as close to the arc as allowed by its motion system. (not sure this is the case now)  
But mostly smaller GCode files.

Maybe it makes sense to add a note in the Klipper documentation if it’s not recommended to use arcs(G2/G3)?

---

<div class="post-metadata">

**Author:** ![Sineos](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/sineos/32/18_2.png) [@Sineos](https://klipper.discourse.group/u/Sineos)\
**Post date:** [December 12, 2023, 10:55am UTC](https://klipper.discourse.group/t/internal-error-on-command-g2/12227/10 "2023-12-12T10:55:06Z")

</div>

“Timer too close” is an error that is created on the host side.  
You are using a pretty weak host (Rpi Zero 2 w) and in combination with quite an extreme resolution, I could imagine that this is causing the issue.

Graphing your log’s content yields:  
 ![image](https://global.discourse-cdn.com/free1/uploads/klipper/original/2X/a/a22a175b818019ff7ae51111ab9ced500cd09059.png)

Which shows a pretty high peak in the hosts bandwidth. For my taste too high and could also be related to the points mentioned above.

> [@mggevaer](#):
>
> I felt as if it was a way for the printer to get as close to the arc as allowed by its motion system. (not sure this is the case now)

Actually, rather on the contrary. It just adds additional processing steps that all cause a certain form of error / approximation.

The size argument, I really do not understand. With todays hardware and WIFI / LAN transmission speeds, I personally could not care less if the file is 10MB or 50MB.

---

<div class="post-metadata">

**Author:** ![mggevaer](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@mggevaer](https://klipper.discourse.group/u/mggevaer)\
**Post date:** [December 12, 2023, 11:12am UTC](https://klipper.discourse.group/t/internal-error-on-command-g2/12227/11 "2023-12-12T11:12:04Z")

</div>

I was under the assumption that there were no downsides to the arc welding (wrongly so apparently), so for me smaller files without any downsides made sense.

Based on what you’re saying it seems like I should go for something like a RPI 4b for my next printer then, since rpi zero 2w has the rpi 3B processor, (clocked maybe slightly lower). Unless I’m really only hitting the limit due to the arc welding, which I won’t use again moving forward based on your comments.

FYI, my printer is in a pretty bad wifi spot, I’m getting upload speeds of 150 kb/s~500kb/s, so it would have made a slight difference to me, e.g. 15 mb vs 22 mb means 46s~14s less upload time.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/klipper/original/1X/64419bf2aac6639e6ef5cef200dcd456b0a01ac3.png) [@system](https://klipper.discourse.group/u/system)\
**Post date:** [January 11, 2024, 9:13pm UTC](https://klipper.discourse.group/t/internal-error-on-command-g2/12227/12 "2024-01-11T21:13:04Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
