bdring / FluidNC

The next generation of motion control firmware
Other
1.59k stars 382 forks source link

Problem: Low memory error while running G-code #1291

Open zizheng1 opened 2 months ago

zizheng1 commented 2 months ago

Wiki Search Terms

"Low Memory" "SD Card" "LocalFS"

Controller Board

MSK TinyBee

Machine Description

Using MSK TinyBee to control four motors. UART is used to connect with an external serial display. I created a serial monitor software for that external display and I can type commands to control the board. Skype_Picture_2024_08_08T14_06_01_607Z

Input Circuits

No response

Configuration file

board: MKS TinyBee V1.0_001
name: K40 Laser
meta: (01.02.2022) by Skorpi

kinematics:
  Cartesian:

stepping:
  engine: I2S_STATIC
  idle_ms: 0
  pulse_us: 4
  dir_delay_us: 1
  disable_delay_us: 0

uart1:
  txd_pin: gpio.17
  rxd_pin: gpio.16
  rts_pin: NO_PIN
  baud: 115200
  mode: 8N1

uart_channel1:
  uart_num: 1
  report_interval_ms: 400

axes:
  x:
    # X
    steps_per_mm: 640
    max_rate_mm_per_min: 4000.000
    acceleration_mm_per_sec2: 50
    max_travel_mm: 411.000
    soft_limits: false
    homing:
      cycle: 2
      positive_direction: true
      mpos_mm: 0.000
      feed_mm_per_min: 300.000
      seek_mm_per_min: 5000.000
      settle_ms: 500
      seek_scaler: 1.100
      feed_scaler: 1.100

    motor0:
      limit_neg_pin: gpio.33:low
      hard_limits: false
      pulloff_mm: 2.000
      stepstick:
        step_pin: I2SO.1
        direction_pin: I2SO.2
        disable_pin: I2SO.0

  y:
    # Y
    steps_per_mm: 135.85
    max_rate_mm_per_min: 4000.000
    acceleration_mm_per_sec2: 50
    max_travel_mm: 182.000
    soft_limits: false
    homing:
      cycle: 1
      positive_direction: true
      mpos_mm: 0.000
      feed_mm_per_min: 300.000
      seek_mm_per_min: 5000.000
      settle_ms: 500
      seek_scaler: 1.100
      feed_scaler: 1.100

    motor0:
      limit_neg_pin: gpio.32:low
      hard_limits: false
      pulloff_mm: 2.000
      stepstick:
        step_pin: I2SO.4
        direction_pin: I2SO.5
        disable_pin: I2SO.3

  z:
    # Z
    steps_per_mm: 640
    max_rate_mm_per_min: 4000.000
    acceleration_mm_per_sec2: 50
    max_travel_mm: 80
    soft_limits: false
    homing:
      cycle: 3
      positive_direction: true
      mpos_mm: 0.000
      feed_mm_per_min: 300.000
      seek_mm_per_min: 1000.000
      settle_ms: 500
      seek_scaler: 1.100
      feed_scaler: 1.100

    motor0:
      limit_neg_pin: gpio.22:low
      # limit_neg_pin: gpio.22:high
      hard_limits: false
      pulloff_mm: 1.000
      stepstick:
        step_pin: I2SO.7
        direction_pin: I2SO.8
        disable_pin: I2SO.6

  a:
# E0
    steps_per_mm: 85.3
    max_rate_mm_per_min: 4000.000
    acceleration_mm_per_sec2: 50
    max_travel_mm: 3300.000
    soft_limits: false
    homing:
      cycle: 4
      positive_direction: true
      mpos_mm: 0.000
      feed_mm_per_min: 300.000
      seek_mm_per_min: 1000.000
      settle_ms: 500
      seek_scaler: 1.100
      feed_scaler: 1.100

    motor0:
      limit_neg_pin: gpio.35:low
      # limits_neg_pin: gpio.35:high
      hard_limits: false
      pulloff_mm: 1.000
      stepstick:
        step_pin: I2SO.10
        direction_pin: I2SO.11
        disable_pin: I2SO.9

  b:
# E1
    steps_per_mm: 1600
    max_rate_mm_per_min: 1500.000
    acceleration_mm_per_sec2: 100
    max_travel_mm: 15.000
    soft_limits: false
    homing:
      cycle: 0
      positive_direction: true
      mpos_mm: 0.000
      feed_mm_per_min: 300.000
      seek_mm_per_min: 1000.000
      settle_ms: 500
      seek_scaler: 1.100
      feed_scaler: 1.100

    motor0:
      limit_neg_pin: gpio.2:high
      # limit_neg_pin: gpio.2:high
      hard_limits: false
      pulloff_mm: 1.000
      stepstick:
        step_pin: I2SO.13
        direction_pin: I2SO.14
        disable_pin: I2SO.12

i2so:
  bck_pin: gpio.25
  data_pin: gpio.27
  ws_pin: gpio.26

