The macro works great, except if you try and feedhold while the reference is happening. I've had it crash my smoothstepper and freeze mach.
I think it might have something to do with the ismoving loops, but if I leave them out mach seems to skip over the code.
Any ideas on a way to fix this?
Code: Select all
OhmicLED = 1503 ' LED that indicates OFF
TouchLED = 1504 ' LED that indicates ON
RefFeed = 1120 ' Ref Feed from Settings
PlungeSafety = 1121 ' Plunge Safety from Settings
TrialZ = 1122 ' Trial Z from Settings
SwitchOffset = 1045 ' Switch Offset from Settings
If GetUserLED(OhmicLED) Then
If IsActive(DIGITIZE) Then
Message "Ohmic sensor jammed."
MsgBox "Ohmic sensor jammed. Clear and hit RUN to continue. ", 0 + 48 , "Clear Z Jam"
Code ("M0")
Else
Code("G00 Z" & GetUserDRO(PlungeSafety) & " (Start probe touch-off)")
While (IsMoving())
'Sleep, so other threads can run while we’re waiting
Sleep(100)
Wend
Code("G31 Z -3.937 F" & GetUserDRO(RefFeed))
While (IsMoving())
'Sleep, so other threads can run while we’re waiting
Sleep(100)
If IsActive(ZHOME) Then 'ohmic missed
Message "Ohmic sensor missed."
If MsgBox ("Ohmic sensor missed. Use touch?", 4 + 48, "Ohmic sensor missed.") = 6 Then
Code("G92 Z0.0")
While (IsMoving())
'Sleep, so other threads can run while we’re waiting
Sleep(100)
Wend
Code("G00 Z" & GetUserDRO(SwitchOffset) & " (Switch offset lift)")
While (IsMoving())
'Sleep, so other threads can run while we’re waiting
Sleep(100)
Wend
Else
Message ""
code ("M0")
End
End If
End If
Wend
Code("G92 Z0.0")
While (IsMoving())
'Sleep, so other threads can run while we’re waiting
Sleep(100)
Wend
If GetOEMLED(66) Then 'trial Z offset
Code("G92 Z -" & GetUserDRO(TrialZ) & " (Trial Z offset)")
While (IsMoving())
'Sleep, so other threads can run while we’re waiting
Sleep(100)
Wend
Code ("G00 Z 0.0")
End If
End If
Else
If GetUserLED(TouchLED) Then 'touch
If IsActive(ZHOME) Then
Message "Touch switch jammed."
MsgBox "Touch switch jammed. Clear and hit RUN to continue. ", 0 + 48, "Clear Z Jam"
Code ("M0")
Else
Code("G28.1 Z" & GetUserDRO(PlungeSafety) & " (Start touch-off)")
While (IsMoving())
'Sleep, so other threads can run while we’re waiting
Sleep(100)
Wend
Code("G92 Z0.0")
While (IsMoving())
'Sleep, so other threads can run while we’re waiting
Sleep(100)
Wend
Code("G00 Z" & GetUserDRO(SwitchOffset) & " (Switch offset lift)")
While (IsMoving())
'Sleep, so other threads can run while we’re waiting
Sleep(100)
Wend
Code("G92 Z0.0")
While (IsMoving())
'Sleep, so other threads can run while we’re waiting
Sleep(100)
Wend
If GetOEMLED(66) Then 'trial Z offset
Code("G92 Z -" & GetUserDRO(TrialZ) & " (Trial Z offset)")
While (IsMoving())
'Sleep, so other threads can run while we’re waiting
Sleep(100)
Wend
Code ("G00 Z 0.0")
End If
End If
End If
End If