Hello Guest it is March 28, 2024, 10:35:19 PM

Author Topic: Trouble getting out of a conditional loop  (Read 2792 times)

0 Members and 1 Guest are viewing this topic.

Offline Fleck

*
  •  31 31
    • View Profile
    • fleckguitar.com
Trouble getting out of a conditional loop
« 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"      
« Last Edit: June 23, 2014, 04:06:25 PM by Fleck »
this is my router, there are many like it but this one is mine

Offline Fleck

*
  •  31 31
    • View Profile
    • fleckguitar.com
Re: Trouble getting out of a conditional loop
« Reply #1 on: June 27, 2014, 04:51:53 PM »
 this seems to work well.

N2:
'*****
Degrees = Degreesperloop
Degreesperloop = (360 / Degreesperloop)
Dim Countdown
Dim i,j

For i = 1 To  Degreesperloop


Degreeincrement = Degrees + Degreeincrement 'get degree input
Code "G01 A" & Degreeincrement & "F500"

For j = 1 To Cutnumber
IStock = Cutdepth-IStock
IStock = IStock * -1
Call SetUserDRO(1232,IStock)
IStock = GetUserDRO(1232)
While IsMoving ()
Wend

YEndcorrect = IStock - Partoff
Code "G01 Y" & Leadin &"F" & CutEngageFeed 'Tool Entry
Code "Y0" & "Z" & IStock 
Code "G01 Y" & Blanklength & "Z" & YEndcorrect &"F" & Roughfeed'Tool Pass
Code "G0 Y" & LeadIn & "Z" & GetUserDRO(1232) + Retract'Tool Retract
 


While IsMoving ()
Wend


Next j

IStock = (Stock-Finishdiameter)+Finishpass

While IsMoving ()
Wend


Next i

While IsMoving ()
Wend
this is my router, there are many like it but this one is mine