Hello Guest it is October 16, 2019, 09:05:34 AM

Author Topic: Marco gone wild.  (Read 4296 times)

0 Members and 1 Guest are viewing this topic.

Marco gone wild.
« on: July 05, 2011, 06:10:20 PM »
Been struggling all weekend  trying to figure this out.

If I go to the offset menu and click the ref all home the Z,X,Y,A home with no problems.

If I click the button on my home page to run the macro below I get random behavior.  Mostly the Z rapids down but once in a while the Z will rapid up and then about half the macro will run.

If I open the macro using the edit button script command and run the macro line by line it runs flawlessly.

This system has been running with no issues for a few years.  It all started with a dumbass move on my part that crashed the system. The only difference is that I added the DoOEMButton command to the macro.

I also tried reinstalling Mach.

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
PlateThickness = GetUserDRO(1151) 'Z-plate thickness DRO
Code "G54"
Code "G90"

DoButton( 24 )

DoOEMButton 1010

DoButton( 23 )
DoButton( 22 )
DoButton( 25 )

Code "G90 G0 Z-2.75"

While ismoving()
Wend

Code "G90 G31 Z-4 F4" 'probing move, can set the feed rate here as well as how far to move

While ismoving()
Wend

ZProbePos = GetVar(2002) 'get the axact point the probe was hit

While ismoving()
Sleep 100
Wend

Code "G90 G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun

While ismoving()
Sleep 100
Wend

Zoffset = getvar(5223)
Cline = (ZProbePos+-3.2395) '-3.2395 Distance between center line of rotary and probe

SetVar(5243,(Cline+PlateThickness))'Set G55 Z
While ismoving()
Wend
SetVar(5263,(Cline+PlateThickness))'Set G56 Z
While ismoving()
Wend
SetVar(5283,(Cline+PlateThickness))'Set G57 Z
While ismoving()
Wend

Code "G91"
Code "G0 Z 0.1" 'retract

While ismoving()
Sleep 100
Wend

Code "G55"
Code "G90"
While ismoving()
Sleep 100
Wend
Code "G0 X0 Y0"   'move to start position
While ismoving()
Sleep 100
Wend

Code "(Z axis is now zeroed for G55, G56, G57)" 'puts this message in the status bar

Exit Sub                                                                                              

Offline ger21

*
  • *
  •  6,288 6,288
    • View Profile
    • The CNC Woodworker
Re: Marco gone wild.
« Reply #1 on: July 05, 2011, 06:33:32 PM »
Try This:


Sub Main()
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
PlateThickness = GetUserDRO(1151) 'Z-plate thickness DRO
Code "G54"
Code "G90"

DoButton( 24 )

DoOEMButton 1010
Sleep (250)

DoButton( 23 )
DoButton( 22 )
DoButton( 25 )

Code "G90 G0 Z-2.75"

While ismoving()
Wend

Code "G90 G31 Z-4 F4" 'probing move, can set the feed rate here as well as how far to move

While ismoving()
Wend

ZProbePos = GetVar(2002) 'get the exact point the probe was hit

Sleep(150)

Code "G90 G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun

While ismoving()
Wend

Zoffset = getvar(5223)
Cline = (ZProbePos-3.2395) '-3.2395 Distance between center line of rotary and probe

SetVar(5243,(Cline+PlateThickness))'Set G55 Z
SetVar(5263,(Cline+PlateThickness))'Set G56 Z
SetVar(5283,(Cline+PlateThickness))'Set G57 Z


Code "G91"
Code "G0 Z0.1" 'retract

While ismoving()
Wend

Code "G55"
Code "G90"
Code "G0 X0 Y0"   'move to start position
While ismoving()
Wend

Message "Z axis is now zeroed for G55, G56, G57" 'puts this message in the status bar

End Sub 
Gerry

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

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Marco gone wild.
« Reply #2 on: July 05, 2011, 07:24:24 PM »
It homes now but does not Zero the Z axis.  Also takes off in the Z and X at Code "G90 G0 Z-2.75"
Re: Marco gone wild.
« Reply #3 on: July 05, 2011, 08:17:03 PM »
Got it to work!  Thanks for the help!  I moved the DoOEMButton and added a ismoving.  It would not take the Sub Main statement.

w00t!

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
PlateThickness = GetUserDRO(1151) 'Z-plate thickness DRO
Code "G54"
Code "G90"

DoButton( 24 )
DoButton( 23 )
DoButton( 22 )
DoButton( 25 )
While ismoving ()
Wend

DoOEMButton(1010)
While ismoving ()
Wend

Code "G90 G0 Z-2.75"

While ismoving()
Wend

Code "G90 G31 Z-4 F4" 'probing move, can set the feed rate here as well as how far to move

While ismoving()
Wend

ZProbePos = GetVar(2002) 'get the axact point the probe was hit

While ismoving()
Sleep 100
Wend

Code "G90 G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun

While ismoving()
Sleep 100
Wend

Zoffset = getvar(5223)
Cline = (ZProbePos+-3.2395) '-3.2395 Distance between center line of rotary and probe

SetVar(5243,(Cline+PlateThickness))'Set G55 Z
While ismoving()
Wend
SetVar(5263,(Cline+PlateThickness))'Set G56 Z
While ismoving()
Wend
SetVar(5283,(Cline+PlateThickness))'Set G57 Z
While ismoving()
Wend

Code "G91"
Code "G0 Z 0.1" 'retract

While ismoving()
Sleep 100
Wend

Code "G55"
Code "G90"
While ismoving()
Sleep 100
Wend
Code "G0 X0 Y0"   'move to start position
While ismoving()
Sleep 100
Wend

Code "(Z axis is now zeroed for G55, G56, G57)" 'puts this message in the status bar

Exit Sub                                                                                                   

Offline ger21

*
  • *
  •  6,288 6,288
    • View Profile
    • The CNC Woodworker
Re: Macro gone wild.
« Reply #4 on: July 05, 2011, 08:20:11 PM »
DoOemButton 1010 should be
DoOemButton(1010)

I missed that.

When a macro messes up, sometimes it's a good idea to close Mach3 and reboot the PC, as macros may not run correctly again until you do this.



How about this?

Sub Main()
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
PlateThickness = GetUserDRO(1151) 'Z-plate thickness DRO
ProbeDepth = (GetOEMDro(802) - 4 ) ' Probe move to current Z - 4
Code "G54"
Code "G90"

DoButton( 24 )

DoOEMButton (1010)
Sleep (250)

DoButton( 23 )
DoButton( 22 )
DoButton( 25 )

Code "G0 Z-2.75"

While IsMoving()
Wend

Code "G90 G31 Z" & ProbeDepth & " F4" 'probing move, can set the feed rate here

While IsMoving()
Wend

ZProbePos = GetVar(2002) 'get the exact point the probe was hit

Sleep(150)

Code "G90 G0 Z" & ZProbePos 'go back to that point, always a very small amount of overrun
While IsMoving()
Wend

Zoffset = getvar(5223)
Cline = (ZProbePos-3.2395) '-3.2395 Distance between center line of rotary and probe

SetVar(5243,(Cline+PlateThickness))'Set G55 Z
SetVar(5263,(Cline+PlateThickness))'Set G56 Z
SetVar(5283,(Cline+PlateThickness))'Set G57 Z


Code "G91"
Code "G0 Z0.1" 'retract

While IsMoving()
Wend

Code "G55"
Code "G90"
Code "G0 X0 Y0"   'move to start position
While ismoving()
Wend

Message "Z axis is now zeroed for G55, G56, G57" 'puts this message in the status bar

End Sub  
Gerry

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

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Marco gone wild.
« Reply #5 on: July 05, 2011, 09:54:46 PM »
Very true on the restart.  Thanks again for your help.

Dan
Re: Marco gone wild.
« Reply #6 on: July 06, 2011, 06:36:08 AM »

When a macro messes up, sometimes it's a good idea to close Mach3 and reboot the PC, as macros may not run correctly again until you do this.
 

Are you sure about this? I've done a fair amount of programming in Mach3 and haven't observed this, and I have had scripts screw up (over, and over, and over, especially on the Egg Shape Wizard!). I always hit cycle stop a few times and reset twice and everything seems fine again.... What have your observations been?

I'm actually really curious because you have a lot of experience, certainly more than me!

Offline ger21

*
  • *
  •  6,288 6,288
    • View Profile
    • The CNC Woodworker
Re: Marco gone wild.
« Reply #7 on: July 06, 2011, 07:06:31 AM »
I probably should have worded that differently.
I've seen issues when having to estop during a macro, where the machine would no longer home correctly afterwards, just crashing through the home switches, and the macro would no longer run afterwards, until re-booting the PC.
I'm sure this isn't the case all the time. What I'm saying, is that if Mach3 doesn't appear to be acting correctly, then close it and re-booting should clear it up.
Gerry

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

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Marco gone wild.
« Reply #8 on: July 06, 2011, 08:33:10 PM »
Thanks for the clarification Ger.

Have a great day/night!

Chris
« Last Edit: July 06, 2011, 08:34:59 PM by Sargon »