Machining a Parabola on a Lathe
Machining a Parabola on a Lathe (12/24/97) 
Machining a parabola is an interesting application for Custom Macro. A few years ago a small job shop hired me to program a "big radius" on a part. I said "Sure, a radius is no problem on a Fanuc 10T". The Big Radius turned out to be a parabolic shape on a plastic mold.
The shop didn't have a PC connected to the machine and like most lathes this one had very limited memory. There was no way the control was going to hold enough code to machine a complete parabola using a regular "G" code program.
The parabola was defined by the function
. The part had a .700" bore and a 6.00" OD. Remember that lathes program in diameter but this equation is for the radius of the parabola. That can get confusing when looking at the program. I set up the problem with Z0 being at the X centerline. That is,
. Since the part has a .700" bore we don't ever get to Z0 in the program. At a radius of .350" the Z value is .0081. This is calculated by
. Remember to work in radius when calculating. The maximum Z value at the OD is
or .5934. This will be the start point for the finish pass.
To rough the shape was no problem using a G90 boring cycle. A simple loop was used to increment a counter and the end point was calculated based on the radius. Here is the code based on a bore of .70" and a maximum diameter of 6.00":
G0X.65Z.65(POSITION TO CLEARANCE POINT)
G96S700
#130=.35( INITIALIZE COUNTER TO START RADIUS)
WHILE[#130 LT 3.0] DO1 (COUNT TO FINISH RADIUS)
#131=[[#130*#130]/15.168 (CALCULATE. Z VALUE)
G90X[#130*2]Z[#131+.003] (LEAVE .003 FINISH STOCK IN Z)
G0X[[#130*2]-.05] (RAPID TO NEW X START POINT)
#130=#130 + .1 (INCREMENT COUNTER BY DEPTH OF CUT DESIRED)
END1
Finishing the Parabola
This is where it got interesting. I thought that I would be able to simply write a loop that calculated an X and Z end point, increment it by .0001 and go. It turns out that a CNC control doesn't have a lot of processing power and this approach completely overwhelmed the control. After thinking about how the control works I decided to use some basic differential calculus and write a program based on the slope of the tangent line to the parabola.
The control has custom chips that are optimized for linear moves and this eased the processing power problem because I could cut tangent lines that were .001" long and still produce a correct shape and a good finish. An interesting note, the control's screen (a Fanuc 10TF) would stop updating and appeared to be hung up while cutting the part but the machine continued to function!
By definition the first derivative of a function is the slope of the tangent line. Also, by the Power Rule of Calculus,
| If f(x) = xn, where n is a positive integer, then the first derivative of f(x) is nxn-1 |
Therefore, the first derivative of the function is
which can be rewritten as Z = .132(X). Remember, this is the slope of a line tangent to the curve at X, not an equation for the curve. The program has to make an X, Z move along this slope to approximate the curve. I used #510 as a variable for the Z axis distance to move so that I could experiment with different values, but in reality a value of .001 worked pretty well.
O8010(PARABOLA SUB)
(Z = .132*X 1ST DERIVATIVE)
#100=.5934 (START PT IN Z)
WH[#100GT.0081]DO1
#101=SQRT[#100*15.168]
#102=.132*#101
#103=[#510/#102]*2
G1U-[RO[#103]]W-#510F.01
#100=#100-#510
END1
M99
Here is an explanation of the program:
| #100=.5934 (START PT IN Z); | This is Z = X2/15.168 solved for a 3" radius. |
| #101=SQRT[#100*15.168]; | This is the equation rearranged to solve for X where X is #101 |
| #102=.132*#101; | This is the slope of the tangent at the current X value |
| #103=[#510/#102]*2; | This divides the RUN by the slope and multiplies it by two convert to diameter. Remember from algebra that the slope of a line is equal to the Run/Rise so we have Run/(Run/rise) which reduces to the rise. This is of course the change in the X axis based on the #510 (.001) change in the Z axis |
| G1U-[RO[#103]]W-#510F.01; | Incremental move in X and Z to actually cut the shape |
| #100=#100-#510; | Decrement the counter and start over |

The next figure shows an approximation of a parabola using tangent lines. This shape was made using .3 as the value for #510 which is 300 times larger than the value I used to machine the part and you can easily see a parabola outline.
A refresher on Parabolas
A Parabola is the set of all points in a plane equidistant from a fixed point F (the Focus) and a fixed line L (the Directrix) in the plane. The generic equation for a parabola with a vertex at 0,0 is Y2=4pX where p is the distance from the vertex to the focus and -p is the distance to the Directrix.
The parabola in the figure has the equation
. In this equation 4p = -6, therefore p = -1.5. The vertex is at X0, Y0, the focus is at X-1.5, Y0 and the Directrix is the line -p or X1.5. A line perpendicular to the Directrix intersecting the parabola is the same length as a line from the focus to the same point on the curve. This is represented as distance D in the figure.

In our part X2=15.168(Z) so 4p is equal to 15.168 or p=3.792. Therefore, the focus of the parabola is X0, Z3.792 and the Directrix is the line Z= -3.792". Any light ray or radio wave coming into the parabola would be focused at X0, Z3.792.
A Spreadsheet of Values
Here are some values calculated in MS Excel for the parabola in our example. I used this chart to spot check the program and sketch the parabola using tangent lines. The columns Angle + 270 and Angle + 180 are used to make it easier to draw the tangent lines in AutoCAD. For example, to draw a line .2" long with a slope of 2.65 degrees I would use the incremental line command @.2<272.65.
Radius | X2/15.168 | Slope of Tangent | Angle of Tangent | Angle + 270 | Angle + 90 |
0.350 | 0.0081 | 0.046 | 2.65 | 272.65 | 92.65 |
0.500 | 0.0165 | 0.066 | 3.78 | 273.78 | 93.78 |
0.650 | 0.0279 | 0.086 | 4.90 | 274.90 | 94.90 |
0.800 | 0.0422 | 0.106 | 6.03 | 276.03 | 96.03 |
0.950 | 0.0595 | 0.125 | 7.15 | 277.15 | 97.15 |
1.100 | 0.0798 | 0.145 | 8.26 | 278.26 | 98.26 |
1.250 | 0.1030 | 0.165 | 9.37 | 279.37 | 99.37 |
1.400 | 0.1292 | 0.185 | 10.47 | 280.47 | 100.47 |
1.550 | 0.1584 | 0.205 | 11.56 | 281.56 | 101.56 |
1.700 | 0.1905 | 0.224 | 12.65 | 282.65 | 102.65 |
1.850 | 0.2256 | 0.244 | 13.72 | 283.72 | 103.72 |
2.000 | 0.2637 | 0.264 | 14.79 | 284.79 | 104.79 |
2.150 | 0.3048 | 0.284 | 15.84 | 285.84 | 105.84 |
2.300 | 0.3488 | 0.304 | 16.89 | 286.89 | 106.89 |
2.450 | 0.3957 | 0.323 | 17.92 | 287.92 | 107.92 |
2.600 | 0.4457 | 0.343 | 18.94 | 288.94 | 108.94 |
2.750 | 0.4986 | 0.363 | 19.95 | 289.95 | 109.95 |
2.900 | 0.5545 | 0.383 | 20.95 | 290.95 | 110.95 |
3.000 | 0.5934 | 0.396 | 21.60 | 291.60 | 111.60 |