How can I read the machine position for conditionals?
-
E.g there are lots of relative moves on the z axis that are there to move the head out of the way in the homing code. But being a CNC, the z position is often already near max.
How could I say e.g (pseudo code)
if ("z axis position" < 50) {
...do the relative z move up
} else {
...do nothing.
} -
@tqkez-0
Something like this will do itif {(move.axes[2].machinePosition) < (move.axes[2].max - 10)} ; check if there's sufficient space to raise head M291 P{"Raising head to... Z" ^ (move.axes[2].machinePosition+5)} R"Raising head" S0 T2 G91 ; relative positioning G1 Z5 F120 ; move Z up a bit G90 ;absolute positioning
-
@owend said in How can I read the machine position for conditionals?:
@tqkez-0
Something like this will do itif {(move.axes[2].machinePosition) < (move.axes[2].max - 10)} ; check if there's sufficient space to raise head M291 P{"Raising head to... Z" ^ (move.axes[2].machinePosition+5)} R"Raising head" S0 T2 G91 ; relative positioning G1 Z5 F120 ; move Z up a bit G90 ;absolute positioning
Perfect thanks!
I've trying to find the list of variables that can be accessed, but i can only seem to find info in the docs about creating custom variables. Is there a list somewhere?
-
Check out the object model. https://duet3d.dozuki.com/Wiki/Object_Model_of_RepRapFirmware
DuetWebControl also includes an object model plugin (at least newer versions do). Run that and you should be able to access the position for each axis and reference it using variations of @TQKez-0's example.