Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    Instabilty after if with logical or

    Scheduled Pinned Locked Moved
    Gcode meta commands
    2
    4
    160
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DonStaufferundefined
      DonStauffer
      last edited by DonStauffer

      This macro works reliably if I avoid the logical or (||) on the if inside the loop. With the logical or, it works maybe the first half dozen times it gets called, then there's a spontaneous reboot. I've switched back and forth several times and it's consistent. See "This works" and "This reboots" comments in the code. In this case the SetNeoPix macro was always called with the A1 parameter. After a failure, I find it safest to power down for a count of 10 before testing again, or it seems like the instability can persist even if the problem is corrected.

      ;-------------------------------------------------------------------------------
      ;	SetNeoPix
      ;-------------------------------------------------------------------------------
      ;   Changes pending NeoPixel data in preparation for updating the display.
      ;   This macro does no I2C communication. ShowNeoPix macro sends and shows data.
      ;
      ;   Parameters:
      ;       A   A1: "Add" color values to any existing pending values in range
      ;           A0: "Don't Add"; just set pending values in range
      ;		C	Color array {R, G, B} to add or set LEDs to
      ;		N	Number of LEDs to potentially change
      ;		S	Starting LED number of LEDs to potentially change
      ;-------------------------------------------------------------------------------
      ;	Don Stauffer							May, 2024
      ;-------------------------------------------------------------------------------
      if global.DebugLevel >= 1100
          echo "SetNeoPix S"^param.S, "N"^param.N, "C"^param.C, "A"^param.A
      ;-------------------------------------------------------------------------------
      ;   Subscript Constants
      
      var COUNT = 1
      var COLOR = 2
      var PEND = 1
      
      ;   Parameters
      
      var ShouldAdd = exists(param.A) ? param.A == 1 : false
      var Color = exists(param.C) ? param.C : {0, 0, 0}
      var Count = exists(param.N) ? param.N : global.NeoPix[var.COUNT]
      var NumStart = exists(param.S) ? param.S : 0
      
      ;   Loop through affected LEDs and make changes to pending values
      
      var LEDNum = null
      var Pend = {0, 0, 0}
      ;-------------------------------------------------------------------------------
      while iterations < var.Count
      
          ;   Get existing pending color for LED
      
          set var.LEDNum = var.NumStart + iterations
          set var.Pend = global.NeoPix[var.COLOR][var.PEND][var.LEDNum]
      
          ;   If not adding or nothing to add to, just set pending color
      
          ;----------------------------
          ;   This works:
          ;----------------------------
          if !var.ShouldAdd
              set global.NeoPix[var.COLOR][var.PEND][var.LEDNum] = var.Color
              continue
      
          if var.Pend[0] == null
              set global.NeoPix[var.COLOR][var.PEND][var.LEDNum] = var.Color
              continue
          ;----------------------------
      
          ;----------------------------
          ;   This reboots:
          ;----------------------------
          ;if !var.ShouldAdd || var.Pend[0] == null
          ;    set global.NeoPix[var.COLOR][var.PEND][var.LEDNum] = var.Color
          ;    continue
          ;----------------------------
      
          ;   Add new color to existing pending color
      
          while iterations < 3
              set var.Pend[iterations] = var.Pend[iterations] + var.Color[iterations]
      
          set global.NeoPix[var.COLOR][var.PEND][var.LEDNum] = var.Pend
      ;-------------------------------------------------------------------------------
      if global.DebugLevel >= 1100
          echo "Exiting SetNeoPix"
      ;-------------------------------------------------------------------------------
      

      Global Initialization Macro:

      ;-------------------------------------------------------------------------------
      ;	InitNeoPix
      ;-------------------------------------------------------------------------------
      ;   Initializes NeoDriver and turns off LEDs.
      ;-------------------------------------------------------------------------------
      ;	Don Stauffer							        May, 2024
      ;-------------------------------------------------------------------------------
      
      ;   Subscript Constants
      
      var ADDR = 0
      var COUNT = 1
      var COLOR = 2
      
      var I2C = 0
      ;var BASE = 1
      
      var SENT = 0
      var PEND = 1
      
      ;   Other Constants
      
      var ADDR_I2C = 0x60
      var ADDR_BASE = 0x0E
      var LED_COUNT = 28
      
      var FUNC_REG_PIN = 0x01
      var FUNC_REG_SPEED = 0x02
      var FUNC_REG_BUF_LENGTH = 0x03
      
      var SPEED400khz = 0
      var SPEED800khz = 1
      
      ;   Parameters
      
      var NeoPixelPinNum = 0x0F
      
      ;   Define array
      
      if !exists(global.NeoPix)
          global NeoPix = vector(3, null)
      
      set global.NeoPix[var.ADDR] = {var.ADDR_I2C, var.ADDR_BASE}
      
      set global.NeoPix[var.COUNT] = var.LED_COUNT
      
      set global.NeoPix[var.COLOR] = vector(2, null)
      set global.NeoPix[var.COLOR][var.SENT] = vector(var.LED_COUNT, {0, 0, 0})
      set global.NeoPix[var.COLOR][var.PEND] = vector(var.LED_COUNT, vector(3, null))
      
      DonStaufferundefined 1 Reply Last reply Reply Quote 0
      • DonStaufferundefined
        DonStauffer @DonStauffer
        last edited by

        @DonStauffer M122
        === Diagnostics ===
        RepRapFirmware for Duet 2 WiFi/Ethernet version 3.5.1+3 (2024-05-21 20:58:33) running on Duet WiFi 1.02 or later + DueX5
        Board ID: 08DGM-9T6BU-FG3SN-6JKD0-3S06Q-9AY7D
        Used output buffers: 3 of 26 (22 max)
        === RTOS ===
        Static ram: 23304
        Dynamic ram: 75824 of which 0 recycled
        Never used RAM 11160, free system stack 184 words
        Tasks: NETWORK(2,nWait 6,8.2%,215) HEAT(3,nWait 5,0.1%,328) Move(4,nWait 5,0.0%,345) DUEX(5,nWait 5,0.0%,23) MAIN(1,running,87.4%,678) IDLE(0,ready,4.3%,29), total 100.0%
        Owned mutexes:
        === Platform ===
        Last reset 00:00:18 ago, cause: software
        Last software reset at 2024-05-24 18:39, reason: OutOfMemory, Platform spinning, available RAM 8, slot 0
        Software reset code 0x41c0 HFSR 0x00000000 CFSR 0x00000000 ICSR 0x0041f000 BFAR 0xe000ed38 SP 0x200047d8 Task HEAT Freestk 354 ok
        Stack: 20019848 004106fb 00000000 00400247 00000000 00000000 00000018 00400299 00000010 00000000 200041bc 2000cc78 200041c4 004601c1 200041d0 0045b77f 20004850 200041bc 00000000 0043088f 20004850 200041bc 00000000 2000488c 2000ca58 2000cc84 200041bc
        Error status: 0x00
        Aux0 errors 0,0,0
        MCU temperature: min 46.3, current 47.2, max 47.4
        Supply voltage: min 24.1, current 24.1, max 24.3, under voltage events: 0, over voltage events: 0, power good: yes
        Heap OK, handles allocated/used 99/36, heap memory allocated/used/recyclable 2048/1344/172, gc cycles 8
        Events: 0 queued, 0 completed
        Driver 0: standstill, SG min n/a
        Driver 1: standstill, SG min n/a
        Driver 2: standstill, SG min n/a
        Driver 3: standstill, SG min n/a
        Driver 4: standstill, SG min n/a
        Driver 5: standstill, SG min n/a
        Driver 6: standstill, SG min n/a
        Driver 7: standstill, SG min n/a
        Driver 8: standstill, SG min n/a
        Driver 9: standstill, SG min n/a
        Driver 10:
        Driver 11:
        Date/time: 2024-05-24 18:39:43
        Cache data hit count 737573386
        Slowest loop: 9.42ms; fastest: 0.20ms
        I2C nak errors 0, send timeouts 0, receive timeouts 0, finishTimeouts 0, resets 0
        === Storage ===
        Free file entries: 9
        SD card 0 detected, interface speed: 20.0MBytes/sec
        SD card longest read time 2.0ms, write time 0.0ms, max retries 0
        === Move ===
        DMs created 83, segments created 0, maxWait 0ms, bed compensation in use: none, height map offset 0.000, max steps late 0, min interval 0, bad calcs 0, ebfmin 0.00, ebfmax 0.00
        no step interrupt scheduled
        Moves shaped first try 0, on retry 0, too short 0, wrong shape 0, maybepossible 0
        === DDARing 0 ===
        Scheduled moves 0, completed 0, hiccups 0, stepErrors 0, LaErrors 0, Underruns [0, 0, 0], CDDA state -1
        === Heat ===
        Bed heaters 0 -1 -1 -1, chamber heaters -1 -1 -1 -1, ordering errs 0
        Heater 1 is on, I-accum = 0.0
        === GCodes ===
        Movement locks held by null
        HTTP is idle in state(s) 0
        Telnet is idle in state(s) 0
        File is idle in state(s) 0
        USB is idle in state(s) 0
        Aux is idle in state(s) 0
        Trigger is idle in state(s) 0
        Queue is idle in state(s) 0
        LCD is idle in state(s) 0
        Daemon is doing "G4 P{var.DaemonPeriod}" in state(s) 0 0, running macro
        Autopause is idle in state(s) 0
        Q0 segments left 0
        Code queue 0 is empty
        === Filament sensors ===
        check 0 clear 102805
        Extruder 0 sensor: no data received
        Extruder 1 sensor: no data received
        === DueX ===
        Read count 1, 3.31 reads/min
        === Network ===
        Slowest loop: 8.54ms; fastest: 0.00ms
        Responder states: HTTP(0) HTTP(0) HTTP(0) FTP(0) Telnet(0)
        HTTP sessions: 1 of 8
        === WiFi ===
        Interface state: active
        Module is connected to access point
        Failed messages: pending 0, notrdy 0, noresp 0
        Firmware version 2.1.0
        MAC address 84:f3:eb:83:47:be
        Module reset reason: Power up, Vcc 3.36, flash size 4194304, free heap 42976
        WiFi IP address 192.168.1.130
        Signal strength -48dBm, channel 11, mode 802.11n, reconnections 0
        Clock register 00002002
        Socket states: 0 0 0 0 0 0 0 0

        dc42undefined 1 Reply Last reply Reply Quote 0
        • dc42undefined
          dc42 administrators @DonStauffer
          last edited by

          @DonStauffer is this still an issue in RRF 3.5.3-rc.1 ?

          Duet WiFi hardware designer and firmware engineer
          Please do not ask me for Duet support via PM or email, use the forum
          http://www.escher3d.com, https://miscsolutions.wordpress.com

          DonStaufferundefined 1 Reply Last reply Reply Quote 0
          • DonStaufferundefined
            DonStauffer @dc42
            last edited by

            @dc42 I suspect it was just running out of memory, but I haven't tried this particular construct again with more free memory. I'll try it tomorrow.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Unless otherwise noted, all forum content is licensed under CC-BY-SA