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 > G-Code Programing


G-Code Programing Discuss G-code programing and problems here!


This forum is sponsored by:

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 06-03-2007, 07:21 AM
 
Join Date: Jan 2005
Location: USA
Posts: 49
DocHod is on a distinguished road
Macro for multi part

Hi, all just got started on modifying a program we have for our cnc router (fanuc control) all they want to do is make multiple parts using a small program (the piece is 4"o.d. 1" i.d.) so I began writing macro into the program and it repeats what I want but it just stays in the same cutting area I have the program below and hope someone can help , thanks . %
N1(UHMW_1IN1.OUT 31-UHMW-0033)
(MCULMS NAME"MACH1S")
(MCUSTOCK X120. Y48. Z1. OBL)
N2G00G17G20G28G40G80G91Z0M5
N3G90
N4 (#508 AMOUNT OF BLANKS REQUIRED)
N5 (#509 AMOUNT OF BLANKS RAN)
N6 IF[#509 GE 1] GOTO8
N7 IF[#509 EQ 0] GOTO9
N8 G91X5.25
N9G52X0Y0Z0
N10G08P1
N11M08
N12(MCUTOOL TOOL2006 D0.750 R0.000 L4.000 NAME "ROUTER-BIT .75 DIA." I1)
N13G28G91Z0M05
N14G90T2006M06
N15T102
N16M03S15000
N17G00G17G55X2.777Y2.8749
N18G00G43H6Z1.25
N19Z1.1
N20G41D06G01X3.1342Y3.0812F150.
N21Z.25
N22G03X3.1379Y3.0948I-.005J.0087F300.
N23I-.1178J-.068
N24X3.1242Y3.0985I-.0087J-.005
N25G00Z1.25
N26G40G00X2.767Y2.8922
N27X2.777Y2.8749
N28Z1.1
N29G41D06G01X3.1342Y3.0812F150.
N30G00Z.35
N31G01Z0.
N32G03X3.1379Y3.0948I-.005J.0087F300.
N33I-.1178J-.068
N34X3.1242Y3.0985I-.0087J-.005
N35G00Z1.25
N36G40G00X2.767Y2.8922
N37X5.307Y2.1715
N38S12000
N39Z1.1
N40G42D06G01X5.3789Y2.5777F175.
N41G03X5.0761Y4.2138Z.25I-2.3377J.4134
N42I-2.0559J-1.187F350.
N43X4.8415Y4.5495Z.045I-2.0559J-1.187F350.
N44I-1.8214J-1.5226
N45X4.2783Y5.04I-1.8214J-1.5226F350.
N46X3.7299Y5.3033Z.35I-1.2931J-1.9909
N47G00Z1.25
N48G40G00X3.3382Y5.4327
N49(MCUTOOL TOOL2009 D0.250 R0.000 L4.000 NAME "EDGE RADIUS" I1)
N50G28G91Z0M05
N51G90T2009M06
N52T102
N53M03S20000
N54G00G17G55X3.0949Y3.4878
N55G00G43H9Z1.25
N56Z1.1
N57G42D09G01X3.1446Y3.4739F375.
N58G02X3.422Y3.2589Z.92I-.1245J-.4471
N59I-.4019J-.232F750.
N60X3.4842Y3.0198I-.4019J-.232F750.
N61X3.3465Y2.6969Z1.1I-.464J.007
N62G00Z1.25
N63G40G00X3.3098Y2.6606
N64X4.9612Y3.6753
N65Z1.1
N66G42D09G01X4.9436Y3.7238F375.
N67G03X4.7919Y4.0498Z.92I-1.9235J-.697
N68I-1.7718J-1.0229F750.
N69X4.654Y4.2581I-1.7718J-1.0229F750.
N70X4.4132Y4.5251Z1.1I-1.6339J-1.2313
N71G00Z1.25
N72G40G00X4.3755Y4.5603
N73G28G91Z0M5
N74#509=#509+1
N75 IF[#509 GE #508] GOTO77
/N76 M99
N77G28G91X0M09
N78G90
N79G52X0Y0Z0
N80G08P0
N81 #509=0
N82M30
%

Last edited by DocHod; 06-05-2007 at 09:03 PM.
Reply With Quote

  #2   Ban this user!
Old 06-03-2007, 08:11 AM
 
Join Date: Jul 2005
Location: Canada
Posts: 11,563
Geof will become famous soon enough

I only see one work coordinate in your program. You need multiple work coordinates in all the locations you want to cut parts. You can put them in by hand in all the G54, G55, etc values or by using G52 X Y to create 'child' coordinates.

A similar problem was discussed in this thread; http://www.cnczone.com/forums/showthread.php?t=34513

This is for a lathe but the same principles apply. Look particularly at Post #19 it describes a macro for calculating values to use with G52. You would need to extend it to two values that step out a grid.

If your controller can handle multi-nested subroutines it is possible to do the same thing but then your actual program has to be written in incremental.
__________________
An open mind is a virtue...so long as all the common sense has not leaked out.
Reply With Quote

  #3   Ban this user!
Old 06-03-2007, 01:33 PM
gar gar is offline
 
Join Date: Mar 2005
Location: USA
Posts: 1,498
gar is on a distinguished road

070603-1333 EST USA

DocHod:

First, I want to criticize your question.

You have presented a program of one long sequence of compacted unintelligible alpha-numeric characters, and few if any comments on the program logic.

If you put this program away for a year, then after that time away from your memory how long will it take to reunderstand what the program does?

I would like to see line numbers only when required. For example: need for a GOTO or subroutine call, or a reference point for some other reason.

I like fields separated by at least a space, or even better formatting where Xs, Ys, etc. are aligned. What is a field? A logical element representing an entity within a record (a record is usually a line). For example: in a spread sheet each column in a row would be a field, and in a CNC program I would classify G10 or, X 0.9, or N1000 as fields.

I like to see line spacing between major sections of a program. For example: a local subroutine would be preceded by a blank line as follows:

GOTO 1000 (Just some code before the subroutine. Nothing to do with the subroutine.)

N200 (subroutine to calculate a point on an ellipse with center at 0, 0)
#100 = #121 COS #120 (X value)
#101 = #122 SIN #120 (Y value)
M99 (command to return from subroutine to the line following the call to the subroutine)
(HAAS uses the description "Return from subroutine", but at M99 you have not yet returned.)

N201 (some other subroutine)

What I have also shown here is supplying comments to ease understanding. Normally I would not provide any comment on an M99 at the end of a subroutine. But in other uses of M99 I might add a comment.

I have no idea what is in your program because there is too much clutter to wade thru.


Second, to help you.
The essence of what you want to do is this:

1. Set up a starting reference point with maybe G54. This is not necessarily the reference point of the first part. And at this level work in absolute (G90).
2. Create two loop points, counters, and count limits.
3. Use G52 as Geof has mentioned to set your changing base position for each part. At this level you must be in G90 for your move to the next position.
4. Create an internal or external subroutine for one part. This can be in either absolute or incremental.

Now part of what you want follows:

G54
G52 X0 Y0 (this will start first part at the G54 location)
( otherwise put in initial values relative to G54 for the start)

#100 = a value ( X offset from one part to the next )
#101 = a value ( Y offset from one part to another )

#110 = a value ( number of parts in the x direction )
#111 = a value ( number of parts in the y direction )

#120 = 0 ( X direction part count initialized to zero )
#121 = 0 ( Y direction part count initialized to zero )

N1100 ( Y loop )
N1101 ( X loop )

call your subroutine

#120 = #120 + 1 ( increment X count )
#5201 = #5201 + #100 ( increment the G52 X position )
if [#120 LT #110] GOTO 1101 (this is the X loop)

#120 = 0 ( reset X count to zero )
#121 = #121 + 1 ( increment Y count )
#5202 = #5202 + #101 ( increment the G52 Y position )
if [#121 LT #111] GOTO 1100 (this is the Y loop)

GOTO DONE --- the program is all done except ending things.

See if there are any mistakes. Note in actual operation you may need decimal points, and there could be sign problems, as there were in our 1993 HAAS.

Also note this can be very inefficient if there are tool changes within the subroutine. I have techniques that get around the tool change problem on multiple parts, but these are not a free giveaway.

.
Reply With Quote

  #4   Ban this user!
Old 06-03-2007, 02:57 PM
 
Join Date: Jan 2005
Location: USA
Posts: 49
DocHod is on a distinguished road

gar I know it's a mess and was going to clean it up later, all I added to the program that someone else generated was macro calls from N4-N7 and N74- N82 . I'm not the programmer of the machine but someone that was asked if there is a way to do multiparts with a short program. geof the program uses G52 for the tool change and G55 for the actual work coordinate , yes I could use other work coordinate but I would run out of work coordinate before I get the required parts.
Reply With Quote

  #5   Ban this user!
Old 06-03-2007, 03:26 PM
 
Join Date: Jul 2005
Location: Canada
Posts: 11,563
Geof will become famous soon enough

Originally Posted by DocHod View Post
...geof the program uses G52 for the tool change and G55 for the actual work coordinate , yes I could use other work coordinate but I would run out of work coordinate before I get the required parts.
First comment: The G52 ahead of the tool change is doing nothing. All that G52 X0 Y0 Z0 does is put zero into the G52 register. If you are not using G52 to set any child coordinates the G52 register is zero anyway.

Second comment: You never run out of G52 child coordinates. During a program you can enters values into G52 as many times as you want because the new value overwrites the old and you can always set the G52 register to zero at any time with G52 X0 Y0 Z0.

Using G52 you simply need to know the locations with reference to G55 of all your parts; these have to be at the head of the program and the actual operations have to be called as a local subroutine or as an external sub program.

You would have something like:

G55
G52 X4. Y0. Z0.
M98 P(Prog number) The P might have to be an O
G52 X8. Y0. Z0.
M98 P(Prog number)
etc
etc
for as many X locations at the same Y until you have to move Y
G52 X(n*4) Y4. Z0.
M98 P(Prog number)
and step back through the X's

The problem with this is that it can be a lengthy program because if you are doing 10 steps in X and 10 steps in Y across a grid pattern and making a part at each point you need 100 G52 lines. And if you want to change your X or Y location you have to edit 100 lines.

This is why I suggested calculating the G52 coordinates using a macro. This requires many fewer program lines and editing for a change in X or Y is trivial.


Final comment regarding the G52 X0 Y0 Z0 in the program: It is possible the programmer was getting confused with G53. G53 X0 Y0. Z0. will send the machine home.
__________________
An open mind is a virtue...so long as all the common sense has not leaked out.
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 06-03-2007, 04:56 PM
gar gar is offline
 
Join Date: Mar 2005
Location: USA
Posts: 1,498
gar is on a distinguished road

070603-1612 EST USA

DocHod:

Do lines N4 and N5 have any other purpose than to hold a comment. If not then where are #508 and #509 loaded.

Where is the machine ever set at a start point?
What happens if #509 is negative?
What is the initial value of #509?
What does N74 = #509 + 1 do? Should be an error.

Is it correct that all the code from N8 thru N73 was original?
What is the purpose of G91 in the following line?
N50G28G91Z0M05

It looks like you never go below Z 0 relative to G55, and it looks like Z 1.25 may be a clearance plane. Further it appears that cut comp is ended by first going to Z 1.25, than ramping out. Thus, you do not ramp away from the cut. I would think this would leave a mark at the path end from the vertical move.

Why the G28G91Z0 just before G90T2009? I would think you could eliminate G91 and G90 here. G28 Z0 should take you to machine Z home position.

Can you define what G52 is supposed to do in your machine?

.
Reply With Quote

  #7   Ban this user!
Old 06-03-2007, 05:34 PM
 
Join Date: Jul 2005
Location: Canada
Posts: 11,563
Geof will become famous soon enough

Originally Posted by gar View Post
....G28 Z0 should take you to machine Z home position...
gar; But this takes you first to Z0. in the current coordinate system, then to machine home. At least that is what it does on my machines and I think that it is a standard that G28 commands the machine to go to the identified reference point then home. Putting an incremental command with the G28 tells the machine to move Z0. incrementally then go home.
__________________
An open mind is a virtue...so long as all the common sense has not leaked out.
Reply With Quote

  #8   Ban this user!
Old 06-03-2007, 07:12 PM
gar gar is offline
 
Join Date: Mar 2005
Location: USA
Posts: 1,498
gar is on a distinguished road

070603-1844 EST USA

Geof:

I will have to try this sometime. G28 is something I never use.

However, from the HAAS on-line manual is the following quote:

"HOME G28 - Returns all axes to machine zero in rapid motion. Home G28 will also home a single axis in the
same manner if you enter an axis letter and press the home G28 button. CAUTION! There is no warning
message to alert the operator of any possible collision. For example, if the Z-axis is down in amongst parts on
the table when X or Y is zeroed, a crash can result."

This maybe incomplete, or inaccurate, or maybe G28 Z performs the above, and G28 Z0 does not.

On rereading this appears to relate to the G28 button. Thus, it should indicate that this does not apply to use of G28 in a program. Great lack of consistency. Also in my opinion misuse of the G91 code which is really being used in the G28 line of code as a modifier to inhibit the thru point. It probably has the unintended effect of putting the machine into incremental mode when not wanted.

If one does G53 Z0, then we do not have do the the G91 and back to G90 thing.

On p118 your definition is defined and the strange use of G91 is included. But the use of G91 is not clearly defined and all of its effects.

.
Reply With Quote

  #9   Ban this user!
Old 06-05-2007, 09:01 PM
 
Join Date: Jan 2005
Location: USA
Posts: 49
DocHod is on a distinguished road

gar , yes N74 is an incorrect statement it should be #509=#509+1 and I corrected it in my post , line 4 and 5 are just notes to the operator line 6 and 7 are for counting the parts ran , the operator would put in variable #508 the amount of parts he needs and #509 will be set to 0 , variable #509 would count how many part are ran .the plan is when the first part is ran at the initial work coordinate that it counts it (N74 #509=#509+1) then jumps to N76 (M99) when it goes back to the top of the program it reads N6 and then jumps to N8 this is the amount to move an incremental move and do another part. But the G55 is getting in the way because it read it again and moves back to the initial start point of the first part . I hope I don't give anyone a head ache that reads this lol . I will get this program to run properly when I get a chance , thanks everone for the help so far .
Reply With Quote

  #10   Ban this user!
Old 06-05-2007, 10:09 PM
gar gar is offline
 
Join Date: Mar 2005
Location: USA
Posts: 1,498
gar is on a distinguished road

070605-2148 EST USA

DocHod:

Is there a reason to have the operator initialize #509 instead of the program? If not put it in the program and relieve the operator of a possible error.

Or do you want to start at some particular part count with a non-zero value in #509? This will require a program modification further down.

How easy is it for an operator to load a #500 series variable vs some other like #100, or some other method of loading the information?

If you use the count * increment for the offset position, then you can start at any desired count location by the initialized count value of #509. This preferably means using G52 for your offset.

.
Reply With Quote

Sponsored Links
  #11   Ban this user!
Old 06-07-2007, 07:03 PM
 
Join Date: Jan 2005
Location: USA
Posts: 49
DocHod is on a distinguished road

gar , it is up to the operator to put in how many parts he wants because of time restraints of run time that the machine can be ran for how long on a particular part and accessing the variables is quite easy on a Fanuc controller.
Reply With Quote

  #12   Ban this user!
Old 06-07-2007, 08:25 PM
gar gar is offline
 
Join Date: Mar 2005
Location: USA
Posts: 1,498
gar is on a distinguished road

070607-2018 EST USA

DocHod:

#508 is the count of what you want made as I understand your notes. #509 is the count of where you are in the sequence. #509 has to be set to zero at the start of the new run and this is not done in your program. Thus, the operator has to set this value as well as the number required. This #509 can always be initiallized to 0 in the program if you never need to restart part way thru your part sequence.

To start part way thru the sequence you have to change the way the program is written.

.
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
Multi-Part Fixturing Geof Work Fixtures and Hold-Down Solutions 12 10-09-2009 08:25 AM
How to multi part Toddjones Mastercam 6 04-23-2009 10:02 AM
Multi-motors Tsukuyomi Stepper Motors and Drives 5 05-02-2006 08:45 PM
multi-boot two HDs Karl_T Computers and Networking 3 06-20-2005 11:58 PM
Multi Bit Drill Head smythe WoodWorking 0 11-16-2004 12:02 PM




All times are GMT -5. The time now is 08:22 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