Can someone help me write my first program?


Results 1 to 3 of 3

Thread: Can someone help me write my first program?

  1. #1

    Join Date
    Nov 2020
    Posts
    0
    Downloads
    0
    Uploads
    0

    Default Can someone help me write my first program?

    Sorry if this is wrong place to ask this. Im am new here.

    Ive been studying gcode for a while and im about to write my first program. What I need to do is mill a half inch slot in 4 seperate places. The material is quarter inch thick. I was thinking .010 to .020 deep per pass. What I need help with is condensing the code. Is there a way to condense each pass for milling the slot or do I have to write out each pass? Also how do I condense the code for the other three slots? Since its the same pattern can I use a subprogram or subroutine to make the code shorter? How would I do this? Thanks

    Similar Threads:


  2. #2
    Community Moderator Jim Dawson's Avatar
    Join Date
    Dec 2013
    Posts
    5717
    Downloads
    0
    Uploads
    0

    Default Re: Can someone help me write my first program?

    Yes, you can use nested loops See L and G91 codes. (Loop and Incremental positioning) One loop for the slot start positions, and then run the inside loop to actually cut the slot. Or use G90 to position the slot starts and then use G91 to actually cut the slot using the loop

    Jim Dawson
    Sandy, Oregon, USA


  3. #3
    Member lucaswalker's Avatar
    Join Date
    Sep 2018
    Posts
    27
    Downloads
    0
    Uploads
    0

    Default Re: Can someone help me write my first program?

    Quote Originally Posted by Jmac2595 View Post
    Sorry if this is wrong place to ask this. Im am new here.

    Ive been studying gcode for a while and im about to write my first program. What I need to do is mill a half inch slot in 4 seperate places. The material is quarter inch thick. I was thinking .010 to .020 deep per pass. What I need help with is condensing the code. Is there a way to condense each pass for milling the slot or do I have to write out each pass? Also how do I condense the code for the other three slots? Since its the same pattern can I use a subprogram or subroutine to make the code shorter? How would I do this? Thanks
    You can Write the commands with correct incremental positions in a sub and then call it where you need, it goes like that :

    G0 X50 Y50 Z0.5 (PREPOSITIONING 1)
    M98 P1234 (CALL SLOT SUBPGM)
    G0 X100 Y50 Z0.5 (PREPOSITIONING 2)
    M98 P1234 (CALL SLOT SUBPGM)
    G0 X150 Y50 Z0.5 (PREPOSITIONING 3)
    M98 P1234 (CALL SLOT SUBPGM)

    O1234 (START SUB)
    G91 (INCREMENTAL)
    G1 Z-0.2 (GO TO FIRST PASS DEPTH)
    Y20 (TRAVERSE)
    Z-0.2 (GO TO SECOND PASS DEPTH)
    Y-20 (TRAVERSE)
    Z-0.1 (GO TO FINISH PASS DEPTH)
    Y20 (TRAVERSE)
    G90 (ABSOLUTE)
    G0 Z0.5 (GO TO RETRACTION)
    M99 (END SUB)

    More complex but more flexible, you can write a macro and call it where you need with the correct inputs parameters, goes like this in B-macro :

    G65 P1234 A-0.5 B6 I50 J50 X100 Y50 (CALL MACRO POSITION 1)
    G65 P1234 A-0.5 B6 I50 J50 X120 Y60 (CALL MACRO POSITION 2)
    G65 P1234 A-0.5 B6 I50 J50 X140 Y70 (CALL MACRO POSITION 3)

    O1234 (START MACRO)
    (#1 A PASS DEPTH)
    (#2 B NB OF PASS)
    (#4 I X TRAVERSE)
    (#5 J Y TRAVERSE)
    (#6 K Z APPROACH)
    (#24 X POS X)
    (#25 Y POS Y)

    G0 X#24 Y#25 Z#6 (PREPOSITIONING)
    G91 (INCREMENTAL)
    #10=1 (-1 OR 1 FOR GO AND BACK PASS)
    #11=#1-#6 (NEXT INCREMENTAL Z POSITION)
    #12=1 (COUNTER FOR NUMBER OF PASS)
    WHILE [#12 LE #2] DO1 (LOOP ON COUNTER)
    G1 Z#11 (GO TO PASS DEPTH)
    X[#10*#4] Y[#10*#5] (TRAVERSE)
    #10=-1*#10
    #11=#1
    #12=#12+1
    END1 (END LOOP)
    G90 (ABSOLUTE)
    G0 Z#6 (RETARCTION)
    M99 (END MACRO)



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
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

Can someone help me write my first program?

Can someone help me write my first program?