![]() | |
| Home Page | Mark Forums Read | Today's Posts | My Replies | Classifieds | Reviews | Photo Gallery | Web Links | Share Files | Advertise With Us | Ad List |
| |||||||
| G-Code Programing Discuss G-code programing and problems here! |
| This forum is sponsored by: |
![]() |
| | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
| |||
| |||
Hi all, I've been trying to write a macro so that I can easily drill holes in the diameter of shafts. The macro works but there is a problem in the 'while... Do' loop WHILE[#24LT#101]DO1 N1G01X[#103-#5]F#9 N2#101=#5041 load current x machine pos into #101 N3#103=#5041 load current x machine pos into #103 N4G00X#102 rapid clear of shaft dia N5X[#103+1.0] rapid to last feed posn + 1mm END1 Unless I put eob between the lines in the loop the program executes N2 before N1 has fed to posn. How should I properly stop the program from executing commands before previous command have finished. In the actual program there are no N numbers. I just put them here for clarity. cheers Andy |
|
#3
| |||
| |||
| Tried your program. First peck worked, but after making the rapid move to X#102 it continued to X4.738 before stopping at which point I stopped the machine. Obviously I wasn't picking up the current X-position with #5041. Looked in the Fanuc manual for 16-18 controls. Changed #5041 to #5001. Your program runs fine. I can only assume you have some way already set in the program so that the drill won't feed smaller than #24. EDIT: BTW, thanks for the idea. I love to learn new things. Don't know yet where I can use it, but who knows, maybe one day it will come in handy. Thanks. |
|
#5
| |||
| |||
| I should have posted the whole program. Here it is. A G65 macro call is made from the main program after tool selection, spindle speed, etc has been set and the drill has been moved to the start position of the hole. I did this because my control appears not to have G83 and I was spending ages writing the code line by line every time I had a different hole to drill. It's may have some critical bug so I test in fresh air every time before use, but it's already saved me a stack of time and broken drills from hand programing errors. Wish I knew more. :0001( main prog) start spindle etc GOO X22.0 Z-24.0 (RAPID TO START POSITION FOR DRILLED HOLE) M98 (FEED PER MIN) G65P9004 X-22.0 I3.0 J4.0 E25 F50 (X= #24, FINAL DRILL POSITION IN X) (I= #4, FIRST PECK DEPTH, slow feed into workpiece) (J= #5, SUBSEQUENT PECK DEPTHS) (E= #8 FIRST PECK FEED) (F= #9 SUBSEQUENT PECK FEED ) :9004 #102=#5041 (LOAD MACHINE POSN INTO #102 G98 G01X[#102-#4]F#8 (FEED TO FIRST PECK ) #103=#5041 (LOAD MACHINE POSN TO #103) WHILE[#24LT#101]DO1 (DO LOOP WHILE #24 IS LESS THAN #101) ; G01X[#103-#5]F#9 FEED TO CURRENT POSN - PECK DEPTH) ; #101=#5041 (LOAD MACHINE POSN TO #101) ; #103=#5041 (LOAD MACHINE POSN TO #103) ; G00X#102 (RAPID BACK TO START OF CYCLE) ; X[#103+1.0] (RAPID BACK TO LAST DRILL POSN + 1MM) ; END1 X#102 #101=#5041 M99 M30 |
| Sponsored Links |
|
#6
| ||||
| ||||
|
|
#7
| |||
| |||
|
Beege, I thought of that and you may be right. Most of the lathes we have use an M-code for exact stop on/off. I leave it on. His program runs fine on a Daewoo with 18T control. Course I had to make up my own little section to test it with as Andy didn't give all the code needed to run it. |
|
#8
| |||
| |||
| Andy. I am going to look at your latest program example in depth tomorrow. I have one question at the moment. What tells the control to stop drilling at X-22.? If I am following it correctly, it should drill to X-25. not the X-22. in the program. Ok for a thru hole (other than time wasted), but not what you want in other situations. I'm pretty tired, so maybe I am missing something simple. |
|
#9
| |||
| |||
| Hi G-Code. You are right, it does drill too far. It's my first attempt so not had time to tweak it. I guess I need to check the drill pos in a different place. it just drills into fresh air for my requirement, but i'd prefer it to be right of course and I was more worried about it reading the x position before the feed block had finished. Cheers Andy |
|
#11
| |||
| |||
After the last peck it also rapids to X[#103+1.] and then back to X#102. Following is a program that eliminates both problems. Only difference is that 'J' becomes the maximum peck depth. Control figures the correct peck depth to finish at X-22. as shown in your example. Once there it rapids back to X#102 and you go on from there. :0133 #102=#5041 (FIGURE PECK DOC) #21=20 (LEAVE AT 20) 20 would be a number larger than you would ever peck at #22=1 (LEAVE AT 1) WHILE[#21GT#5]DO1 #21=[[#102-#4-#24]/#22] #22=[#22+1] END1 G1G98X[#102-#4]F#8 #103=#5041 WHILE[#24LT#101]DO2 G1X[#103-#21]F#9 #101=#5041 IF[#101EQ#24]GOTO9 #103=#101 G0X#102 X[#103+1.] N9END2 G0X#102 #101=#5041 M99 :122 Tool, spindle speed, etc. X22.Z-15. G65P133X-22.I3.J4.E25F50 ... ... M30 % I am relatively new at this myself. I am sure others could come up with a more elegant solution. However this does work. I tested it before the others came in for work. EDIT: I layed out the program this way so that when I loaded it into the control program O122 would be the one showing on the screen. EDIT2: Oops, forgot to change #5001 back to #5041 for you. And back to X[#103+1.] I had to run in fractions. Last edited by g-codeguy; 03-24-2009 at 08:30 AM. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| macro - motion pauses each loop | kendo | Haas Mills | 2 | 12-18-2008 05:17 AM |
| question on closed loop vs open loop (servo systems) | boonie | Servo Motors and Drives | 20 | 11-09-2007 12:30 PM |
| Loop in Mach 3 Question?? Help please | luther | Mach Software (ArtSoft software) | 0 | 10-06-2007 11:21 PM |
| Loop in Mach 3 Question?? Help please... M47, M99 | jimmychand | Mach Software (ArtSoft software) | 3 | 09-10-2007 08:06 AM |
| Macro WHILE DO END Loop (Lathe) | Jorge-D-Fuentes | G-Code Programing | 18 | 07-25-2007 08:57 AM |