Loading ...
Sorry, an error occurred while loading the content.

M97/M98 jump vs call .. was M60

Expand Messages
  • Doug Fortune
    ... Yes, each M98 (call subroutine) must be paired with an M99 (return from call subroutine) ... eventually ... in a proper program. Although, you can call
    Message 1 of 13 , Apr 1, 2006
    • 0 Attachment
      EZ wrote:
      >I entered 50. and after about 10 times thru the loop the machine
      >stopped and said something about Stack limit, or something like
      >that. Anyone know what that may be?

      Yes, each M98 (call subroutine) must be paired with an M99 (return
      from call subroutine) ... eventually ... in a proper program.

      Although, you can call subroutines from subroutines (this is called
      subroutine nesting), including a subroutine calling itself, which
      implies several M98 call gcodes occur before the corresponding M99's

      However, that limit is 10 or 20 in the current compilation.

      What you want to use is the M97 jump instruction, a counter and
      a test condition to terminate it. Here I count down to zero,
      but you could count up instead if you wanted...


      ;N100 ASK #1 ; loop how many times?
      N100 #1=50 ; or set it this way

      N110 M98 O1000 ; call the subroutine
      N120 #1=[#1 - 1] ; decrement counter
      N130 IF #1 GT 0 M97 O110 ; if not zero, loop again

      N150 G01 X+1.0 Y+1.0 F20 ; continue with program

      N999 M02 ; all done


      ; a subroutine
      N1000 SAY #1 ; Loop Counter
      N1010 G01 X+1.0 F20
      N1020 G01 X-1.0
      N1999 M99 ; return from subroutine


      cheerz
      Doug Fortune

























































      .
    • jjmefoam
      Thanks, I will give that a try. EZ ... M99 s
      Message 2 of 13 , Apr 1, 2006
      • 0 Attachment
        Thanks, I will give that a try.

        EZ


        --- In turbocnc@yahoogroups.com, Doug Fortune <pentam@...> wrote:
        >
        >
        > EZ wrote:
        > >I entered 50. and after about 10 times thru the loop the machine
        > >stopped and said something about Stack limit, or something like
        > >that. Anyone know what that may be?
        >
        > Yes, each M98 (call subroutine) must be paired with an M99 (return
        > from call subroutine) ... eventually ... in a proper program.
        >
        > Although, you can call subroutines from subroutines (this is called
        > subroutine nesting), including a subroutine calling itself, which
        > implies several M98 call gcodes occur before the corresponding
        M99's
        >
        > However, that limit is 10 or 20 in the current compilation.
        >
        > What you want to use is the M97 jump instruction, a counter and
        > a test condition to terminate it. Here I count down to zero,
        > but you could count up instead if you wanted...
        >
        >
        > ;N100 ASK #1 ; loop how many times?
        > N100 #1=50 ; or set it this way
        >
        > N110 M98 O1000 ; call the subroutine
        > N120 #1=[#1 - 1] ; decrement counter
        > N130 IF #1 GT 0 M97 O110 ; if not zero, loop again
        >
        > N150 G01 X+1.0 Y+1.0 F20 ; continue with program
        >
        > N999 M02 ; all done
        >
        >
        > ; a subroutine
        > N1000 SAY #1 ; Loop Counter
        > N1010 G01 X+1.0 F20
        > N1020 G01 X-1.0
        > N1999 M99 ; return from subroutine
        >
        >
        > cheerz
        > Doug Fortune
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        > .
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.