Hello Guest it is March 29, 2024, 07:30:21 AM

Author Topic: IsMoving Hangs Mach3  (Read 4978 times)

0 Members and 1 Guest are viewing this topic.

IsMoving Hangs Mach3
« on: July 18, 2014, 05:26:25 PM »
Hello All,

I have a custom version of a Z zeroing macro I found here.  For some reason one of the IsMoving loops hangs Mach3 when it executes.  The only way I can regain control is to hit the reset button in mach.  The last message I see is "Retracting Probe to touch depth" and it never comes out of the IsMoving loop as "Retract Complete" never shows up.  Anyone have thoughts on this?  I am running version 066 (latest - just downloaded).  I am calling the script from the Set Z Height button on the Offsets tab.  Any input is greatly appreciated.

Thanks.
Greg

Code: [Select]
DownStroke = -0.5 'Set the down stroke to find probe
DownFeedRate = 10 'Set the down FeedRate
RetractStroke = 0.5 'Set the retract Stroke
RetractFeedRate = 40 'Set the retract FeedRate
PlateThickness = 0.060

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
' Not getting correct value for PlateThickness - hard coded for now
' PlateThickness = GetUserDRO(1151) 'Z-plate thickness DRO
If GetOemLed (825)=0 Then 'Check to see if the probe is already grounded or faulty
DoOEMButton (1010) 'zero the Z axis so the probe move will start from here
Code "G4 P2" ' this delay gives me time to get from computer to hold probe in place
Code "G90 G31 Z" &DownStroke &" F" &DownFeedRate 'probing move
While IsMoving() 'wait while it happens
Wend
ZProbePos = GetVar(2002) 'get the axact point the probe was hit
If Abs(ZprobePos) <= Abs(DownStroke)-0.1 Then 'Check if the probe has been found
Code "G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun
While IsMoving ()
Code "(Retracting Probe to touch depth)"
Wend
Code "(Retract Complete)"
Call SetDro (2, PlateThickness) 'set the Z axis DRO to whatever is set as plate thickness
Code "G4 P0.25" 'Pause for Dro to update.
Code "G1 Z" &RetractStroke &" F" &RetractFeedRate 'retract
While IsMoving ()
Wend
Code "(Z axis is now zeroed - hard coded to " &PlateThickness &")" 'puts this message in the status bar
Else
Code "G0 Z0" 'retract to start pos
While IsMoving ()
Wend
Code "(Z-Plate not found, check connection or stroke - try again)" 'puts this message in the status bar
End If
Else
Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if aplicable
End If
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
Exit Sub     

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: IsMoving Hangs Mach3
« Reply #1 on: July 18, 2014, 06:40:36 PM »
Get rid of the "Code" in the middle of the While IsMoving

While IsMoving ()
         Code "(Retracting Probe to touch depth)"
      Wend
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: IsMoving Hangs Mach3
« Reply #2 on: July 18, 2014, 08:17:16 PM »
Gerry,

I changed the section of code so that I now appears as shown below.  There was no change in behavior.  The Z axis still stopped after making contact and Mach had to be reset to regain control.

Thanks.
Greg

Code: [Select]
If Abs(ZprobePos) <= Abs(DownStroke)-0.1 Then 'Check if the probe has been found
Code "G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun
                Code "(Retracting Probe to touch depth)"
While IsMoving ()
Wend
Code "(Retract Complete)"
Re: IsMoving Hangs Mach3
« Reply #3 on: July 19, 2014, 02:02:32 PM »
Just as an update, I thought I could be clever and re-wrote the macro so that the IsMoving loop wasn't necessary.  I just set the DRO based on the plate thickness and amount of overrun found.  The new version is below.  Everything except the move command seems to be working.  When I attempt to run the new macro, the probe moves until the probe touches, the Z axis DRO is reset, and the last message is "Z Zero Routine Complete".  Except the probe doesn't retract as commanded.   Very strange behavior.

Does anyone know if Mach has a log file of all G code executed or anything where I can get some more debugging info from Mach?

Any suggestions are welcome.

Thanks.
Greg

Code: [Select]
DownStroke = -0.5 'Set the down stroke to find probe
DownFeedRate = 10 'Set the down FeedRate
RetractStroke = 0.5 'Set the retract Stroke
RetractFeedRate = 40 'Set the retract FeedRate
PlateThickness = 0.060

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
' Not getting correct value for PlateThickness - hard coded for now
' PlateThickness = GetUserDRO(1151) 'Z-plate thickness DRO
If GetOemLed (825)=0 Then 'Check to see if the probe is already grounded or faulty
DoOEMButton (1010) 'zero the Z axis so the probe move will start from here
Code "G4 P2" ' this delay gives me time to get from computer to hold probe in place
Code "G90 G31 Z" &DownStroke &" F" &DownFeedRate 'probing move
While IsMoving() 'wait while it happens
Wend
Code "(Probe Complete: " & GetVar(2002) & ")"
ZProbePos = GetVar(2002) 'get the axact point the probe was hit
Code "(Checking)"
If Abs(ZprobePos) <= Abs(DownStroke)-0.1 Then 'Check if the probe has been found
' Set Z DRO to plate thickness, less the amount of overrun where
' the overrun is the difference between the probe trigger point
' and the current position
Code "(Probe OK!)"
Call SetDro (2, PlateThickness - (ZProbePos - GetOEMDRO(802)))
Code "G4 P0.25" 'Pause for Dro to update.
Code "G1 Z" &RetractStroke &" F" &RetractFeedRate 'retract
Code "(Z axis is now zeroed - hard coded to " &PlateThickness &")" 'puts this message in the status bar
Else
Code "G0 Z0" 'retract to start pos
Code "(Z-Plate not found, check connection or stroke - try again)" 'puts this message in the status bar
End If
Else
Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if aplicable
End If
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
Code "(Z Zero Routine Complete)"
Exit Sub