Internal error on command M400

Basic Information:

Printer Model: Zero G Merc
MCU / Printerboard: Manta M8p

klippy (2).log (4.6 MB)
Capture

Describe your issue:

updated to the latest version and now get this error when trying to load filament with an orbiter sensor and its cfg.

Please try to reproduce without any unofficial modification and run a M112 immediately after the error. Then post the resulting log.

I seem to get the same problem. After the latest update.
Tried to reinstall klipper but with a version that it did not happen with. But the problem persisted.
Found that it could be a communication problem somewhere physical.
I’ve replaced my MCU and rpi for a manta e2ez and a CB1.

Now, after reinstalling everything I get the same issue.
M600 triggered > filament unloads > then inserting my filament into the orbiter sensor and the internal error pops up.

Just a snippet of the log:

b'stepcompress o=13 i=-611908 c=1 a=0: Invalid sequence'
Internal error on command:"M400"
Traceback (most recent call last):
  File "/home/biqu/klipper/klippy/gcode.py", line 211, in _process_commands
    handler(gcmd)
  File "/home/biqu/klipper/klippy/toolhead.py", line 608, in cmd_M400
    self.wait_moves()
  File "/home/biqu/klipper/klippy/toolhead.py", line 477, in wait_moves
    self._flush_lookahead()
  File "/home/biqu/klipper/klippy/toolhead.py", line 356, in _flush_lookahead
    self.move_queue.flush()
  File "/home/biqu/klipper/klippy/toolhead.py", line 176, in flush
    self.toolhead._process_moves(queue[:flush_count])
  File "/home/biqu/klipper/klippy/toolhead.py", line 353, in _process_moves
    self._advance_move_time(next_move_time)
  File "/home/biqu/klipper/klippy/toolhead.py", line 311, in _advance_move_time
    self._advance_flush_time(flush_time)
  File "/home/biqu/klipper/klippy/toolhead.py", line 302, in _advance_flush_time
    m.flush_moves(flush_time, clear_history_time)
  File "/home/biqu/klipper/klippy/mcu.py", line 971, in flush_moves
    raise error("Internal error in MCU '%s' stepcompress"
mcu.error: Internal error in MCU 'mcu' stepcompress
Transition to shutdown state: Internal error on command:"M400"
Dumping gcode input 0 blocks

This does not occur outside of an active print. So loading filament trough the sensor does load and extrude it.

Did M112 after it happens.
klippy.log (5.1 MB)
Weirdly enough, it is not consistent. A few tries did work but then it failed at the same stage an at the same command.

Hopefully this helps. If needed, I can provide more tests and information.

A little update on my side. The moment the switch in the filament sensor is pressed, the error pops-up. Which would mean that the problem is somewhere in the beginning of the macro’s.

In the standard OrbiterSensor.cfg configuration I turned the following to True:
variable_disable_autoload :True . This turns the autoload off.

After that, tried to recreate the problem and the problem does not return for me.
So what is inside the autoload?

[gcode_button filament_sense]
pin: !PD9 # remove the negation "!" for sensor v1 - use just PA9 as example
press_gcode: # sensor released  -runnout detected!
  runnout_init
release_gcode: #gcode macro for filament auto-load, sensor pressed
  filament_load_init

filament_load_init is the macro to look at. Nothing more than that.

[gcode_macro filament_load_init]
gcode:
  {% set sensor = printer['gcode_macro _SENSOR_VARIABLES'] %}
  {% if (printer.print_stats.state != "printing") %}
    {% if(sensor.disable_autoload|lower == 'false') %}
      filament_load
    {% else %}
    M118 Filament auto-load is disabled in the sensor config file!   
    {% endif %} 
  {% else %}    
    M118 Printing! Can't load filament right now!    
  {% endif %} 
  SET_GCODE_VARIABLE MACRO=filament_unload VARIABLE=filamentpresent VALUE=1
  UPDATE_DELAYED_GCODE ID=clear_changebusy DURATION=2

Inside this macro the macro filament_load is requested.

[gcode_macro filament_load]
variable_loadbusy: 0
variable_USER_TEMP: 0
variable_LOAD_TEMP: 0
gcode:    
    {% set sensor = printer['gcode_macro _SENSOR_VARIABLES'] %}
    {% if loadbusy == 0 %} # requires [virtual_sdcard] 
      SET_GCODE_VARIABLE MACRO=filament_load VARIABLE=loadbusy VALUE=1
      SET_GCODE_VARIABLE MACRO=filament_unload VARIABLE=unloadbusy VALUE=1    
      {% set USER_TEMP = printer.extruder.target %} # save user set temperature before loading
      {% set LOAD_TEMP = 0 %} 
      #M118 USER TEMP {USER_TEMP}      # echo back for debug only      
        {% if (printer.extruder.can_extrude|lower != 'true') or (printer.extruder.target < sensor.filament_load_min_temp) %} # checking for minimum extrusion temperature
        # check if temperature is over the minimum extrusion temp. min_extrude_temp must be defined in the extruder config (to about 185)                        
          SET_HEATER_TEMPERATURE HEATER=extruder TARGET={sensor.filament_load_temp} # set user defined load temperature
          {% set LOAD_TEMP = sensor.filament_load_temp %} # save user set temperature before loading           
         M118 Hotend heating! 
      {% endif %}     
    {% if (sensor.enable_beep|lower == 'true') %} 
      M300 # beep sound
    {% endif %}
    M118 Filament loading!  
    M82           #set extruder to absolute mode
    G92 E0
    G4 P1500        # wait for 1.5 seconds
    FORCE_MOVE STEPPER=extruder DISTANCE=15 VELOCITY=10 ACCEL=1000  # load filament inside the gears force move needs to be enabled    
    TEMPERATURE_WAIT SENSOR=extruder MINIMUM={LOAD_TEMP} # wait for reaching set temperature    
    TEMPERATURE_WAIT SENSOR=extruder MINIMUM={USER_TEMP} # wait for reaching set temperature    
    G1 E{sensor.nozzle_purge_length} F{sensor.nozzle_purge_speed} # extrude preconfigured purge length
    M400 # wait to complete nozzle purge
    SET_HEATER_TEMPERATURE HEATER=extruder TARGET={USER_TEMP} # restore user temp if it was set before loading
    M118 Filament load complete!    
    UPDATE_DELAYED_GCODE ID=clear_unloadbusy DURATION=2   
    {% else %}
      M118 Filament already loaded!    
    {% endif %}

I could not find something that would be wrong. I must say, I’m not the best in parsing this code but my basic understanding is that there is not a bug in. But klipper does not like something inhere. Is it a value that is something it should not?

@jedikaal im not using the most recent Orbiter Macro mine is from last year, should update so i can turn off the auto load for now. has worked perfect up until now. @Sineos here is the log you wanted. freshly fired up the printer and went to load it.
klippy (3).log (290.6 KB)

Thanks. I was able to reproduce this problem locally. It is a regression introduced in the recent “pwm_tool” toolhead flushing work.

The issue should hopefully be fixed now (commit 3d3b87f9).

-Kevin

1 Like

great to hear, havent updated yet but it decided to work. here is the log. ill update also
klippy (4).log (4.4 MB)

1 Like

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