Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: alexzkter on November 14, 2019, 08:19:13 AM

Title: [MACRO] Move the Y axis after job end by a predefined amount with MaxY() ?
Post by: alexzkter on November 14, 2019, 08:19:13 AM
Hi,

I'm trying to park the tool dynamically after the machine ends cutting and I came upon the MaxY() function, which returns the Machine coordinates of an axis from a gcode.

Problem is, this macro is evaluated only while the tool path is generated, that is, before actually cutting. So if I zero my axis after loading the cut file, the final move is not where I expected it, because the tool path took into account the old zeros.

Code: [Select]
'Define the axes
Dim Xaxis As Integer
Xaxis = 0
Dim Yaxis As Integer
Yaxis = 1
Dim Zaxis As Integer
Zaxis = 2

'Define the X&Y work dimensions
Dim X_axis_length As Double
X_axis_length = 1300.0
Dim Y_axis_length As Double
Y_axis_length = 2550.0

'Define variables to store the machine position for the Y axis
Dim Y_MaxReachedMachinePos As Double

'Get Y Axis max reached value of machine coordinates during the cut 
Y_MaxReachedMachinePos = MaxY()




' Move Z axis to Safe_Z position
GotoSafeZ()
While IsMoving()
Wend

'Compare which of the 3 table areas the tool reached to know how far it can be moved in the Y direction after job finished.
If Y_MaxReachedMachinePos <= (Y_axis_length/3) Then
Code "G0G53 X20.0 Y" & Y_MaxReachedMachinePos+600.0 'Move the tool 60cm in the Y direction
'While IsMoving()
'Sleep 100
'Wend


ElseIf Y_MaxReachedMachinePos > (Y_axis_length/3) And Y_MaxReachedMachinePos <= (Y_axis_length*2/3) Then
Code "G0G53 X20.0 Y" & Y_MaxReachedMachinePos 'Move the tool 45cm in the Y direction
'While IsMoving()
'Sleep 100
'Wend


ElseIf (Y_MaxReachedMachinePos+450.0) < Y_axis_length Then
Code "G0G53 X20.0 Y" & Y_MaxReachedMachinePos 'Move the tool 45cm in the Y direction
'While IsMoving()
'Sleep 100
'Wend

Else
Code "G0G53 X20.0 Y" & Y_axis_length 'Move the tool all the way back in the Y direction
'While IsMoving()
'Sleep 100
'Wend

End If

Y_MaxReachedMachinePos=0

Is there a way to accomplish this? Like, executing the macro only after the machine starts cutting, for isntance?
Enabling "Ignore M calls while loading" didn't work.


Thanks in advance, Alejandro.
Title: Re: [MACRO] Move the Y axis after job end by a predefined amount with MaxY() ?
Post by: TPS on November 15, 2019, 03:41:48 PM
that is the Problem between zeroing an axis and home a axis (by using a Limit Switch).
if you only "Zero" a axis you never know where this Zero is based on max of axis movement.

if you home an axis by using a Limit Switch you allways know exactly where the axis is (in machine
coords) by using G53.