control:
  safety_door_pin: NO_PIN
  reset_pin: NO_PIN
  # Original: gpio.35:high
  feed_hold_pin: NO_PIN
  # feed_hold_pin: gpio.36:low
  cycle_start_pin: gpio.39:low
  # EXP1 BTN_ENC
  macro0_pin: NO_PIN
  macro1_pin: NO_PIN
  macro2_pin: NO_PIN
  macro3_pin: NO_PIN

macros:
  startup_line0: 
  startup_line1:
  macro0: G1F1000X0Y0Z0A0B0
  # macro0: G1F1000X0Y0Z0A0B0
  macro1: 
  macro2: 
  macro3:

coolant:
  flood_pin: NO_PIN
  # gpio.12:high
  mist_pin: NO_PIN
  delay_ms: 0

#probe:
#  pin: gpio.2
#  check_mode_start: true

PWM:
  pwm_hz: 5000
  # on EXP1 IO15 connector.
  # note IO15 will give some short pulses on boot, which may activate spindle
  # use IO17 on EXP1 to avoid
  output_pin: gpio.15
  s0_with_disable: true
  tool_num: 0
  spinup_ms: 0
  spindown_ms: 0
  speed_map: 0=0.000% 10000=100.000%

# PWM Duty Cycle M67 E0 Q50

user_outputs:
  analog0_pin: NO_PIN
  analog1_pin: NO_PIN
  analog2_pin: NO_PIN
  analog3_pin: NO_PIN
  analog0_hz: 5000
  analog1_hz: 5000
  analog2_hz: 5000
  analog3_hz: 5000
  digital0_pin: gpio.14:low
  digital1_pin: gpio.13:low
  digital2_pin: gpio.12:low
  digital3_pin: gpio.21:low
  digital4_pin: gpio.4:low
  digital5_pin: gpio.0:low

start:
  must_home: false

 # USB  TX0(1)  RX0(3)
 # J3-> TX2(17) RX2(16)
 # J1-> I2SO.23 I2SO.22
 # TH1(36)        TH2(34)        THB(39)
 # HE0(I2SO.17)   HE1(I2SO.18)   HBED(I2SO.16)
 # FAN1(I2SO.19)  FAN2(I2SO.20)
 #                   EXP1                                   EXP2
 #(BEEPER) I2SO.21 | 1  2 | 13 (BTN_ENC)    (SPI MISO) 19 | 1  2 | 18 (SPI SCK)
 #    (LCD_EN)  21 | 3  4 |  4 (LCD_RS)      (BTN_EN1) 14 | 3  4 |  5 (SPI CS)
 #    (LCD_D4)   0 | 5  6   16 (LCD_D5)      (BTN_EN2) 12 | 5  6   23 (SPI MOSI)
 #    (LCD_D6)  15 | 7  8 | 17 (LCD_D7)      (SPI_DET) 34 | 7  8 | RESET
 #             GND | 9 10 | 5V                        GND | 9 10 | 3.3V

Startup Messages

