2101
General Mach Discussion / Re: Mach3 Turn, can't jog, g-codes work normal
« on: February 02, 2018, 10:00:49 AM »
jog mode enebled ?
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
'calculate the actual value from laser
'based on (rawvalue * multiplicator) - offset
actmm = GetUserDro(1000) * GetUserDro(1150)
SetUserDro(1151, actmm )
SetUserDro(1154, 1000.0 - actmm -GetUserDro(1153))
' ---------------------------------------------------------------------------------
' TPS 26.01.2018
' ATC macro for 8 places
' V 1.0.0
' ---------------------------------------------------------------------------------
' Main routine for tool change -----------------------------------------------------
Sub Main()
' declare ten global variables ----------------------------------------------------
Dim Pos_X_Tool(8) as double
' variables for the feedrate
F_slow = 400 'feedrate for slow moves
F_fast = 2000 'feedrate for fast moves
'remark all TC position are in machine coordinates !!!
'variables for the X positions
Pos_X_Tool(1) = 100.0000 'X position for tool 1
Pos_X_Tool(2) = 200.0000 'X position for tool 2
Pos_X_Tool(3) = 300.0000 'X position for tool 3
Pos_X_Tool(4) = 400.0000 'X position for tool 4
Pos_X_Tool(5) = 500.0000 'X position for tool 5
Pos_X_Tool(6) = 600.0000 'X position for tool 6
Pos_X_Tool(7) = 700.0000 'X position for tool 7
Pos_X_Tool(8) = 800.0000 'X position for tool 8
'variables for the Y Position
Pos_Y_before = 200.0000 'Y position in front of TC
Pos_Y_in = 100.0000 'Y position in TC
'variables for the Z Position
Pos_Z_save = 300.0000 'Z position over all that we can move (X/Y) save to TC
Pos_Z_over = 200.0000 'Z position over the placed tool (X move possible)
Pos_Z_in = 100.0000 'Z position in TC
'variable for toolclamp output
TC_output = Output1
'variable for delay open/close toolclamp
TC_wait = 1000
' ---------------------------------------------------------------------------------
'get the tool relvated numbers
newtool = GetSelectedTool() 'get the new toolnumber
acttool = GetCurrentTool() 'get the actual toolnumber
'do some basic check's
' no tool loaded nothing to unload
If ((newtool = 0) and (acttool = 0)) Then
message("no tool loaded nothing to unload !")
Exit Sub
End If
' nothing to do newtool = acttool
If newtool = acttool Then
message("nothing to do newtool = acttool !")
Exit Sub
End If
'check toolnumber in range
If (((newtool > 8) Or (newtool < 1)) and (newtool <> 0)) Then
Message (" toolnumber " & newtool & " is not in range (1-8). abort toolchange ! ")
DoButton(3)
Exit Sub
End If
'X-axis is not referenced
If GetOEMLED(807) Then
Message ("X-axis no reference -> abort !!")
DoButton(3)
Exit Sub
End If
'Y-axis is not referenced
If GetOEMLED(808) Then
Message ("Y-axis no reference -> abort !!")
DoButton(3)
Exit Sub
End If
'Z-axis is not referenced
If GetOEMLED(809) Then
Message ("Z-axis no reference -> abort !!")
DoButton(3)
Exit Sub
End If
Message "change tool: " +CStr(acttool) + " to: " + CStr(newtool)
'get the current position and settings
CurrentFeed = GetOemDRO(818) 'Get the current feedrate to return to later
CurrentAbsInc = GetOemLED(48) 'Get the current G90/G91 state
CurrentGmode = GetOemDRO(819) 'Get the current G0/G1 state
CurrentXpos = GetOemDRO(83) 'Get t X position where we came from
CurrentYpos = GetOemDRO(84) 'Get t Y position where we came from
CurrentZpos = GetOemDRO(85) 'Get t Z position where we came from
'Get Axis Scale factors in use
XScale = GetOEMDRO(59)
YScale = GetOEMDRO(60)
ZScale = GetOEMDRO(61)
'Set All Axis Scales to 1
SetOEMDRO(59,1)
SetOEMDRO(60,1)
SetOEMDRO(61,1)
Sleep(250)
' turn spindle off just in case
Code "M5"
' go to save Z position
Message "goto Z-save"
Code "G53 G90 G01 Z"+CStr(Pos_Z_save)+"F"+CStr(F_fast)
WaitForMove
'only unload tool
If newtool = 0 Then
'go to X/Y position (Y-before)
Message "go to X/Y position"
Code "G53 G90 G01 X"+CStr(Pos_X_Tool(acttool))+"Y"+CStr(Pos_Y_before)
WaitForMove
'goto Z-in fast
Message "goto Z-in fast"
Code "G53 G90 G01 Z"+CStr(Pos_Z_in)
WaitForMove
'go to Y position in
Message "go to Y position in"
Code "G53 G90 G01 Y"+CStr(Pos_Y_in)+"F"+CStr(F_slow)
WaitForMove
'open toolclamp
Message "open toolclamp"
ActivateSignal(TC_output)
Sleep(TC_wait)
'goto Z-over slow
Message "goto Z-over slow"
Code "G53 G90 G01 Z"+CStr(Pos_Z_over)
WaitForMove
End If
'only load tool
If acttool = 0 Then
'go to X/Y position
Message "go to X/Y position"
Code "G53 G90 G01 X"+CStr(Pos_X_Tool(newtool))+"Y"+CStr(Pos_Y_in)
WaitForMove
'goto Z-over fast
Message "goto Z-over fast"
Code "G53 G90 G01 Z"+CStr(Pos_Z_over)
WaitForMove
'open toolclamp
Message "open toolclamp"
ActivateSignal(TC_output)
Sleep(TC_wait)
'goto Z-in slow
Message "' goto Z-in slow"
Code "G53 G90 G01 Z"+CStr(Pos_Z_in)+"F"+CStr(F_slow)
WaitForMove
'close toolclamp
Message "close toolclamp"
DeactivateSignal(TC_output)
Sleep(TC_wait)
'go to Y position before
Message "go to Y position before"
Code "G53 G90 G01 Y"+CStr(Pos_Y_before)
WaitForMove
End If
'full tool change
If ((acttool <> 0) and (newtool <> 0)) Then
'unload tool
'go to X/Y position (Y-before)
Message "go to X/Y position"
Code "G53 G90 G01 X"+CStr(Pos_X_Tool(acttool))+"Y"+CStr(Pos_Y_before)
WaitForMove
'goto Z-in fast
Message "goto Z-in fast"
Code "G53 G90 G01 Z"+CStr(Pos_Z_in)
WaitForMove
'go to Y position in
Message "go to Y position in"
Code "G53 G90 G01 Y"+CStr(Pos_Y_in)+"F"+CStr(F_slow)
WaitForMove
'open toolclamp
Message "open toolclamp"
ActivateSignal(TC_output)
Sleep(TC_wait)
'goto Z-over slow
Message "goto Z-over slow"
Code "G53 G90 G01 Z"+CStr(Pos_Z_over)
WaitForMove
'load new tool
'go to X/Y position
Message "go to X/Y position"
Code "G53 G90 G01 X"+CStr(Pos_X_Tool(newtool))+"Y"+CStr(Pos_Y_in)+"F"+CStr(F_fast)
WaitForMove
'goto Z-in slow
Message "' goto Z-in slow"
Code "G53 G90 G01 Z"+CStr(Pos_Z_in)+"F"+CStr(F_slow)
WaitForMove
'close toolclamp
Message "close toolclamp"
DeactivateSignal(TC_output)
Sleep(TC_wait)
'go to Y position before
Message "go to Y position before"
Code "G53 G90 G01 Y"+CStr(Pos_Y_before)
WaitForMove
End If
' go to save Z position
Message "goto Z-save"
Code "G53 G90 G01 Z"+CStr(Pos_Z_save)+"F"+CStr(F_fast)
WaitForMove
'restore the origin values
Code "F" &CurrentFeed 'Returns to prior feed rate
If CurrentAbsInc = 0 Then 'if G91 was in effect before then return to it
Code "G91"
End If
If CurrentGMode = 0 Then ' if G0 was in effect before then return to it
Code "G0"
End If
'Put previous Axis Scale factors back
SetOEMDRO(59,XScale)
SetOEMDRO(60,YScale)
SetOEMDRO(61,ZScale)
Sleep(250)
'set new tool
SetCurrentTool( newtool )
' go back to the position we came from
Message "goto origin X/Y"
Code "G53 G01 X"+CStr(CurrentXpos)+"Y"+CStr(CurrentYpos)
WaitForMove
Message "goto origin Z"
Code "G53 G01 Z"+CStr(CurrentZpos)
WaitForMove
'set new tool
SetCurrentTool( newtool )
Message " "
End Sub
'global Sub's
Sub WaitForMove ()
While IsMoving()
Sleep(15)
Wend
End Sub