Hello Guest it is December 05, 2021, 03:02:21 AM

Author Topic: Subroutines  (Read 3648 times)

0 Members and 1 Guest are viewing this topic.

Offline Keith

*
  • *
  •  187 187
    • View Profile
Subroutines
« 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

Offline Graham Waterworth

*
  • *
  •  2,422 2,422
  • Yorkshire Dales, England
    • View Profile
Re: Subroutines
« Reply #1 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.
Without engineers the world stops

Offline Keith

*
  • *
  •  187 187
    • View Profile
Re: Subroutines
« Reply #2 on: January 12, 2007, 03:33:04 PM »
Thank you Graham. I see my confusion.-Keith

Offline Keith

*
  • *
  •  187 187
    • View Profile
Re: Subroutines
« Reply #3 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

Offline Graham Waterworth

*
  • *
  •  2,422 2,422
  • Yorkshire Dales, England
    • View Profile
Re: Subroutines
« Reply #4 on: January 12, 2007, 03:42:44 PM »
Have you got a blank line after the M99, you should have one.

Graham.
Without engineers the world stops

Offline Keith

*
  • *
  •  187 187
    • View Profile
Re: Subroutines
« Reply #5 on: January 12, 2007, 03:56:00 PM »
The old 'return' after the last line,gets me one more time. Thanks,that works.-Keith