@Phaedrux Also, thanks for responding!
Posts made by stephencreech
-
RE: M291 S5 - To move Z axis
@Phaedrux I just read about this a few hours ago. I'm going to try it and see. I also realized I didn't put the "input^" into a var; I assume I need to store that Zaxis number first, correct?
-
M291 S5 - To move Z axis
Hi,
I'm trying to move the Z axis of a CNC based on a number input from an M291 S5 Prompt. Everything is working except when driving the Z-axis from the input variable, which errors and says, 'G1: target position outside machine limits'.
I set the M208 minima and maxima, but I still get errors. Any Suggestions?
Macro:
;Home all
; increase Z
G91 ; relative positioning
G1 H1 Z5 F6000 ; move Z relative to current position to avoid dragging nozzle over the bed
G90 ; absolute positioning; home XY
var xTravel = move.axes[0].max - move.axes[0].min + 5 ; calculate how far X can travel plus 5mm
var yTravel = move.axes[1].max - move.axes[1].min + 5 ; calculate how far Y can travel plus 5mm
G91 ; relative positioning
G1 H1 X{-var.xTravel} Y{-var.yTravel} F600 ; coarse home in the -X and -Y directions
G1 H2 X5 Y5 F6000 ; move back 5mm
G1 H1 X{-var.xTravel} Y{-var.yTravel} F300 ; fine home in the -X and -Y directions
G90 ; absolute positioning; home Z
var zTravel = move.axes[2].max - move.axes[2].min + 25 ; calculate how far Z can travel plus 5mm
G91 ; relative positioning
G1 H1 Z{var.zTravel} F600 ; coarse home in the +Z direction
G1 H2 Z-5 F6000 ; move back 5mm
G1 H1 Z10 F300 ; fine home in the +Z direction
G90 ; absolute positioning; Prompt the user to enter a measurement
M291 P"Enter the height in mm (e.g., 30):" R"Input Required" S5 L0 H150 F100; Convert the entered value from inches to millimeters
var height = {move.axes[2].userPosition} ; Get the user input (assuming it's stored in Z)
;var height_mm = var.height * 25.4 ; Convert inches to millimeters; Move the Z axis to the user-specified height
G1 Z{var.height} F3000; Traverse the Y axis for the full length
G91 ; Set relative positioning
G1 Y-500 F3000 ; Move Y to the end of its range (adjust the distance as necessary)
G1 Y500 F3000 ; Move Y back to the start
G90 ; Set back to absolute positioning