587,591 active members*
4,232 visitors online*
Register for free
Login

Thread: Do loop

Results 1 to 6 of 6
  1. #1
    Join Date
    May 2013
    Posts
    261

    Do loop

    Does Kmotion Gcode controller have a "do loop" option with a counter ? I looked at the EMC user manual but did not see anything like it .

    I would like to perform a simple move in X and Y and have it stop after a hundred moves.

    Or is there an easier way of doing this .

  2. #2
    Join Date
    May 2006
    Posts
    4051

    Re: Do loop

    Hi Gregore,

    You can call a subroutine N times. Such as:


    G20 G0 X0 Y0 Z0
    M98 P10 L100(Call the Subroutine 100 times)
    M2 (Stop)

    O10 (Subroutine Label of 10)
    F40
    G1 X1 Y0
    G1 X1 Y1
    G1 X0 Y1
    G1 X0 Y0
    M99

    HTH
    Regards
    TK
    http://dynomotion.com

  3. #3
    Join Date
    May 2013
    Posts
    261

    Re: Do loop

    Thank you Tom , I think that should work perfectly for me

    What function does the M2 call do before the O10 sub routine

  4. #4
    Join Date
    May 2013
    Posts
    261

    Re: Do loop

    Never mind , I think I under stand . The first part up to m2 is the main program the second part is the seperate sub routine .

    Is that correct ?

    I assume that the m99 command will move the machine back to the start position X0 Y0 Z0

  5. #5
    Join Date
    May 2006
    Posts
    4051

    Re: Do loop

    Hi Gregore,

    I think I under stand . The first part up to m2 is the main program the second part is the seperate sub routine .

    Is that correct ?
    Yes the M2 is there to stop the Main Program after it is finished.

    I assume that the m99 command will move the machine back to the start position X0 Y0 Z0
    No. That is the return from subroutine. The code has already moved back to X0 Y0 Z0 by the end of the subroutine in the example. You might Single Step through the code for a better understanding of how a subroutine works.

    HTH
    Regards
    TK
    http://dynomotion.com

  6. #6
    Join Date
    May 2013
    Posts
    261

    Re: Do loop

    The single stepping is a good idea , that should give me a really clear idea of each lines function.

Similar Threads

  1. Closing the loop with Path Pilot. Possibly dual (global) closed loop?
    By SwampDonkey in forum Tormach Personal CNC Mill
    Replies: 29
    Last Post: 05-04-2016, 09:39 PM
  2. Open Loop to Closed Loop Stepper Conversion
    By beamhome in forum Stepper Motors / Drives
    Replies: 11
    Last Post: 03-09-2014, 11:27 PM
  3. CNC conversion typically open loop or closed loop?
    By foobar42 in forum Benchtop Machines
    Replies: 8
    Last Post: 10-30-2009, 01:21 AM
  4. question on closed loop vs open loop (servo systems)
    By boonie in forum Servo Motors / Drives
    Replies: 20
    Last Post: 11-09-2007, 07:30 PM
  5. Lathe conversion - open loop vs closed loop
    By bhowden in forum Uncategorised MetalWorking Machines
    Replies: 7
    Last Post: 03-21-2006, 10:56 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •