4
« on: June 23, 2014, 04:02:59 PM »
I am trying to write a boxing loop for Lathe type tool passes with a router to a A axis spindle. I am used to a different scripter and would have used a While, Do, End While.
I am reading the material and trying to figure this out with no real programming experience so I am sure its a mess. The Macro is either blowing through the code or infinite looping .
Any info is appreciated.
Also wondering, is declaring a As Double the same as declaring a Real number?
Dim Blanklength, Finishdiameter, Stock
Dim Roughfeed, Finishfeed
Dim Cutdepth
Dim Cutnumber
Dim XProgramlo,YProgramlo,ZProgramlo,AProgramlo
Dim XAbsolo, YAbsolo, ZAbsolo, AAbsolo
Dim Finishpass
Dim Retract
Dim IStock
Dim IFinishdiameter
Blanklength = GetUserDRO(1226)*-.1'get blank length input
Stock = GetUserDRO(1227)/2'get stock input
Finishdiameter = GetUserDRO(1229)/2'get blank diameter input
Roughfeed = GetUserDRO(818)'get Roughfeed length input
Finishfeed = GetUserDRO(818/2)'Get Finishfeed length Input
Cutnumber = GetUserDRO(1228)'get full cut depth
XProgramlo = GetDRO(83)'Current G54 X location
YProgramlo = GetDRO(84)'Current G54 Y location
ZProgramlo = GetDRO(85)'Current G54 Z location
AProgramlo = GetDRO(86)'Current G54 A location
XAbsolo = GetDRO(0)'Current G53 X location
YAbsolo = GetDRO(1)'Current G53 Y location
ZAbsolo = GetDRO(2)'Current G53 Z location
AAbsolo = GetDRO(3)'Current G53 A location
Cutdepth = SetUserDRO(1225,(Stock-Finishdiameter)/Cutnumber)
Finishpass = GetUserDRO(1230)'get finish pass depth
Retract = GetUserDRO(1231)'get retract distance
Cutdepth = GetUserDRO(1225)
IStock = SetUserDRO(1232,(Stock-Finishdiameter))
N1:
Code "G90"
Code "M03"
While IsMoving ()
Wend
Code "G0 Y" & YProgramlo '& "X" & XProgramlo'Rapid to Program X and Y zero
Code "G0 Z" & Stock +.01'Rapid to tenth inch above rough stock
Code "G52 Z" & Finishdiameter'Zero offset
While IsMoving ()
Wend
N2:
Do While IStock >= (0)
'*****
Code "G01Z" & Cutdepth & Roughfeed'Tool Entry
Code "G01Y" & Blanklength'Tool Pass
Code "G0Z" & Retract'Tool Retract
Code "G0 Y0"
IStock = GetUserDRO(1232)
IStock = SetUserDRO(1232,(IStock*1)-Cutdepth)
Loop
'*****
N3:
Code"G53 Z0"
Code "G52 Z0"
Code "M05"
Code "M30"