1. ## Macro/Parametric Programming

Hi all. I've been a Fadal user for quite a while. Over the years I have taught myself a few tricks using Fadal's Macro Language. Here is one example that I'd like to share. Anybody else have any unique macro examples?

---

I have a plate that is 2.5x2.5" and 1.00" thick. I need to cut a .75" radius on the front edge.

One option is to use a radius cutter.

Another, would be to repeat a subroutine that has a G19 G2/G3 move (arc on YZ) and a small stepover in X. This is actually my preferred method when I am looking for the best finish. On the downside, it is slow.

The method I am going to describe here is a pretty quick way to get the job done. The program creates a Z-level toolpath (tool moves down in Z, then cuts the part shape at that level, moves down again in Z, and repeats until the shape is cut). You can cut any radius, with virtually any size tool, and any tool corner radius.

I use macro programming to create a loop. Within that loop, the program calculates a toolpath for the first Z-level. The toolpath always returns the tool to it's initial position in X,Y. A new toolpath is calculated for the next Z-level, and the loop repeats until the radius is cut. This pic shows the first and last toolpath that gets created.

The first move of the toolpath is a G1 move to the Z level. Move 2 takes the tool into the part until the tool corner radius is tangent (touching) the part radius. Move 3 is the cut along the part edge. Move 4 is a short retract to get the tool off the stock. And Move 5 is a rapid move to the initial position in X,Y.

I sometimes will step the Z down in equal steps. Though I usually only do this for roughing, as it leaves heavy steps near the top of your radius (relative to the bottom anyway).

The way I'll do it here leaves a much more consistent finish on the radius. I select an angle to step around the arc, and use the sine function to calculate the step in Z. What I get are very small steps in Z at the top of the radius, and large steps at the bottom.

I have selected a favorite tool that I have a my disposal. It's 1.00" dia, with a .060 corner radius. Virtually any size tool will work within reason. If the radius is not roughed out at all yet, my tool is about minimum diameter to work well, IMO. The larger the corner radius, the better the finish. A tool with 0 corner radius can be used (i.e., square end mill), but with make for a rough finish.

This program requires that the diameter of the tool to be in the CDC table. It does not use G41/G42, but it does look into the table so that it can calculate the correct toolpath. You could use a value of 0 in the CDC, if you adjust one of the variables by the value of the tool's radius (more on this later).

Anyway, on to the program:

<I retyped this so be sure to prove it out first - I can't be held responsible for crashes>

%
N1 O8001(.75 RADIUS ON FRONT EDGE
N2 M6 T1 (1.00 INGERSOLL W/ .06R
N3 G70 G90 G0 S2500 M3 F60.
N4 G43 H1 Z3. X1.3 Y-1.85 (initial position for X,Y)
N5 Z.1 (.1 above the part)
N6 #V1=.75 'the radius to be cut on the part
N7 #V2=.06 'the corner radius on the tool
N8 #V3=0 'the start angle
N9 #V4=90 'the finish angle
N10 #V5=15 'the step angle
N11 #V7=-.5 'the distance from Y0 to the center of the radius
N12 #V8=-.75 ' the distance from Z0 to the center of the radius
N13 #V10=TN 'sets V10 to the current tool number
N14 #V11=D(V10)/2 'sets V11 to the radius of the current tool
N15 #V12=V1+V2 'the actual arc thats calculated
N16 #:LOOP
N17 #R1=V7-V11+V2-(SIN(V3)*V12) 'calculates the Y position
N18 #R3=V8-V2+(COS(V3)*V12) 'calculates the Z position
N19 G1 Z+R3 (moves to Z-level
N20 Y+R1 (feed in to radius
N21 X-1.3 (cut along edge
N22 G91 G0 Z.05 G90 (short retract [YES, G91/G90 can be on the same line]
N24 #IFV3GEV4THENGOTO:END 'if at the finish angle goto end
N25 #V3=V3+V5 'increase the step counter
N26 #IFV3GEV4THENV3=V4 'step counter should not be more than finish angle
N27 #GOTO:LOOP
N28 #:END
N29 G0 Z.1 M5 M9
N30 G49 Z0
N31 M2
%

Notice that my start angle was 0°, finish angle was 90°, and step was 15°. I picked these numbers for demonstration only. They match my pictures. And I think it made it easier to explain.

Really the cuts at 0 and 90° are wasted cuts. They wouldn't be removing any stock, just dusting the existing surfaces.

And the 15° step is huge. It would leave a very rough surface.

To actually machine this part with this tool, I'd try 3° start angle, 87° finish, and a 3° step angle.

Hope you find this approach as useful as I have. If you have any comments, shoot me a line at beckerdan69(at)hotmail(dot)com

Cheers,
Dan

2. Dan,

I'm working on extensions to EMC to provide subroutines and control structures. Do I have your permission to translate this code to that language and publish it? I'll give full credit to you in the comments, of course.

Thanks,

Ken

3. Originally Posted by lerman
Dan,

I'm working on extensions to EMC to provide subroutines and control structures. Do I have your permission to translate this code to that language and publish it? I'll give full credit to you in the comments, of course.

Thanks,

Ken
Sure, you can use it.

4. Oops, I just noticed something I forgot to do.

I need to thank you for posting stuff like this. I find it very valuable and encourage you to post more of the same.

Thanks again.

Ken

• This is actually part of a little project that I have been working on. I planned on having a version of this program in my machine to be called as a sub-program. My main program would assign values to the variables that describe the size/location of the radius, then call the suprogram.

I was working on getting subprograms set up to about every configuration of radius or fillet for an edge, block, pocket, cylinder, or hole.

I was working on writing a manual to show how to use all these subprograms. It was becoming more work than I had imagined.

Then I realized that there is only one other guy in my shop that would need to know how to use them. I showed him some examples of how to do this instead.

Now I usually just copy and modify this code. Then paste it into my main program.