Machsupport Forum

G-Code, CAD, and CAM => G-Code, CAD, and CAM discussions => Topic started by: Keith on January 12, 2007, 02:41:16 PM

Title: Subroutines
Post by: Keith on January 12, 2007, 02:41:16 PM
I know this subject has been discussed before but my application of what I've read isn't bearing fruit for me and if someone could just give me an example,I think I could clear things up for myself.
Okay,let's just say I am at x0y0z0. To simplify ,let's use just the x-axis. Say we want to move the x-axis +1",then back to zero 5 times. What would the gcode/subroutine commands look like?
Ultimately I would like to include an A-axis move during the X move (I am winding a coil on the cnc) but if I could get the X to do what I'd like,I think I could figure the rest out.
Also,what is the qualification I've been reading about Mach3's relationships between P and O and L and Q ,about?Thanks,Keith
Title: Re: Subroutines
Post by: Graham Waterworth on January 12, 2007, 03:02:57 PM
O0001 (MAIN PROGRAM)
G00 X0 Y0 Z0
M98 P2 L5
M30

O0002 (SUB PROGRAM)
G01 X1. A??? F10.
X0 A???
M99

Try this

Graham.
Title: Re: Subroutines
Post by: Keith on January 12, 2007, 03:33:04 PM
Thank you Graham. I see my confusion.-Keith
Title: Re: Subroutines
Post by: Keith on January 12, 2007, 03:41:05 PM
Hmm,wrote that out and it just goes through one iteration(in reality just doing the sub program once;goes to 1 and then back to zero and stops)-Keith
Title: Re: Subroutines
Post by: Graham Waterworth on January 12, 2007, 03:42:44 PM
Have you got a blank line after the M99, you should have one.

Graham.
Title: Re: Subroutines
Post by: Keith on January 12, 2007, 03:56:00 PM
The old 'return' after the last line,gets me one more time. Thanks,that works.-Keith