584,805 active members*
5,350 visitors online*
Register for free
Login
Results 1 to 16 of 16
  1. #1
    Join Date
    Nov 2013
    Posts
    45

    G code line jump?

    Hello,

    Is there a G code supported that will allow a line jump? An M99 P12 will jump to line 12 for example on a Fanuc and some others . I have also seen GOTO used in the G code.

    Thanks.

  2. #2
    Join Date
    Nov 2005
    Posts
    655

    Re: G code line jump?

    There's a block delete/block skip function.......... By putting a symbol(/) in front of the line to be skipped and turning on the block delete button.
    Block Delete button activated = skip lines with / in front of it

    Is that what you're looking for?
    Walking is highly over-rated

  3. #3
    Join Date
    May 2006
    Posts
    4043

    Re: G code line jump?

    Hi Epiphany,

    KMotionCNC supports Jumps to Subroutines which is similar to a Jump if you simply never return.

    M98 Pxxx

    can be used to Jump to the GCode Line with the Label:

    Oxxx

    The Jump can be conditional as well by specifying a Subroutine Loop Count of either 0 or 1. See the included example

    SubroutineWithConditionals.ngc

    Code:
    G20
    #100 = 5
    
    (examples of logical operations)
    (result is 1 if condition is true)
    (result is 0 if condition is false)
    
    #101 = [#100 >  5]
    #102 = [#100 >= 5]
    #103 = [#100 <  5]
    #104 = [#100 <= 5]
    #105 = [#100 =  5]
    #106 = [#100 <> 5]
    
    (subroutine call can be looped a number of times)
    (the L or Q word may be used to specify the count)
    (if neither L or Q is specified a count of 1 is used)
    (if the count is 0 the subroutine will not be called at all)
    
    M98 P1 L3  (example using L to specify the loop count)
    M98 P1 Q3  (example using Q to specify the loop count)
    
    M98 P1 L#100  (example using a variable loop count)
    
    M98 P1 L[5 > 4]  (example using a conditional as a loop count)
    M2
    
    O1
    #200 = [#200+1]
    M99
    HTH
    Regards
    TK
    http://dynomotion.com

  4. #4
    Join Date
    Nov 2013
    Posts
    45

    Re: G code line jump?

    Thanks for the replys,

    I am writing a tool setting routine and just attempting to simplify the code.

    Here is what I have now.


    Code:
    (***Tool Setting Macro with Manual Tool Change***)
    
    #100=1
    #101=1
    M98 P1 L[#101=1]
    M98 P1 L[#101=1]
    M98 P1 L[#101=1]
    M98 P1 L[#101=1] (This will need to be repeated about 20 times)
    G10L2P9X0Y0Z0
    #100=0
    #101=0
    (MSG,Tool Setting Complete)
    M2
    
    O1
    (Change Tool)
    M6 T#100
    (Set Fixture Offset)
    G59.3
    (Set Height Offset & Save XY Offset to G59.3)
    M101
    (Go Home)
    G00 G53 G90 Z0.
    G00 G53 G90 X0. Y0.
    (Send Message and pause)
    (MSG,Change to next Tool!)
    (Pause)
    M00 (Uncheck "Block Delete" To End)
    /#101=0
    /M99
    G00 G59.3 G90 X0. Y0.
    #100=[#100 + 1]
    M00 (Move Z to desired Offset Height)
    M99
    Repeating the M98 P1 L[#101=1] gets the job done I was just looking for another way.

    I have done this before.
    Code:
    (***Tool Setting Macro with Manual Tool Change***)
    
    N1 #100=1
    N2 (Change Tool)
    N3 M6 T#100
    N4 (Set Fixture Offset)
    N5 G59.3
    N6 (Set Height Offset & Save XY Offset to G59.3)
    N7 M101
    N8 (Go Home)
    N9 G00 G53 G90 Z0.
    N10 G00 G53 G90 X0. Y0.
    N11 (Send Message and pause)
    N12 (MSG,Change to next Tool!)
    N13 (Pause)
    N14 M00 (Uncheck "Block Delete" To End)
    N15 /M99 P20
    N16 G00 G59.3 G90 X0. Y0.
    N17 #100=[#100 + 1]
    N18 M00 (Move Z to desired Offset Height)
    N19 M99 P3
    N20 G10L2P9X0Y0Z0
    N21 #100=0
    N22 (MSG,Tool Setting Complete)
    N23 M2
    This would allow for "infinite" tools to be set.

    Cheers.

  5. #5
    Join Date
    Nov 2013
    Posts
    45

    Re: G code line jump?

    Need help with the setting of the tool table.

    Here is the sequence.

    The X & Y & Z are jogged to a position.
    Press cycle start, the M101 will execute and do 2 things.
    1. Update the Length of the currently selected tool to the current machine coords.
    2. Update the X & Y coords of the G59.3 to the current X & Y machine coords.

    Here is the problem

    Attachment 237780

    Tool table at start

    Attachment 237782

    After first tool

    Attachment 237784

    After second tool. This is overwriting the pocket and ID of tool 1.

    Here is the C program.

    Code:
    #include "KMotionDef.h"
    
    #define TMP 10 // which spare persist to use to transfer data
    #include "KflopToKMotionCNCFunctions.c"
    
    #define Zaxis 2
    
    main()
    {
    	int FixtureIndex,Units, TWORD, HWORD, DWORD;
    	double NewToolLength,OriginOffsetZ,AxisOffsetZ,NewX,NewY,NewZ;
    	double Machinex,Machiney,Machinez,Machinea,Machineb,Machinec;
    
    	GetMiscSettings(&Units, &TWORD, &HWORD, &DWORD);
    
    	GetFixtureIndex(&FixtureIndex);
    
    	GetOriginOffset(&OriginOffsetZ, FixtureIndex, Zaxis);
    
    	GetAxisOffset(&AxisOffsetZ, Zaxis);
    	
    	GetMachine(&Machinex,&Machiney,&Machinez,&Machinea,&Machineb,&Machinec);
    
    	// Compute Tool Offset to make DRO zero when Tool Length selected and enabled
    	//
    	// Since Machine = DRO + OriginOffset + AxisOffset + ToolOffset
    	//
    	// Set DRO = 0 and solve for ToolOffset
    	//
    	
        
        printf("X is %d & Y is %d Z is %d\n",Machinex,Machiney,Machinez); 
      
    	// Change Currently Selected Tool Length
    	
    		
        NewToolLength = Machinez - OriginOffsetZ - AxisOffsetZ;
    
    	// Change Currently Selected Tool Length
    	SetToolLength(TWORD,NewToolLength);	
    	
    		
    	// Change Fixture Offset X
    	NewX= Machinex;
    
    	pD[TMP]=NewX;
    	SetVars(5201+FixtureIndex*20+0, 1, TMP);
    
    	DoPC(PC_COMM_UPDATE_FIXTURE);
    	
    	// Change Fixture Offset Y
    	NewY = Machiney;
    
    	pD[TMP]=NewY;
    	SetVars(5201+FixtureIndex*20+1, 1, TMP);
    
    	DoPC(PC_COMM_UPDATE_FIXTURE);
    	
    	
    }
    Using version 431s currently.

    Thanks.

  6. #6
    Join Date
    May 2006
    Posts
    4043

    Re: G code line jump?

    Hi Epiphany,

    Still a bit clumsy but here is a way to eliminate your list of repeated conditional subroutine calls by using a looped surbroutine:

    Code:
    #100=1
    #101=1
    M98 P2 L100 (Do up to 100 tools)
    G10L2P9X0Y0Z0
    #100=0
    #101=0
    (MSG,Tool Setting Complete)
    M2
    
    O2 (Sub to conditionally call another sub)
    M98 P1 L[#101=1]
    M99
    
    O1
    (Change Tool)
    M6 T#100
    (Set Fixture Offset)
    G59.3
    (Set Height Offset & Save XY Offset to G59.3)
    M101
    (Go Home)
    G00 G53 G90 Z0.
    G00 G53 G90 X0. Y0.
    (Send Message and pause)
    (MSG,Change to next Tool!)
    (Pause)
    M00 (Uncheck "Block Delete" To End)
    /#101=0
    /M99
    G00 G59.3 G90 X0. Y0.
    #100=[#100 + 1]
    M00 (Move Z to desired Offset Height)
    M99
    Regarding Tool Table Problem. Please use latest Version 4.33b with the new Tool Table Format I believe that has been fixed

    See the Thread on our Yahoo Group regarding this:
    https://groups.yahoo.com/neo/groups/.../messages/9522

    HTH
    Regards
    TK
    http://dynomotion.com

  7. #7
    Join Date
    Oct 2011
    Posts
    17

    Re: G code line jump?

    Sorry Guys, I am sure to be on the wrong thread, but is there any string of Gcode that I can use that after leaving XY Zero, I can traverse to new co-ordinace ( X199 Y45 anywhere) STOP and RESET to ZERO at that point Thanks for any suggestions

  8. #8
    Join Date
    May 2006
    Posts
    4043

    Re: G code line jump?

    Hi Aarwhy,

    One way would be to use G92

    G0 X199 Y45 (Traverse somewhere)
    G92 X0 Y0 (Set current position to zero)

    See here for more info.

    Regards
    TK
    http://dynomotion.com

  9. #9
    Join Date
    Oct 2011
    Posts
    17

    Re: G code line jump?

    Thanks Tom, I must be doing something wrong, that unfortunately does not work. Cheers Rod

  10. #10
    Join Date
    May 2006
    Posts
    4043

    Re: G code line jump?

    Hi Rod,

    Are you looking at Machine Coordinates or Work Coordinates? What type of system/software do you have? What are you doing exactly? What happens?

    Regards
    TK
    http://dynomotion.com

  11. #11
    Join Date
    Oct 2011
    Posts
    17

    Re: G code line jump?

    Thanks. What I have in mind is a generic G, or Mcode Leader/Starter script I could include ahead of any program code.
    That would use/maintain/keep my MACHINE HOME X0 Y0. coordinates, intact.

    Then, Traverse to an entered Work location ie: X156 Y23 (create an artificial X0Y0 or whatever) but Start/Run the program from that (fake Zero) point,
    Yet, still able to maintain the integrity of original MACHINE HOME X0 Y0. coordinates, able to return to my original MACHINE HOME X0 Y0.

    Bottom line, if I create a tool-path in Aspire, it will start at Zero, be that, at a corner, or center of the program.
    I just want the ability to set the program start coordinates.
    Tell it to go to anywhere on the table I want, and start running the program as if that is Zero from there.
    I don't want to manually shift to that point, and reset Zero at that point , thus screwing all my machine coordinates
    Sorry, I hope you are not totally bewildered. But If so, I understand, I KNOW what I mean
    Here's Hoping! Cheers Rod

  12. #12
    Join Date
    Nov 2013
    Posts
    45

    Re: G code line jump?

    Aarwhy,

    It sounds like you are refering to the work offsets already in the program. G54 thru G59.3 will do exactly what you are saying. A G53 will return you to machine coordinates. If you check the "Zero using fixture offsets" box in the Trajectory Planner the zero button next to the axis will apply the current X or Y position to the active offset. If you wanted to do this through a c program via M code or push button there are examples in the c program folder.

    SetFixtureX.c

    Code:
    #include "KMotionDef.h"
    
    #define TMP 10 // which spare persist to use to transfer data
    #include "KflopToKMotionCNCFunctions.c"
    
    #define Xaxis 0
    
    main()
    {
    	int FixtureIndex;
    	double NewOriginOffset,OriginOffsetX,AxisOffsetX;
    	double Machinex,Machiney,Machinez,Machinea,Machineb,Machinec;
    
    	GetFixtureIndex(&FixtureIndex);
    
    	GetOriginOffset(&OriginOffsetX, FixtureIndex, Xaxis);
    
    	GetAxisOffset(&AxisOffsetX, Xaxis);
    	
    	GetMachine(&Machinex,&Machiney,&Machinez,&Machinea,&Machineb,&Machinec);
    
    	// Compute Origin Offset to make DRO zero
    	//
    	// Since Machine = DRO + OriginOffset + AxisOffset
    	//
    	// Set DRO = 0 and solve for OriginOffset
    	//
    	NewOriginOffset = Machinex -  AxisOffsetX;
    
    	pD[TMP]=NewOriginOffset;
    	SetVars(5201+FixtureIndex*20+0, 1, TMP);
    
    	DoPC(PC_COMM_UPDATE_FIXTURE);
    }
    This will set the X value of the active fixture offset to the "Machine X - X Axis Offset" . There are also files for the Y.

    Hope that helps,

    Cheers :cheers:

  13. #13
    Join Date
    May 2006
    Posts
    4043

    Re: G code line jump?

    Hi Rod,

    I can't imagine why G92X0Y0 doesn't do what you describe. This is one of the most common things to do in GCode. Jog out to the center of your part, enter G92X0Y0, and the DROs should display 0,0, You didn't answer my questions regarding what type of system you have, what steps you did, and what happened.

    The G54...etc... Fixture Offsets that Epiphany describes is an alternate way of doing what you describe. Neither method will change your Machine Coordinates.

    Regards
    TK
    http://dynomotion.com

  14. #14
    Join Date
    Dec 2014
    Posts
    78

    Re: G code line jump?

    So lets say you broke a tool in the middle of the part and now I want to continue machining from some specified line. How do you do this with KMotionCNC?

  15. #15
    Join Date
    May 2006
    Posts
    4043

    Re: G code line jump?

    Hi Rod,

    Its very complex in general to start executing GCode in the middle of a program. KMotionCNC has a capability to "Set Next Statement" that can be selected by right-clicking on a line of GCode. In most straightforward cases KMotionCNC should be able to reverse scan from that point and determine the appropriate modes. Then on Cycle Start it will request to do a safe Z move to a previous position, activate spindle, plunge in Z, set the feedrate, and resume.

    We have recently found two bugs related to this and have a patch for V4.33. See below to add the patch.


    Fix Trajectory Planner/Segment Buffer Bug when first segment requires multi-pass look-ahead optimization and can not be optimized on first optimization pass resulting in no motion until segment buffer wraparound and consequently large quantity of lost motion and large discontinuity. Basically when no rapid and complex trajectory path at the very beginning of motion. Likely to occur when using "Set Next Statement" into an area of short segments.


    We did find another bug where in some sequences the preparation dialog and motion wouldn't occur and the GCode would resume in G0 instead of G1.

    Please download the new GCodeInterpreter.dll and a new KMotionCNC.exe

    http://dynomotion.com/Software/Patch...nterpreter.dll
    http://dynomotion.com/Software/Patch...KMotionCNC.exe


    Regards
    TK
    TK
    http://dynomotion.com

  16. #16
    Join Date
    Dec 2014
    Posts
    78

    Re: G code line jump?

    Quote Originally Posted by TomKerekes View Post
    KMotionCNC has a capability to "Set Next Statement" that can be selected by right-clicking on a line of GCode.
    Just what I was looking for. Thanks!

Similar Threads

  1. Replies: 3
    Last Post: 04-08-2011, 01:48 AM
  2. It stops after every line of code
    By Farmers Machine in forum CamSoft Products
    Replies: 3
    Last Post: 11-15-2009, 09:41 PM
  3. How to get rid of line numbers in NC code
    By mcoughlin in forum CamWorks
    Replies: 1
    Last Post: 04-17-2007, 04:30 AM
  4. Seeing what line of code the machine is at?
    By greasetattoo in forum CNC (Mill / Lathe) Control Software (NC)
    Replies: 6
    Last Post: 03-04-2007, 08:47 PM
  5. G-Code Line Numbers?
    By Imagineering in forum G-Code Programing
    Replies: 3
    Last Post: 08-17-2005, 01:26 PM

Posting Permissions

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