Hello Guest it is December 26, 2024, 09:17:38 AM

Author Topic: Tool Height Macro Problem Help  (Read 3854 times)

0 Members and 1 Guest are viewing this topic.

Tool Height Macro Problem Help
« on: November 15, 2007, 05:04:45 PM »
I want to change my tools and make the height control with this macro but When I run this macro my computer freezing.What is the problem with this code.I get this code from this forum



ChX = GetUserDRO(1200)
ChY = GetUserDRO(1201)
ChZ = GetUserDRO(1202)
Swposx = GetUserDRO(1203)
Swposy = GetUserDRO(1204)
SwError = GetUserDro(1205)
CurrentFeed = GetOemDRO(818)

If GetOemLed (23) Then DoOemButton (119) 'Turn soft limits off

Code "G20" 'Set to inch units

Code "G53 G00 Z" &ChZ 'Move the tool all the way up
While IsMoving()
Wend
ZOld = Getdro(2)

Code "G53 G00 X" &Swposx & "Y" &Swposy 'Move to the switch position
While IsMoving()
Wend

MsgBox ("Jog Z axis down close to switch then hit Cycle Start to resume")
SystemWaitFor (Start) 'Pause macro to jog the Z axis close to the switch

Code "G31 Z-7 F10" 'Move Z down until switch is triggered
While IsMoving()
Wend
Code "G4 P0.1"
HitOld = GetVar(2002) 'Get the position where the switch was triggered
Code "G53 G00 Z" &ChZ 'Z move all way up
Code "G53 G00 X" &ChX & "Y" &ChY 'Move to change tool position
While IsMoving()
Wend

MsgBox ("Insert the new tool")

Code "G53 G00 X" &Swposx & "Y" &Swposy 'Move to the switch position
While IsMoving()
Wend

MsgBox ("Jog Z axis down close to switch then hit Cycle Start to resume")
SystemWaitFor (Start) 'Pause macro to jog the Z axis close to the switch

Code "G31 Z-7 F10" 'Z move down until switch is triggered
While IsMoving()
Wend
Code "G4 P0.1"
HitNew = GetVar(2002) 'Get the position where the switch was triggered
Code "F" &CurrentFeed

Diff = HitOld - HitNew
DiffABS =Abs(Diff)

If DiffABS=0 Then
Code "G53 G00 Z" &ChZ
Code "G53 X0Y0"
While Ismoving()
Wend
DoOemButton (119) 'Turn soft limits on
Code "(New tool is now ready for use)"
Exit Sub
End If

ZNew=0

If HitOld < HitNew Then ZNew = ZOld - DiffABS :A=1
If HitOld > HitNew Then ZNew = ZOld + DiffABS :A=2

Code "G53 G00 Z" &ChZ
While IsMoving()
Wend
Call setdro(2,ZNew - SwError)
Code "G53 X0Y0"
While Ismoving()
Wend
DoOemButton (119) 'Turn soft limits on
Code "(New tool is now ready for use)"
End   

Offline jimpinder

*
  •  1,232 1,232
  • Wakefield, West Yorks, UK
Re: Tool Height Macro Problem Help
« Reply #1 on: November 21, 2007, 12:02:53 PM »
Run the Macro into an edit page and try stepping through the macro line by line.

Either it will not run at all - in which case it should tell you which line of code is faulty, or it will run line by line until it comes to the faulty line.

Try that - if it will not work I will download it to my machine and see if it will run on this.
Not me driving the engine - I'm better looking.
Re: Tool Height Macro Problem Help
« Reply #2 on: November 22, 2007, 08:15:41 AM »
I tried step mode and find that in this line comturer working so hard and slow then it freezes
The line is

"  Code "G31 Z-7 F10" 'Move Z down until switch is triggered  "