. .

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #8
    Here the same G-code for the Squares but using parametric G-code.

    Notice how it's much cleaner code and even thou theres twice has many squares there's less lines of code.
    This is made possible by the fact the subroutine is called 4 times with the (L) parameter and the use of a variable we define has #1 at the top which we then use at the end of the SUB (G91 x#1) to offset the next square on the X axis. We actually didn't need the variable and could just used a G91 150 incremental move but you'll see why we did below.

    Now here's the beauty of Parametric g-code. If you look carefully you'll see that the first row is offset in X direction by 10mm but the proceeding rows are not.?
    This is because at line n50 we moved x10 but when we return from the sub and reposition to start of next row with line n70 it used the value in #2 variable which is 0. So each time we return from the proceeding subs we return to X0 and it repeats.
    We don't want this and if this was normal code it would say X0 on every line it now says X#2 and we'd have to edit every line. Using variables we don't need to and can just edit #2 variable and hey presto every line gets changed. .

    Now going back to the Sub you should see why we used the variable.? . . .Yep by just changing the #1 variable we can instantly change the offset for all squares.
    Also by just repeating 2 lines (m98 p1000 L4) & ( g0 x#2 ) we can add 4 more squares in another row.!
    Attached Files Attached Files
    Last edited by JAZZCNC; 24-01-2013 at 10:40 AM.

  2. The Following 2 Users Say Thank You to JAZZCNC For This Useful Post:


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Anyone got some 2.5D G-code please ?
    By dudz in forum Programmers Corner
    Replies: 5
    Last Post: 22-06-2013, 11:21 PM
  2. Cambium Code Web Tools – Parametric G-code Generation
    By CambiumMachines in forum Manufacturer News
    Replies: 0
    Last Post: 09-01-2013, 04:56 AM
  3. Mach3 Using a physical button to repeat current gcode
    By RLKS Rob in forum Artsoft Mach (3 & 4)
    Replies: 2
    Last Post: 12-08-2012, 01:30 PM
  4. Use a tile cutter as a hobby table saw?!!!
    By HankMcSpank in forum General Discussion
    Replies: 10
    Last Post: 21-07-2009, 06:56 PM
  5. G Code help
    By moose007 in forum Programmers Corner
    Replies: 4
    Last Post: 22-05-2009, 11:39 AM

Bookmarks

Posting Permissions

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