|
|
G Code TrickQuestion
If we are doing a number of code intensive parts that are all the same, say circles, what is the procedure to have the code written once and repeat itself starting at a different xy location? This would reduce the size of our programs. For example, say we want to do 15 -18" diameter circles on a 5 x 8 sheet of MDF. Also, is there a way to insert a code before a 'M00' to signal a buzzer to let the operator know it's time to flip a part over or clean up the cuttoffs before the next operation? Forum Responses
G23 N8
Then switch to incremental programming (G91) and produce one part.
If the shape of your part is extensive, this works wonders. It also works well if you have to make several passes around the same part. In all, it looks like this: (MOVE TO 1st LOCATION)
From contributor K: My Multicam has a command that makes the last position of the job the new home to start from and restarts the job from there. Still, this only makes sense when the job has lots of lines, 3D shaping or so. You can come a long way with a spreadsheet (Excel) to disassemble, edit and reassemble. From contributor J: You are using almost the exact same machine combination as me, so I may well be able to supply you with very accurate code. I do have a few questions, however. I assume a standard row/column layout isn't acceptable, as it surely doesn't give a very nice yield? (You want staggered rows?)
We run an Andi/Fanuc 11/AlphaCAM here as well.
From the original questioner: Contributor J, for the parts I am considering, we would use a std row/column layout. For my example, we would make 18" diameter circles at 5 x 3 layout for 15 pieces per sheet. And yes, we use a bleeder board to hold down. What I need to know is how to do something like the post above. A 'repeat at x##,y##' procedure. The reason for all of this is that we could economize our controller memory as we keep a number of daily programs in the machine, and still have room for specials.
From contributor J: You need to make two "nested loops." This can be a bit tricky your first time but not impossible. You're going to have to learn two loops instead of just one. Here's the concept in a nutshell: The first loop...
That's your "inner" loop. If you set the conditions right, this will net you any number of circles side by side. Every time the counter goes up one, the G52 shift goes up one more time and the shift gets bigger and bigger. First it shifts 200mm, then 400mm, then 600mm, etc. The main thing to watch is when you go to repeat this loop, you must *not* repeat the line which sets the counter to zero. Obviously, the condition you set to exit the loop will never be met if you make this error. Here's some code: N1
This simple loop will execute your program six times (never forget the time the machine cuts when the counter is set to 0), shifting 200mm to the negative in x each time. Note that when the program repeats, it does *not* repeat the step of setting the counter to zero. I'll let that sink in and do the double loop in another post, then I will try a real double loop on my machine since the code should be near identical.
From contributor C: Here's a handwritten main and subprogram to do what you want to do. It assumes that X0Y0 is at the right rear corner of the machine, X-axis runs left to right, Y-axis front to back, and the standard Cartesian coordinate system is used - hence all absolute X & Y locations are negative. It also assumes that Z0 is top of part. Every machine is different, so you may need to rearrange the code a bit for your machine. I don't know how big your table is, so I placed the circles 1/4" from the right and rear edges of the machine. The main program goes to each start point in succession, working from left to right and back to front. At each start point, the subprogram is called (M98) and executed. At the end of the subprogram, control is returned to the main (M99) which proceeds to the next start point. The subprogram makes a 1" move to turn comp on and ramp through the material to cutting depth, then another 1" move to the top and center of the circle. The G02J-9. block makes one complete circle of 9" radius. (If you aren't familiar with I & J codes, look them up in your manual - to me it's the simplest way to make full circles.) The circle is followed by a 1" move away from the part and another 1" move to ramp up and out. This is the basic manual programming style that we used for years prior to CAM software. Using subprograms can save a lot of space when you have multiple parts on the table, especially if the shapes are complex. It also simplifies tweaking as you only have one subprogram to deal with as opposed to multiple occurrences within the main. If you have Macro-B (Fanuc option) enabled on your control, you could make this program shorter as well as parametric. You could actually have the program figure how many circles fit based on the circle diameter and sheet size used! These days we mostly use CAM'd programs, as it is much faster and more accurate (no math errors or typos!). Memory is also cheap, so program size isn't really a factor. Anyway, try this out and see if it works for you. O100(18 IN CIRCLES - MAIN)
O105(18 IN CIRCLES - SUBPROGRAM)
From contributor C: After reading contributor J's post, it occurs to me that macro languages have probably progressed a bit since Fanuc's Macro-B language that I used. Imagine, actual variable names instead of variable numbers! Just for fun, here's an old (note the date) hole macro that we used to leave resident in the control and was used by many of our old programs. Variables were passed to it when calling from the main program: G65P4028A0D2.25F200.H1R.5T3.Z.50 Note that if "H" is set to zero it simply cuts the inside perimeter of the circle. If "H" is set to 1 it will hog out the entire hole starting at the center. Don't ask how I came up with 4028 for the program number - I have no idea! O4028(HOLE BORING)
From contributor J: One thing I didn't mention - the loops have two functions. They not only repeat the cut path the required times, they also provide the means for the program to calculate the increasing coordinate shifts each cut path needs. Here's the first loop again: N10
I'm going to change the line numbers only by adding zeros so I can add the second loop. What you have to remember about the second loop is you want to repeat the *whole* first process. Again, watch where you send the program so the counters get reset properly. For the next loop, which will do the columns, you *do* want the first loop counter reset to zero so you get all the rows. COUNTER1=1
It's hard to see properly in this little window, so I will write the code for a real program and try it. Can you provide the cutting code you have now? I think you can see once you learn how to program loops that you can do a lot of things with short programs. Much better than a subroutine program as was posted above. One of the reasons is that by editing (or making them variables) the two numbers that govern rows and columns, you can change those quantities easily. For smaller parts there are way fewer lines when using loops.
From contributor J: Contributor C, you bring up a good point that I was foolish not to point out. In fact, you can't use named variables in the FANUC we use; I was merely trying to make the code easier to understand by giving the variables meaningful names. I should have clarified that. The variables on my machine in reality look much more like you say, i.e. #123. This is unfortunate as it does make debugging a little more of a challenge, especially when you're only just learning. From contributor C: Contributor J, I feel better now - thought for a minute I was way behind the times! I don't know what Fanuc's current macro language is, but when Macro-B came along it was like moving into the light! Macro-A was mind numbing to write and edit. It looked like this: G65H02P#102Q#101R.500 It means add .500 to var #101 and store in var #102 G65 = This is a macro statement - every macro line started with this
Glad we don't have to do that anymore! P.S. It's much easier to type your message in Notepad than paste into the little message window.
From contributor B: I'll often have "cut path" as a sub program so it makes the loop program as easy to view as contributor J's. From contributor S: Contributor C, good posts. I can relate. When it comes to Macro B, I knew more 3 years ago than I do now. It sure is nice to be able to jump on our Weeke and whip out parametrics that used to take me a week. Macro B does still have its place, and I use it once in a while. It's kind of like getting on my horse and going for a slow, sure-footed ride, as opposed to jumping in my car and standing on the gas. From contributor J: I wasn't thinking when I typed in the control we use. We also have an 18M Fanuc, so this hopefully will work on your machine with few, if any, modifications. Our machine zero is back right, we use the sheet butted to the pins at front right and we use the material bottom as zero (don't ask - I hate it, too). BE CAREFUL IF YOU TRY THIS UNEDITED---> TEST TEST TEST! he he I just ran this and it works. Note the few 'syntax' things the FANUC requires with brackets and EQ for equals, etc. It cuts 3 rows of 15" circles on a 5 x 8 sheet with a 1/2" tool. I left 14 mm between parts. Hope this helps: START
I travel at 40 mm above the table and rapid to 25 mm when the sheet is 19 mm as it was programmed here. I assume no responsibility for crashes! Test this first, please use z-lockout, etc.
From contributor L: As the picture attached, try NESTING function (under "util"), or COPY toolpath if you only have basic engraving version. Both can select subprogram. en.. Try my program below if you like (exxact51), set G54 first! START
You can buy a sensitive detector (people use for their cat or visitor) at Walmart or K-Mart. Place it on machine zero point. Cheap and easy!
The comments below were added after this Forum discussion was archived as a Knowledge Base article (add your comment). Comment from contributor T:
Write a program that starts nozzle at the corner of your material and homes every axis but X and Y, then calls out another program and then homes the machine again. This will be your main program. O1513(MAIN)
Write a row movement program that calls out your part program and sets the row movements. O1514(ROW MOVEMENT)
Now write your part program.
When the part program finishes, it will repeat the number of times you specified moving to the location of the next part, which you also specified at the end of the part program. The part program will then exit back to the row program and finish running there, which moves your tool to the top of the next row. The row program finishes and runs again because you told it to run 5 times in the main program. The first thing in the row program is a call out for the part program which again runs 3 times. The entire cycle repeats until all repetitions have run and the main program finishes and exits. Would you like to add information to this article? Interested in writing or submitting an article? Have a question about this article? Have you reviewed the related Knowledge Base areas below?
|
|
|
||||
| Home » Knowledge Base » Knowledge Base Article | Login | |||