Page 1 of 2 12 LastLast
Results 1 to 12 of 20

Thread: What am I missing?

  1. #1
    Registered
    Join Date
    Mar 2010
    Location
    USA
    Posts
    12
    Downloads
    0
    Uploads
    0

    What am I missing?

    I am working on a macro to drill holes. My problem (with this macro) is that it drills holes twice when it moves in a different axis. The code is below.

    I would appreciate any advice I can get on solving this problem.

    Thanks in advance,

    James

    %
    O9517(PERF AND GROOVE CALL)
    (V1.00.000)

    (TRANSLATE)
    #106=#105 (Y GROOVE SPACING)
    #101=#105 (HOLE X START)
    #102=#105 (HOLE Y START)
    #1=[#105*4] (PERF SPACING X)
    #2=[#106*3] (PERF SPACING Y)

    (ERROR)
    IF [#124 GT 120] GOTO 300 (TOO LARGE X)
    IF [#125 GT 60] GOTO 300 (TOO LARGE Y)
    IF [#126 GT 5] GOTO 300 (TOO LARGE Z)
    IF [#124 LT .75] GOTO 301 (TOO SMALL X)
    IF [#125 LT .75] GOTO 301 (TOO SMALL Y)
    IF [#126 LT .125] GOTO 301 (TOO SMALL Y)
    GOTO 31

    N300#3000=3 (MATL TOO LARGE)
    N301#3000=17 (MATL TOO SMALL)

    (MATERIAL TYPE)
    N31IF [#103 EQ 999] GOTO 53 (BROKEN DRILL)
    N32IF [#103 LT 2] GOTO 150
    N33#3000=1 (ERROR)

    (N31IF [#123 EQ 10] GOTO (A500 FOAM)(FOR FUTURE USE)
    (N32IF [#123 EQ 20] GOTO (20# HD FOAM)
    (N33IF [#123 EQ 30] GOTO (30# HD FOAM)
    (N40IF [#123 LT 10] GOTO 42)
    (N41IF [#123 GT 20] GOTO 42)
    (N42#3000=16 (MATERIAL NOT RECOGNIZED)


    (BROKEN DRILL)
    N53#3006=1(RECOVER FROM BROKEN TOOL?)
    (N54#1=[#105*3] (PERF SPACING X)
    (N55#2=[#105*4] (PERF SPACING Y)(CAN THIS BE CHANGED?????????TO SCALE)
    (N56#107=600. (GROOVE FEED)
    (N57#109=16000 (GROOVE SPEED)
    (N58#108=150. (DRILL FEED)
    (N59#111=3600 (DRILL SPEED)
    N60#101=#500 (STORED X POSITION)
    N61#102=#501 (STORED Y POSITION)
    N62GOTO 150

    N150IF [#103 EQ 0] GOTO 31

    (2MM_DRILL.)
    G28G91Z0M05
    G90T2009M06
    T102
    G90G0G17G55X[#101]Y[#102]M03S3600
    #500=#101
    #501=#102
    G0G43H9Z[#126+.25]

    N1WHILE [#101 LT [#124-#1]] DO 1 (X POSITION LESS THAN MATERIAL SIZE)

    N2WHILE [#102 LE [#125-#2]] DO 2 (Y POSITION LESS THAN MATERIAL SIZE)
    G1Z0.F150.
    Z[#126+.25]F3150.
    #102=[#102+#2]
    IF[#102 GE [#125-#2]]GOTO 2
    #501=#102
    Y[#102]
    END 2 (END ASCENDING Y HOLES)

    IF [#101 GE [#124-#1]] GOTO 1
    #101=[#101+#1]
    G1X[#101]F3150.
    #500=#101

    N3WHILE [#102 GE #2] DO 3 (Y POSITION GREATER THAN Y START)
    IF[#102 LE #2]GOTO 3
    G1Z0.F150.
    Z[#126+.25]F3150.
    #102=[#102-#2]
    IF[#102 LE #2]GOTO 3
    #501=#102
    Y[#102]
    END 3 (END DESCENDING Y HOLES)

    IF [#101 GE [#124-#1]] GOTO 1
    #101=[#101+#1]
    G1X[#101]F3150.
    #500=#101
    N100END 1

    N500G28G91Z0M5
    N505G90

    N1250M99
    %


  2. #2
    Registered
    Join Date
    Feb 2006
    Location
    india
    Posts
    1,273
    Downloads
    0
    Uploads
    0
    Post your drawing and indicate where the problem is.
    Are you sure that this program is otherwise OK?


  3. #3
    Registered
    Join Date
    Mar 2010
    Location
    USA
    Posts
    12
    Downloads
    0
    Uploads
    0

    RE: What am I missing?

    Sinha,

    There is no drawing. The program is designed to drill a "Grid" of holes with variable spacing based on grooves in the nmaterial to be drilled. The program works as I intend as far as the math is concerned. The issue is in the code here:
    N2WHILE [#102 LE [#125-#2]] DO 2 (Y POSITION LESS THAN MATERIAL SIZE)
    G1Z0.F150.
    Z[#126+.25]F3150. (it drills the first hole in the Y axis series twice then moves on drilling each hole once and incrementing as i expect.)
    #102=[#102+#2]
    IF[#102 GE [#125-#2]]GOTO 2
    #501=#102
    Y[#102]
    END 2 (END ASCENDING Y HOLES)

    IF [#101 GE [#124-#1]] GOTO 1
    #101=[#101+#1]
    G1X[#101]F3150.
    #500=#101
    (when the code reaches this point and moves in the Y Axis, it drills the first hole in the row twice.)


  4. #4
    Registered
    Join Date
    Feb 2009
    Location
    Engerland
    Posts
    22
    Downloads
    0
    Uploads
    0
    I think you need to tell us what #155,#124,#125#126 ect are set to 1st.
    They are not being written at the start of thev program


  • #5
    Registered
    Join Date
    May 2007
    Location
    USA
    Posts
    939
    Downloads
    0
    Uploads
    0
    Programming relatively simple parts on lathes, I don't nest WHILE statements. I looked up the format. Your program doesn't meet the format. This is for a Fanuc lathe control. Are you running a Fanuc? Do Fanuc mills have a different format than lathes? Normally I'd say "No".

    Format is

    WHILE[....]DO1
    WHILE[....]DO2
    WHILE[....]DO3
    END3
    END2
    END1

    Could this be part of the problem?

    I think Jay meant #105 instead of #155. I personally don't need to know those values to understand the program (somewhat ) However #103 has me confused. Seems to me it has to equal 1 or the program will run in a continuous loop.

    Looks to me like the only way the program will read blocks N60 thru N63 is if #103 is between 3-998 and you push RESET & CYCLE START a couple times to get past the block N33 and N53 alarm messages. In less, of course, you manually call block N60 up from the control.

    I also have a question on the use of IF statements within the WHILE statement, but will study the program a bit more first. Maybe I can avoid showing my ignorance.


  • #6
    Registered
    Join Date
    Feb 2009
    Location
    Engerland
    Posts
    22
    Downloads
    0
    Uploads
    0
    Hi g-codeguy / cnc monkey

    It could be me (or the glass of red wine i have had) but i can not make headway through this part of the program to see why it doubles drills the 1st hole without needing to know the value of some #variables ie #102, #105

    N2WHILE [#102 LE [#125-#2]] DO 2 (Y POSITION LESS THAN MATERIAL SIZE)
    G1Z0.F150.
    Z[#126+.25]F3150.
    #102=[#102+#2]
    IF[#102 GE [#125-#2]]GOTO 2
    #501=#102
    Y[#102]
    END 2 (END ASCENDING Y HOLES)

    I willm have another look tomorrow, with a clearer head.


  • #7
    Registered
    Join Date
    May 2007
    Location
    USA
    Posts
    939
    Downloads
    0
    Uploads
    0
    Well, Jay, I don't drink so I can't use that as an excuse!


    Would this work? My 1st attempt at nesting WHILE statements, so please be gentle with me.

    WHILE[#101LT[#124+#2]]DO1

    WHILE[#102LE[#125-#2]]DO2
    G1Z0F150.
    Z[#126+.25]F3150.
    #102=#102+#2
    #500=#102
    Y#102
    END2

    #101=#101+#1
    #500=#101
    X#101

    WHILE[#102GE#2]DO3
    Z0F150.
    Z[#126+.25]F3150.
    #102=#102-#2
    #501=#102
    Y#102
    END3

    #101=#101+#1
    #500=#101
    X#101
    END1

    Can I use the excuse that it is late, and I'm pretty tired. Working 2 jobs keeps me that way.

    EDIT: Actually I would move the G1 to a block in front of the 1st WHILE statement. That way it would always be active no matter where the program started should it be interrupted before finishing the part. I'm always looking for the least amount of typing on my part
    Last edited by g-codeguy; 06-06-2011 at 06:00 AM.


  • #8
    Registered
    Join Date
    May 2007
    Location
    USA
    Posts
    939
    Downloads
    0
    Uploads
    0
    If I'm thinking correctly, the addition of another variable is necessary. Naturally I don't know if this would work since I've never nested WHILE statements.

    G1
    WHILE[#101LT[#124+#2]]DO1
    IF[#502EQ2]GOTO2
    IF[#502EQ3]GOTO3

    N2WHILE[#102LE[#125-#2]]DO2
    #502=2
    Z0F150.
    Z[#126+.25]F3150.
    #102=#102+#2
    #500=#102
    Y#102
    END2

    #101=#101+#1
    #500=#101
    X#101

    N3WHILE[#102GE#2]DO3
    #502=3
    Z0F150.
    Z[#126+.25]F3150.
    #102=#102-#2
    #501=#102
    Y#102
    END3

    #101=#101+#1
    #500=#101
    X#101
    END1


  • #9
    Registered
    Join Date
    Mar 2010
    Location
    USA
    Posts
    12
    Downloads
    0
    Uploads
    0

    RE: What am I missing?

    Thanks for all of the help so far. To fill in some of the gaps I left...

    We are using a FANUC 210i control.

    The goal of this program is to drill holes in a grid pattern. First it incrments the X material size (DO1), then it increments the Y material size and starts driling in Y positive (DO2) when it hits the end in Y positive it increments X and drills Y negative (DO3), Since there is still X material remeing to be drilled, it steps off an increment in X and starts (DO2) and (DO3) again.

    Here are the missing variables:

    %
    :1234(CALL MACRO)
    G00G17G20G40G64G80G90
    G0G28G91Z0M5
    G49G90
    G52X0Y0Z0
    G08P1

    (MATERIAL SIZE X)#124=40. (120.00 LIMIT)
    (MATERIAL SIZE Y)#125=20. (60.00 LIMIT)
    (MATERIAL SIZE Z)#126=2.0 (6.00 LIMIT)

    (MATERIAL TYPE)#123=10 (CURRENTLY DISSABLED)
    (MATERIAL TYPE: A500=10, 20LB.HD FOAM=20, 30LB.HD FOAM=30)

    (DRILL ON)#103=1 (DRILLS ON=1, DRILLS OFF=0, BROKEN TOOL RESUME PROGRAM=999)
    (GROOVE ON)#104=1 (GROOVE ON=1, GROOVE OFF=0)

    (SPACING)#105=1. (DISTANCE BETWEEN CENTER OF GROOVES)
    (ASSUMES EQUAL DISTANCE X AND Y)


    N10G65P9517 (MACRO CALL)




    N118G90G52X0Y0Z0
    N119G08P0
    N120G00G28G91Z0M05
    N121G28G91X0
    N122 G90
    N123M30
    %


  • #10
    Registered
    Join Date
    May 2007
    Location
    USA
    Posts
    939
    Downloads
    0
    Uploads
    0
    cnc, how much trouble would it be to test (in air) my sample? I added #502 variable so you could start in the middle of the job, and it would still move in the right direction for the next hole.

    I'm interested in knowing if it'll work, but have no place to test it out. Yes, we have mills, but they are always behind schedule even if I could talk the foreman into trying this program.


  • #11
    Registered
    Join Date
    Mar 2010
    Location
    USA
    Posts
    12
    Downloads
    0
    Uploads
    0

    RE: What am I missing.

    g-code,

    I ran the test.

    The code only moves in X, it doesn't drill or move in Y.

    James


  • #12
    Registered
    Join Date
    Mar 2010
    Location
    USA
    Posts
    12
    Downloads
    0
    Uploads
    0

    RE: What am I missing?

    The problem seems to be in the IF statement. If I remove it, I get an extra hole in the Y axis because of the command Y[#102]. (That's why I added it to the fisrt place...) Can anyone think of a way to check to see if incrementing the counter pushes me over the material boundaries? (#102=[#102+#2])

    Thanks in advance.

    James


    N2WHILE [#102 LE [#125-#2]] DO 2 (Y POSITION LESS THAN MATERIAL SIZE)
    G1Z0.F150.
    Z[#126+.25]F3150.
    #102=[#102+#2]
    IF[#102 GE [#125-#2]]GOTO 2
    #501=#102
    Y[#102]
    N20END 2 (END ASCENDING Y HOLES)


  • Page 1 of 2 12 LastLast

    Similar Threads

    1. Need Help!- all missing
      By istotel in forum Fanuc
      Replies: 2
      Last Post: 01-21-2010, 04:17 AM
    2. Need Help!- X3: Missing V in my VFD
      By imprez55 in forum Benchtop Machines
      Replies: 0
      Last Post: 01-02-2010, 09:02 PM
    3. Newbie- SX3 Missing
      By BlueFin in forum Syil Products
      Replies: 2
      Last Post: 04-14-2008, 02:05 PM
    4. Missing .DLL???
      By CyborgCNC in forum Surfcam
      Replies: 6
      Last Post: 05-25-2007, 01:41 PM
    5. Am i missing anything here?
      By phantomcow2 in forum General Electronics Discussion
      Replies: 7
      Last Post: 08-11-2005, 11:36 PM

    Posting Permissions


     


    About CNCzone.com

      We are the largest and most active discussion forum from DIY CNC Machines to the Cad/Cam software to run them. The site is 100% free to join and use, so join today!

    Follow us on

    Facebook Dribbble RSS Feed


    Search Engine Friendly URLs by vBSEO ©2011, Crawlability, Inc.