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

    Array index out of bounds error

    Scheduled Pinned Locked Moved
    General Discussion
    2
    4
    258
    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.
    • oliverkerstenundefined
      oliverkersten
      last edited by

      I am developing a PnP machine with a duet3d 6xd. On the PnP head I have a IR sensor, this will stay high if the head is past the mid position and will remain low if it is below the mid position. The Duet needs center the head, it will do this by checking this IR sensor and then turnin the motor in the correct direction to center the head. THis code I have written in my homez.g

      G91                         ; Relative positioning
      ; Decide direction based on sensor state
      
      if sensors.gpIn[0].value == 0
        echo "Sensor LOW — moving up to mid position"
        G1 H1 Z5 F600             ; Move up until sensor triggers
      else
        echo "Sensor HIGH — moving down to mid position"
        G1 H1 Z-5 F600            ; Move down until sensor triggers
      ; Sensor is triggered — refine position
      G1 H2 Z2 F300               ; Back off
      G1 H1 Z-3 F200              ; Re-approach slowly
      G90                         ; Absolute positioning
      

      in config.g I have set up the pin as following:

      M574 Z1 P"io2.in" S1 ; configure Y axis endstop
      

      SO when I try to home the Z-Axis I get the following error: meta command: array index out of bounds.

      chatgpt suggested to use

      [^"io0.in"]
      

      but this didnt help either. I dont know what is causing this problem, I hope someone can help me?

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

        @oliverkersten the expression sensors.gpIn[0] reads the state of GpIn pin 0, which I presume you haven't defined. I think the expression you want is sensorrs.endstops[2].

        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

        oliverkerstenundefined 1 Reply Last reply Reply Quote 0
        • oliverkerstenundefined
          oliverkersten @dc42
          last edited by

          @dc42 Thanks I fot it working with using sensorrs.endstops[2].triggerd.

          If I wanted to use a input then I should use M950 and then sensors.gpIn[] should also work?

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

            @oliverkersten said in Array index out of bounds error:

            @dc42 Thanks I fot it working with using sensorrs.endstops[2].triggerd.

            If I wanted to use a input then I should use M950 and then sensors.gpIn[] should also work?

            Yes. An input can't be simultaneously and endstop and a GpIn port.

            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

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