Ian,

Example of while loop to make circular indents in the side of a handwheel/

DAMPER> cat 110_mill_grips.ngc
%
(mill grips on other side, 3/8mill=9.5mm, 12 deep)
(params)
#1=-15  (drill depth)
#2=10   (retraction interval)
#100=-12        (depth)
(fixed)
(speed)
F80
(reset)
G0 Z5
G0 X0 Y0
G4 P5
(start round)
#8=0    (angle in degrees)
#9=30   (angle increment in degrees)
O101 while [#8 lt 360]
#5=32.30        (first step and start)
#6=31.00        (second step)
#7=35           (safe circle)
(first step)
G0 Z1
G0 X[#5 * cos[#8]] Y[#5 * sin[#8]]
G1 Z[#100 + 0.06]
G1 X[#7 * cos[#8]] Y[#7 * sin[#8]]
(second step)
G0 Z1
G0 X[#6 * cos[#8]] Y[#6 * sin[#8]]
G1 Z#100
G1 X[#7 * cos[#8]] Y[#7 * sin[#8]]
(increment angle)
#8=[#8 + #9]
(wait)
(M0)
O101 endwhile
(end)
G0 Z5
G0 X1 Y-1
G1 X0 Y0
G0 Z20
%

another example using IF:

(simple turning)
(#100 = max Z = start Z > #101)
(#101 = min Z)
(#200 = max X = start X > #201)
(#201 = min X)
(#300 = feed)
(#400 = stepsize)
(Z)
#100 = 200
#101 = 0
(X)
#200 = 17
#201 = 14
(FEED)
#300 = 120
(STEP)
#400 = 1
(END OF PARAMETERS)
(set feed)
F#300
(set current X)
#250 = #200
O501 while [#250 gt #201]
#250 = [#250 - #400]
O502 if [#250 lt #201]
#250 = [#201]
O502 endif
(goto start point, safety x 1mm)
G0 X[#250 + #400 + 1]
G0 Z#100
G0 X#250
G1 F#300 Z#101
O501 endwhile
(retract to orig X)
(END)
G0 X[#200 + 1]



Ian W. Wright wrote:
> Hi,
> 
> Could someone please give me a little tutorial on using do/while loops 
> in g-code please or, at least, point to me to a tutorial on the web 
> while I have obviously missed in several hours of trawling the 'net. I'm 
> trying to write a simple gearcutting program where I can mount the blank 
> on a rotary axis and traverse the cutter back and forth on the X-axis a 
> given number of times. I'm wanting to make the script 'universal' so 
> that I can just insert numbers into variables for number of teeth, 
> length of X travel, depth of each cut, and total cut depth but I seem to 
> be getting my brain in a twist trying to figure out how to write the 
> loops. I know that, if I was bright, I should be able to figure this out 
> easily and maybe even write an interactive GUI but, today at least, I'm 
> not and I need to get this part made ASAP!! ( a house full of 
> grandchildren doesn't help either :-(  )
> 
> Thanks,
> Ian
> ----------------------
> Ian W. Wright
> Sheffield  UK
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Emc-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/emc-users
> 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to