CNCzone.com-The Largest Machinist Community on the net!



Home Page Mark Forums Read Today's Posts My Replies Classifieds Reviews Photo Gallery Web Links Share Files Advertise With Us Ad List
Go Back   CNCzone.com-The Largest Machinist Community on the net! > Machine Controllers Software and Solutions > Fanuc


Fanuc Discuss Fanuc controllers here!


This forum is sponsored by:

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 10-27-2011, 03:13 PM
 
Join Date: Sep 2011
Location: USA
Posts: 71
MCImes is on a distinguished road
Question Help writing chip breaker custom macro

I thought that I had a copy of the chip breaker turn/dwell program from my old machine but I seem to have misplaced it. So anyone want to help me write one? or if you have one post it?

I want to turn/dwell/turn/dwell/turn...ect

I thought it looked something like this:

%9010

#1 =z end
#2 =turn distance/chip break
#3 =dwell
#4 =feed

IF [#2 LT0] goto2
IF [#3 LT0] goto3
IF [#4 LT0] goto4

while [#5041 LT #1] DO1
G1 W#2 f#4
G4 U#3
END1

N1 #3000=1 (No Z)
N2 #3000=2 (No Q)
N3 #3000=3 (No D)
N4 #3000=4 (No F)
%

My questions are
-How do I define my current Z position. If I remember the old program correctly I thought it was #1=#5401 but I could be wrong. I just looked in the Fanuc manual and think I need to use a #5041-5048 macro but can someone confirm this. Also how do I determine what axis number my X and Z are?

-I want to write the code in the program as G65 Z(end) Q(chip break) D(dwell) F(feed). How do I link Z,Q,D, and F to my sub program? Can I say #2=Q? Or do I use some parameter #'s like Q=#5403?

-In my WHILE statement should I use a Z or W for my feed move? Does it matter? Do I have it written correctly that the loop will end when it hits my end point or could it possibly over-turn by going to the end of the last chip break assuming the chip break distance is not divisible by the overall distance.

-How do I signify the end of the loop? m99?

I know thats kinda a lot so thanks a bunch in advance!
__________________
I program, setup and run Swiss lathes with Fanuc controls
Reply With Quote

  #2   Ban this user!
Old 10-27-2011, 09:20 PM
fordav11's Avatar  
Join Date: Aug 2011
Location: Fordaville
Posts: 939
fordav11 is on a distinguished road

Originally Posted by MCImes View Post
-I want to write the code in the program as G65 Z(end) Q(chip break) D(dwell) F(feed). How do I link Z,Q,D, and F to my sub program? Can I say #2=Q? Or do I use some parameter #'s like Q=#5403?
In the G65 line if you want to use D, F, Q & Z use this list below to reference them in your macro program. These are called Local Variables.
a simple example is if you want to use D in your G65 and you need to check it is greater than 0 you put this into your macro....
IF [#7 GT 0] GOTO 100
etc

A #1
B #2
C #3
D #7
E #8
F #9
H #11
I #4
J #5
K #6
M #13
Q #17
R #18
S #19
T #20
U #21
V #22
W #23
X #24
Y #25
Z #26

So that's one of your questions answered
Reply With Quote

  #3   Ban this user!
Old 10-29-2011, 07:21 AM
fordav11's Avatar  
Join Date: Aug 2011
Location: Fordaville
Posts: 939
fordav11 is on a distinguished road

I'm no macro expert but if you think about this it's not far off a G74 peck cycle on a lathe but instead of back-off at the peck depth it dwells instead.
There is a drill peck cycle macro in the Fanuc 16/18/21 series operator's manual (and probably other series manuals too) but using a totally different method.
Anyway, based on your method something like this should work....

Z end point = -10.00" (#26)
Peck Q = 0.200" (#17). must be positive value
Dwell D = 1 second (#7)
Feed F = 0.014" (#9)
Back-off in X at end of pass as incremental U value. sign important! U is positive for OD turning and minus for ID boring (#21)
#5042 = Z axis current pos (#5041 = X axis current pos)

G65 P9010 Z-10.0 Q0.200 D1.0 U0.04 F0.014

%
O9010
#1 = #5042 (remember start Z position)
WHILE [#5042 LT #26] DO (or maybe GT because #26 is a negative Z and current pos is also negative, but less negative if face = Z0)
IF [[#5042 - #26] LT #17] THEN #17 = #5042 - #26 (prevent over-run)
G1 W-#17 F#9 (peck W-0.200 at feed 0.014")
G4 U#7 (dwell 1 second)
END
N1 G1 U#21 (at end of pass move away incrementally)
G0 Z#1 (rapid back to initial start point)
%

The 'prevent over-run' line basically checks current position (which will be a minus Z value) and subtracts the end position (also a negative Z value). If that amount is less than the peck amount then the peck amount becomes the remainder between current position and end position.
For example if current pos = Z-9.9 then peck W = -9.9 minus -10.0 = 0.100"
At least in theory anyway

To use this as a custom G-code set parameter 6050 to the number of your custom G-code. 6050 corresponds to program 9010. 6051 to 9011. 6052 to 9012 etc.

You may need to fine tune this on the machine in case some of the logic is wrong, especially the 'prevent over-run' part

Last edited by fordav11; 10-29-2011 at 08:13 AM.
Reply With Quote

  #4   Ban this user!
Old 10-29-2011, 08:21 AM
 
Join Date: Sep 2010
Location: Australia
Posts: 733
angelw is on a distinguished road

Originally Posted by fordav11 View Post
Anyway, based on your method something like this should work....

Z end point = -10.00" (#26)
Peck Q = 0.200" (#17). must be positive value
Dwell D = 1 second (#7)
Feed F = 0.014" (#9)
Back-off in X at end of pass as incremental U value. sign important! U is positive for OD turning and minus for ID boring (#21)
#5042 = Z axis current pos (#5041 = X axis current pos)

G65 P9010 Z-10.0 Q0.200 D1.0 U0.04 F0.014

%
O9010
#1 = #5042 (remember start Z position)
WHILE [#5042 LT #26] DO (or maybe GT because #26 is a negative Z and current pos is also negative, but less negative if face = Z0)
G1 W-#17 F#9 (peck W-0.200 at feed 0.014")

G4 U#7 (dwell 1 second)
END
G1 U#21 (at end of pass move away incrementally)
G0 Z#1 (rapid back to initial start point)
%

To use this as a custom G-code set parameter 6050 to the number of your custom G-code. 6050 corresponds to program 9010. 6051 to 9011. 6052 to 9012 etc.
I understand that yours is just an example, but the logic in red could result in an over cut in Z of up to 0.001 less than the amount of the peck value.

Something like the following in Blue would fix this. This example is based on end of workpiece being Z Zero.
%
O9010
#1 = #5042 (remember start Z position)
WHILE [#5042 GT #26] DO1
#2=ABS[#26-#5042]
IF[#2LT#17]TH#17=#2

G1 W-#17 F#9 (peck W-0.200 or W-#2 value at feed 0.014")
G4 U#7 (dwell 0.1 second)
END1
G1 U#21 (at end of pass move away incrementally)
G0 Z#1 (rapid back to initial start point)
%

Regards,

Bill
Reply With Quote

  #5   Ban this user!
Old 10-29-2011, 09:52 AM
 
Join Date: Mar 2005
Location: united states
Posts: 14
geach73 is on a distinguished road
Drilling macro

O9010 (DRILL MACRO)
#100=#7(SET VARIABLE #100 EQUAL TO
D – PECK AMOUNT)
#101=ABS [#26] (SET VARIABLE #101 EQUAL TO Z - HOLE DEPTH)
#102=#6 (SET VARIABLE #102 EQUAL TO K – DRILL RETURN OFFSET)
#103=#18 (SET VARIABLE #103 EQUAL TO R – RETRACT LOCATION)
#104=#100 (TEMPORARILY SET VARIABLE #104 EQUAL TO PECK AMOUNT)
#105=#9 (SET VARIABLE #105 EQUAL TO F, FEED RATE)
WHILE [#104LT#101] DO1 (LOOP WHILE TEMP Z-VALUE IS LESS THAN FINISH DEPTH)
G1 Z-#104 F#105 (FEED TO PECK DEPTH = VALUE OF #104)
G0 Z#103 (CLEAR CHIP - RAPID TO RETRACT LOCATION)
Z- [#104-#102] (RAPID RETURN TO LAST LOCATION LESS K VALUE)
#104=#104+#100 (SET TEMP Z EQUAL TO TEMP Z PLUS PECK VALUE)
END1 (END LOOP)
G1 Z-#101 (DRILL TO FINISH DEPTH)
G0 Z#103 (RAPID OUT TO RETRACT LOCATION)
M99 (RETURN TO MAIN PROGRAM)

This closely resembles the subprogram call illustrated earlier, except that now the subroutine is called up with a G65 instead of an M98. Calling subprograms with a G65 allows you to "pass" variables to the subprogram. Variables make it easy to alter a program as cutting conditions require by simply changing the value of D, R, K, etc. It also makes it easy to use these macros for other jobs, as you can simply change a few values in the G65 macro call instead of rewriting the entire drilling routine.

A cleaner way to use this program would be to assign it a G code, like this:

O0001 (MAIN PROGRAM)
N4 G97 M3 S1000 T404
G0 X4. Z1.
G183 Z-1.5 D.35 R.07 F.012 K.02
G28 U0 W0
M30

This makes the macro program appear to be just like any other canned cycle in your machine. If you want to assign a G code to your macro programs, you will need to open the parameter manual for your control and find the specific parameter that maps the program number (usually a 9000-series program) to the G code.

In fact, as you may have already realized, there are few differences between a macro program and a canned cycle. But while canned cycles are fixed, macro programs give you the freedom to accomplish any programming task you desire. And that usually is a big plus when conducting drilling operations on a CNC lathe.
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 10-29-2011, 10:33 AM
fordav11's Avatar  
Join Date: Aug 2011
Location: Fordaville
Posts: 939
fordav11 is on a distinguished road

Originally Posted by angelw View Post
Something like the following in Blue would fix this. This example is based on end of workpiece being Z Zero.
I took care of the over-run around 8 minutes before you posted.....
Anyway, I find it very interesting that you waited 2 days to answer this after I took the time to read up in the manual and provided a possible solution. Hmmmm interesting
Reply With Quote

  #7   Ban this user!
Old 10-29-2011, 05:30 PM
 
Join Date: Sep 2010
Location: Australia
Posts: 733
angelw is on a distinguished road

Originally Posted by fordav11 View Post
I took care of the over-run around 8 minutes before you posted.....
Anyway, I find it very interesting that you waited 2 days to answer this after I took the time to read up in the manual and provided a possible solution. Hmmmm interesting
What's you point regarding how long it took to respond to this thread? Not that I'm obliged to answer to you or anyone as to when I reply to a thread, but I do so when I have time and I contribute to more than this thread and this forum. I had already contributed substantially to MCImes's other thread dealing with Custom G Codes. The fact that Forum members take the time to make a contribution should be seen as a bonus in my opinion, and is the basis on which a Forum operates. I and many members of this and other Forums operate on a "Play it Forward" philosophy; each making a beneficial contribution.

I hadn't noticed that you'd edited your post whilst I was typing.
Regards,

Bill

Last edited by angelw; 10-29-2011 at 06:55 PM.
Reply With Quote

  #8   Ban this user!
Old 10-29-2011, 06:40 PM
tc429's Avatar  
Join Date: Feb 2011
Location: USA
Posts: 325
tc429 is on a distinguished road

Originally Posted by geach73 View Post
O9010 (DRILL MACRO)
#100=#7(SET VARIABLE #100 EQUAL TO
D – PECK AMOUNT)
#101=ABS [#26] (SET VARIABLE #101 EQUAL TO Z - HOLE DEPTH)
#102=#6 (SET VARIABLE #102 EQUAL TO K – DRILL RETURN OFFSET)
#103=#18 (SET VARIABLE #103 EQUAL TO R – RETRACT LOCATION)
#104=#100 (TEMPORARILY SET VARIABLE #104 EQUAL TO PECK AMOUNT)
#105=#9 (SET VARIABLE #105 EQUAL TO F, FEED RATE)
WHILE [#104LT#101] DO1 (LOOP WHILE TEMP Z-VALUE IS LESS THAN FINISH DEPTH)
G1 Z-#104 F#105 (FEED TO PECK DEPTH = VALUE OF #104)
G0 Z#103 (CLEAR CHIP - RAPID TO RETRACT LOCATION)
Z- [#104-#102] (RAPID RETURN TO LAST LOCATION LESS K VALUE)
#104=#104+#100 (SET TEMP Z EQUAL TO TEMP Z PLUS PECK VALUE)
END1 (END LOOP)
G1 Z-#101 (DRILL TO FINISH DEPTH)
G0 Z#103 (RAPID OUT TO RETRACT LOCATION)
M99 (RETURN TO MAIN PROGRAM)

This closely resembles the subprogram call illustrated earlier, except that now the subroutine is called up with a G65 instead of an M98. Calling subprograms with a G65 allows you to "pass" variables to the subprogram. Variables make it easy to alter a program as cutting conditions require by simply changing the value of D, R, K, etc. It also makes it easy to use these macros for other jobs, as you can simply change a few values in the G65 macro call instead of rewriting the entire drilling routine.

A cleaner way to use this program would be to assign it a G code, like this:

O0001 (MAIN PROGRAM)
N4 G97 M3 S1000 T404
G0 X4. Z1.
G183 Z-1.5 D.35 R.07 F.012 K.02
G28 U0 W0
M30

This makes the macro program appear to be just like any other canned cycle in your machine. If you want to assign a G code to your macro programs, you will need to open the parameter manual for your control and find the specific parameter that maps the program number (usually a 9000-series program) to the G code.

In fact, as you may have already realized, there are few differences between a macro program and a canned cycle. But while canned cycles are fixed, macro programs give you the freedom to accomplish any programming task you desire. And that usually is a big plus when conducting drilling operations on a CNC lathe.
great thread

I never knew (never looked) for a gcode call to a 9000 program
Reply With Quote

  #9   Ban this user!
Old 10-29-2011, 07:33 PM
 
Join Date: Aug 2011
Location: Sydney, Australia
Posts: 3
bkeats is on a distinguished road

Originally Posted by tc429 View Post
great thread

I never knew (never looked) for a gcode call to a 9000 program
fordav11 had made that suggestion in Post #3, and creating a custom G code was covered for the OP MCImes in his other Thread "How do I set a Custom G code?"
Reply With Quote

  #10   Ban this user!
Old 10-30-2011, 04:27 AM
fordav11's Avatar  
Join Date: Aug 2011
Location: Fordaville
Posts: 939
fordav11 is on a distinguished road

Originally Posted by angelw View Post
What's you point regarding how long it took to respond to this thread?
my point is I noticed you reading the OP 2 days ago (the bottom of the page shows who is reading the page) but of course at that time there was no solution posted and you didn't post one either. I waited a couple of days in case someone who knows more about macro answered it but no one did so I posted my reply after doing some research.
then 2 days later you nit-pick my reply after I supplied a possible solution without fully reading/refreshing. You could have re-read it after and it would have been courteous to correct your reply acknowledging my solution and/or removing your unnecessary post entirely. The main problem was the OP cross-posted causing duplicate info/posts. On most forums cross-posting will get you banned although here it's kind of ok I think because 90% of the forums here are dead and a newcomer wouldn't know that. Anyway I don't require a reply here so please don't as this is getting off-topic and the original post was answered in full.

The only thing remaining now is to wait for MCImes to come back here and say whether it worked on his machine and solved his problem....

Last edited by fordav11; 10-31-2011 at 05:08 AM.
Reply With Quote

Sponsored Links
  #11   Ban this user!
Old 10-31-2011, 11:34 AM
 
Join Date: Sep 2011
Location: USA
Posts: 71
MCImes is on a distinguished road

Thanks everyone. Ill try loading up one of those sometime this week when I get a slow day and report back with how it works
__________________
I program, setup and run Swiss lathes with Fanuc controls
Reply With Quote

Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
custom macro hillafbmike Fanuc 2 04-13-2011 09:30 PM
Chip Breaker for Aluminum tpsimer General Metalwork Discussion 24 11-12-2010 10:59 AM
"difference between Custom Macro A and Custom Macro B" arulthambi Parametric Programing 4 10-05-2009 03:34 PM
Writing a custom M code? greeder88 Dynapath 1 06-24-2009 08:52 AM
Custom Macro B On A 18t. JIMMYZ Fanuc 3 10-18-2006 10:08 PM




All times are GMT -5. The time now is 07:27 PM.





Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO
Template-Modifications by TMS

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361