# Thread: Need Help With Circular Pocketing Algorithm

1. ## Need Help With Circular Pocketing Algorithm

I'm implementing gcode subroutines for a wizard I'm writing to do circular pocketing on a milling machine. The input will be: pocket diameter, tool diameter, pocket depth, depth per pass, tool stepover, ramp angle, center x and y, climb or conventional, finish depth pass, finish radial pass.

See: http://www.se-ltd.com/~lerman/gallery/G-Wiz/wizarddemo for a sample screendump.

I've found that it is a lot easier to generate the screen than it is to generate the gcode (this will be implemented as an EMC style gcode subroutine). Some of the issues I'm having are:

1 - Do I mill the pocket from the outside in or from the center out? Going from the outside has the advantage that I should be able to ramp to each step in the first half circle. Since there is more motion, the ramping should cut better.
In that case, I would start inside of the finish allowance, ramp down to the first step in the first circle, then do concentric circles (in a CW direction) with circular arcs connecting them until I got to the center. Then go back to the outside and do it again. One awkward aspect of this is that when I do the finish pass on the diameter, I would have to reverse the direction so as to continue to climb mill.

2 - Assume I'm going from outside to inside. Then, what does the final pass look like? I would take an extra circular pass to remove what is left of the ramp from the previous pass. The ramp down in a CW direction to the finish depth and cut the full circle. The spiral out in a CCW direction taking the finish pass on part of the bottom and the outside diameter. Come back in again taking a circular pass to remove the last ramp. Then go CW again and spiral in to the center to finish the bottom. Is all of this necessary? Would it be sufficient to cut the outside finish pass in a CCW direction so as to climb mill it and continue in that direction in the spiral to the center. It seems to me that since this is just a shallow bottom cut, it probably shouldn't matter if it is climb or conventional milled.

3 - I'm assuming that the ramp is specified as an angle. Is that the most convenient way? Would users prefer it as slope (drop/run).?

Any thoughts or comments would be appreciated. Does anyone have a paper describing an algorithm for this?

Thanks,

Ken

2. Look at this site. The code is C, but is easy to follow.

http://jelinux.pico-systems.com/gcode.html

RipperSoftware

3. I'm familiar with Jon Elson's code. In fact, it served as the prototype for the first version of the pocketing gcode subroutine I wrote.

It doesn't address the issue of ramping into the material.

My current version of the code just plunges at the center of the pocket feeding at the current feed rate divided by five. That worked fine for the few different cases I tried. But they were very limited.

What I really need is a good, tried and tested algorithm. Does anyone know what the mach3 wizards do for this?

Ken

4. In my AutoCAD macro I think I ramp in from near the edge, or a fixed length from center, depending on the diameter and tool size, and start spiraling from the center, leaving the finish allowance.

• Ger,

When you say "my autocad macro" do you mean one that you use or one that you wrote?

Does the user specify the ramp angle? If it is a fixed distance from center, how do you guarantee that the distance is great enough so that you can ramp deeply enough? Or do you ramp back and forth until you get to the depth? I would think that if you go back and forth, you would want the distance to depend on the tool diameter. You might want to go at least a few diameters so that you are not simply plunging.

I wanted to avoid the separate ramping because then the cut would be broken as the cutter crossed the ramp area. Also, the bottom would not appear as regular. Am I worrying about things that shouldn't matter?

Thanks for commenting,

Ken

• Originally Posted by lerman
Ger,

When you say "my autocad macro" do you mean one that you use or one that you wrote?

Both.

I wrote it to just ramp to the depth of cut for that pass, with the max depth per pass specified by the user. I don't specify the ramp angle, but I think I have a fixed ramp length that gets smaller if the tool and hole size need it. Just a single ramp to the center. I work with wood, so I didn't think about breaking tools when I wrote it.

• I think I may have an approach.

1 - Position off the center by a the distance corresponding to the stepover. If this is larger than the rough diameter reduce to fit.

2 - Then helically ramp into the material at the specified angle. Do this in whole circles, taking as many loops as necessary to get to the step depth. If this is the last step before the rough bottom, it may be smaller than previous steps. Also if this is the last step, take an extra loop around the circle to remove the ramp.

3 - Circularly loop outwards to the next stepover. Repeat this until at the rough diameter.

4 - At the rough diameter, loop all the way around.

5 - The lift the cutter off the bottom and head back to the center (where the ramp is started).

6 - Now loop back to step 1 to do the next step. (Unless this was the last step).

7 - Ramp down to the finish depth. Take an extra loop around the circle to remove the ramp.

8 - Now spiral out (a stepover at a time) to the finish diameter, taking a final loop around at the end. Loop back to the center. Raise the cutter.

9 - DONE

ONE MORE QUESTION:

Should I provide different feed and speed rates for the rough and final passes? My inclination is to NOT provide them. In fact, I'd like to assume that the speed and feed have been preset prior to entering this subroutine.

If the user needs different values, he can do a separate subroutine call to do the finish passes.

Thanks,

Ken

• Originally Posted by lerman
I think I may have an approach......Any comments?

Thanks,

Ken
This seems very similar to the Haas circular pocket routine with the advantage that it is not necessary to prebore the center hole because you have included the center helical interpolation down to the cut depth.

Regarding different speeds/feeds do you plan on doing the central helical operation at the same feed that you then use for the spiralling out? I find it sometimes necessary to do the initial helical ramp a bit slower because there is not as much space for the cutter to eject chips; once you are going round the inside of the spiral things can move faster.

• Geof,

I wasn't planning a different feed. I could add that, but it's just another thing for the user to (mis)understand. If the user find it to be a problem, he could pre-bore the initial hole by using the same routine with a slower feed.

Do you have any documentation on the Haas routines? I'm building a conversational gcode wizard (called G-Wiz) to work with EMC, and could use some definitions for a bunch of routines. It's relatively easy to find info on what they do and what parameters they take; but what I really need is HOW they are done.

Thanks,

Ken

• The only Haas information I have is from the manual about using the routine. If you went to the Haas website and dug your way down to their literature page you would find it in the mill manual. I think you would find Haas very reluctant to tell you how theirs is done.