[MSG:INFO: FluidNC v3.7.12 https://github.com/bdring/FluidNC]
[MSG:INFO: Compiled with ESP32 SDK:v4.4.4]
[MSG:INFO: Local filesystem type is spiffs]
[MSG:INFO: Configuration file:1.yaml]
[MSG:DBG: Running after-parse tasks]
[MSG:DBG: Checking configuration]
[MSG:INFO: Machine K40 Laser]
[MSG:INFO: Board MKS TinyBee V1.0_001]
[MSG:INFO: UART1 Tx:gpio.17 Rx:gpio.16 RTS:NO_PIN Baud:115200]
[MSG:INFO: I2SO BCK:gpio.25 WS:gpio.26 DATA:gpio.27]
[MSG:DBG: SPI not defined]
[MSG:DBG: See http://wiki.fluidnc.com/en/config/sd_card#sdfallbackcs-access-sd-without-a-config-file]
[MSG:INFO: Stepping:I2S_static Pulse:4us Dsbl Delay:0us Dir Delay:1us Idle Delay:0ms]
[MSG:INFO: User Digital Output:0 on Pin:gpio.14:low]
[MSG:INFO: User Digital Output:1 on Pin:gpio.13:low]
[MSG:INFO: User Digital Output:2 on Pin:gpio.12:low]
[MSG:INFO: User Digital Output:3 on Pin:gpio.21:low]
[MSG:INFO: User Digital Output:4 on Pin:gpio.4:low]
[MSG:INFO: User Digital Output:5 on Pin:gpio.0:low]
[MSG:INFO: Axis count 5]
[MSG:INFO: Axis X (-411.000,0.000)]
[MSG:INFO:   Motor0]
[MSG:INFO:     stepstick Step:I2SO.1 Dir:I2SO.2 Disable:I2SO.0]
[MSG:INFO:  X Neg Limit gpio.33:low]
[MSG:DBG:  X Neg Limit 0]
[MSG:INFO: Axis Y (-182.000,0.000)]
[MSG:INFO:   Motor0]
[MSG:INFO:     stepstick Step:I2SO.4 Dir:I2SO.5 Disable:I2SO.3]
[MSG:INFO:  Y Neg Limit gpio.32:low]
[MSG:DBG:  Y Neg Limit 0]
[MSG:INFO: Axis Z (-80.000,0.000)]
[MSG:INFO:   Motor0]
[MSG:INFO:     stepstick Step:I2SO.7 Dir:I2SO.8 Disable:I2SO.6]
[MSG:INFO:  Z Neg Limit gpio.22:low]
[MSG:DBG:  Z Neg Limit 0]
[MSG:INFO: Axis A (-3300.000,0.000)]
[MSG:INFO:   Motor0]
[MSG:INFO:     stepstick Step:I2SO.10 Dir:I2SO.11 Disable:I2SO.9]
[MSG:INFO:  A Neg Limit gpio.35:low]
[MSG:DBG:  A Neg Limit 0]
[MSG:INFO: Axis B (-15.000,0.000)]
[MSG:INFO:   Motor0]
[MSG:INFO:     stepstick Step:I2SO.13 Dir:I2SO.14 Disable:I2SO.12]
[MSG:INFO:  B Neg Limit gpio.2]
[MSG:DBG:  B Neg Limit 1]
[MSG:INFO: cycle_start_pin gpio.39:low]
[MSG:INFO: Kinematic system: Cartesian]
[MSG:INFO: PWM Spindle Ena:NO_PIN Out:gpio.15 Dir:NO_PIN Freq:5000Hz Period:8191]
[MSG:INFO: Using spindle PWM]
[MSG:INFO: WiFi is disabled]

User Interface Software

FluidTerm

What happened?

I have a short G-code file stored in spiffs and execute the code by "LocalFS/Run=/2.nc". However, while running, messages like "Low memory: 13242 bytes" showed up randomly and the size was descending. After reaching 0, the board restarted and the original task was somehow aborted.

GCode File

% G21 G17 G21 G94 G90 G54 G92 x0Y0 Z0 A0 G0 G00 a-90 m62 p0 G04 p1 m63 p0 m0 G00 a0 G00 z-31 G00 y-198 m62 p4 g04 p1 G01 z0 f1000 G0 y -107 x-96 g1 z-53 m63 p4 g04 p1 G0 y0 x0 A-150 m62 p1 G04 p1 m63 p1 m0 G00 A0 z -60 y-171.85 m62 p4 g04 p1 z 0 y -218.85 z -15 m63 p4 g04 p1 y-198 z-60 m62 p4 g04 p1 z-50 y0 x-280 y-28 z-60 m63 p4 g04 p1 y0 x0 m62 p2 g04 p1 m63 p2 m0 z-60 x-280 y-28 m62 p4 g04 p1 z-50 y0 x-150 z-36 y-108 z-46 m63 p4 g04 p1 y0 x0 a-120 m62 p3 g04 p1 m63 p3 m0 a-150 m62 p3 g04 p1 m63 p3 m0 a0 x-150 y-108 m62 p4 g04 p1 z-36 y0 x0 y-198 z-60 m63 p4 g04 p1 z-53 y0 x-96 y-107 m62 p4 z0 x0 y-151 z-70 m63 p4 y0 G00 a-150 m62 p0 G04 p1 m63 p0 m0 G00 a-60 G00 z-31 G00 y-198 m62 p4 g04 p1 G01 z0 f1000 G0 y -107 x-96 g1 z-53 m63 p4 g04 p1 G0 y0 x0 A-210 m62 p1 G04 p1 m63 p1 m0 G00 A-60 z -60 y-171.85 m62 p4 g04 p1 z 0 y -218.85 z -15 m63 p4 g04 p1 y-198 z-60 m62 p4 g04 p1 z-50 y0 x-280 y-28 z-60 m63 p4 g04 p1 y0 x0 m62 p2 g04 p1 m63 p2 m0 z-60 x-280 y-28 m62 p4 g04 p1 z-50 y0 x-150 z-36 y-108 z-46 m63 p4 g04 p1 y0 x0 a-180 m62 p3 g04 p1 m63 p3 m0 a-210 m62 p3 g04 p1 m63 p3 m0 a-60 x-150 y-108 m62 p4 g04 p1 z-36 y0 x0 y-198 z-60 m63 p4 g04 p1 z-53 y0 x-96 y-107 m62 p4 z0 x0 y-151 z-70 m63 p4 y0 G28 M30 %

Other Information

If I use a shorter G-code, I do not have such issue.

bdring commented 2 months ago

Update the firmware. v3.7.17 addressed a memory issue.

zizheng1 commented 2 months ago

Thank you! I will update the firmware.

MitchBradley commented 2 months ago

In addition to the version problem, there are other problems that can happen when running long gcode files from localfs. Accessing FLASH as data can interfere with interrupts, which can cause problems with realtime step generation. We recommend using SD cards for gcode files.