Array index out of bounds error
-
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?
-
@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 issensorrs.endstops[2]
. -
@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?
-
@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.