
Tips and Tricks for Custom Macro ProgrammingThe following tips have been included on this site to make your life as a macro programmer easier. If you have a tip that you would like included please E-mail it to the address below and we'll include it on this page. You can save this page as an HTML document and view it offline. In Internet Explorer click File, Save As... and give the document a name. - Not Enough Common Variables in your control?
- Abbreviations of Macro Commands
- Keyboard Macro for Okuma OSP5000 controls
- Checking the state of Cycle Start and Chuck Open on OSP Controls
- Verifying the Second Offset of a Grooving Tool on an OSP Control
- Clear a Range of Variables
- Return Mazak Z Axis to Home 2 without using G30
- Macro to automatically set tool lengths on a Mazak Mill
- Calibrating a Renishaw Probe's Tool Length
 - Calibrating a Renishaw Probe on a Machining Center
- Clearing Common Work Shift offsets before Probing
- Debugging a macro using DPRNT
 - Timing Tools on a Mazak
 - Using a probe to verify that a tilting table is at 90 degrees
 - Machining a Parabola on a lathe

Not Enough Common Variables in your control? (3/17/97) If you need more common variables than your control has you can use spare tool offsets in their place. For example, if you used #100 to store a value for use in your macro you could change this to #2064 and use tool offset 64 instead. This has the advantage on some controls that the operator can change the tool offsets even if "Program Edit" is locked and he can't change variables. I have used this technique on Mazak Multiplex lathes to share variables between heads.Return to Top of Page Abbreviations of Macro Commands (6/22/97) Depending on the control some macro commands can be abbreviated. For example you might be able to use RO in place of ROUND or WH in place of WHILE. You will need to experiment on your control to see which commands can be abbreviated but if you are short on memory (who isn't?) this might save enough to get you through.Return to Top of Page
Keyboard Macro for Okuma OSP5000 controls (9/24/97) Okuma allows you to read the state of various switches on the operator keyboard including Spindle Override, Feed Rate Override, Dry Run, Single Block, Auto Coolant and Optional Stop. You can take advantage of this to write a macro that checks the state of the keyboard when Cycle Start is pressed. I use this to make sure that the operator hasn't accidentally turned Dry Run on or forgotten to turn the coolant back on. If Single block is ON, the macro exits without checking the switches. Use the Check Data key on the control to see these inputs. Look under EC Panel Input for bits to change while you move the switches. To use the macro, paste this code into an editor and then send it to your OSP5000 control. It will be saved as O.SSB which is a System Sub Routine. To edit the macro on the control you will have to enter O.SSB instead of using edit *. To call the macro, insert CALL OALM in your machining program before each tool. $O.SSB OALM N1 IF[[VDIN[1128] AND 2] EQ 2] NEND(MACHINE LOCK) N2 IF[[VDIN[1138] AND 32] EQ 32] NALA7 (LOAD AUTO SET) N3 IF[[VDIN[1128] AND 1] EQ 1] NALA1 (DRY RUN ON) N4 IF[[VDIN[1128] AND 128] EQ 128] NEND (SINGLE BLOCK ON) N5 IF[[VDIN[1132] AND 2] EQ 2] NALA2 (FEED RATE OVER) N6 IF[[VDIN[1132] AND 8] NE 8] NALA2 (FEED RATE OVER) N7 IF[[VDIN[1132] AND 1] EQ 1] NALA2 (FEED RATE OVER) N8 IF[[VDIN[1132] AND 4] EQ 4] NALA2 (FEED RATE OVER) N9 IF[[VDIN[1132] AND 16] NE 16] NALA3 (SPINDLE OVER) N10IF[[VDIN[1132] AND 32] EQ 32] NALA3 (SPINDLE OVER) N11IF[[VDIN[1132] AND 64] NE 64] NALA3 (SPINDLE OVER) N12IF[[VDIN[1132] AND 128] EQ 128] NALA3 (SPINDLE OVER) N13IF[[VDIN[1126] AND 128] NE 128] NALA5 (AUTO COOLANT) GOTO NEND NALA1 VUACM[1]='DRY RUN IS ON' VDOUT[993]=1000 NALA2 VUACM[1]='FEED RATE NE 100' VDOUT[993]=1000 NALA3 VUACM[1]='SPINDLE OVERRIDE' VDOUT[993]=1000 NALA4 VUACM[1]='LOAD MONITOR' VDOUT[993]=1000 NALA5 VUACM[1]='COOLANT NOT ON' VDOUT[993]=1000 NALA7 VUACM[1]='LOAD AUTO SET' VDOUT[993]=1000 NEND RTS %
Note: For OSP5020 controls change line N5 to read N5 IF[[VDIN[1132] AND 2] NE 2] NALA2 (FEED RATE OVER) Okuma changed the state of the bit on the OSP 5020 for some reason. Return to Top of Page
Checking the State of Cycle Start and Chuck Open (9/24/97) Have you ever used M00 somewhere in a program to allow the operator to remove chips or inspect the part only to have him put the next part in and crash the machine? This macro will prevent that from happening. Instead of using an M00, the macro creates an indefinite loop that continues until Cycle Start is pressed or the chuck is opened. If Cycle Start is pressed the program jumps to N5 (or any line number you want) and continues. However, if the chuck is opened, because the operator forgot that he was at M00 and put a new part in, the program jumps to an alarm code and tells the operator to restart. NLOOP IF[[VDIN[1124] AND 2] EQ 2]N5 IF[[VDIN[1108] AND 2] EQ 2]NALA1 GOTO NLOOP N5G0X20Z20(NEXT TOOL IN PROGRAM) ...PROGRAM CODE ...PROGRAM CODE ... GOTO N9999 NALA1 VUACM[1]='RESTART FROM N5' VDOUT[991]=999 N9999 M02
To use the macro, insert it where you would normally have an M00. The lines NLOOP IF[[VDIN[1124] AND 2] EQ 2]N5 IF[[VDIN[1108] AND 2] EQ 2]NALA1 GOTO NLOOP do the actual work. IF[[VDIN[1124] AND 2] EQ 2] is true if Cycle Start is pressed and then execution jumps to line N5. Otherwise, IF[[VDIN[1108] AND 2] EQ 2]NALA1 checks to see if the Chuck open switch has been pressed. If so, execution jumps to the alarm. Be sure to put the alarm at the end of the program. You can use the Check Data key on the control to see the input for Chuck Open. Look under EC Panel Input for bits to change while you activate the chuck pedal. Return to Top of Page
Verifying the Second Offset of a Grooving tool on an OSP Control (11/25/97) Have you ever wanted to use two offsets for a grooving tool or turning tool but were afraid the operator would forget to set the second offset and crash the machine? Or worse, you did program for a second offset and the machine did get crashed. This macro shows how to read the offset of each tool and determine if the second tool is set correctly.
Notice that Okuma allows variables to have alphanumeric names. In this example, IDOF is set to the X offset of tool 7 and DOF is set to the X offset of tool 17. The variable names are arbitrary. The statement VTOFZ[17]=VTOFZ[7] sets the Z offset of tool 17 equal to the Z offset of tool 7. This is done because we are allowing for a small adjustment in the X axis but Z should be the same so this eliminates one more error source for the operator. The statement IF[DIF LT .015] NEND compares the X offset of tool 7 to tool 17 and exits if the difference is less than .015". In this example, the machining program was written on a CAM system that compensated for the width of the grooving too. That's why the difference between offsets is set at .015. If you don't compensate for the width of the tool in the machining program you will have to add the width of the tool to the .015. This makes the code less generic because you have to change it for each different width of insert but it still works. You can also use the same concept for turning tools and boring bars. For example, if a part has a close diameter with a relief in the middle you might want to have two offsets to compensate for taper in the machine. Use this type of macro to be sure the operator doesn't forget to set the second offset. - (FACE GROOVE TOOL)
(SET THE TOOL OFF OF THE O.D.) (OFFSET #7 WILL CONTROL THE HUB DIA.) (OFFSET #17 WILL CONTROL THE ID) G14 IDOF=VTOFX[7] DOF=VTOFX[17] VTOFZ[17]=VTOFZ[7] DIF=ABS[IDOF-DOF] IF[DIF LT .015] NEND NALA1 VUACM[1]='GRV TOOL NOT SET' VDOUT[992]=999 NEND
Return to Top of Page
Clear a Range of Variables (11/24/97) This loop will clear common variables 100-149. Change #1=100 to the starting variable if you want to clear a different range. It is common practice to clear a range of variables before using them to guarantee that you start with Vacant values. #1=100 WHILE[#1LE149]DO1 #[#1]=#0 #1=#1+1 END1 Return to Top of Page
Return Mazak Z Axis to Home 2 without using G30 (11/24/97) This code will return the head of a Mazak mill to the home 2 position without using G30 during probing. Modify the line #592=#5223+[#591-.0315] to fit the particular machine. In this example, the head is at home 2 (G30) when the Z machine position is -.0315. This example works in the G54 coordinate system. If you are using a different coordinate system change #5223 to the appropriate value. For example, G55 would use #5243, G56 #5263, G57 #5283, G58 #5303 and G59 #5323. (POSITION HEAD TO HOME 2) #590=#5223 #591=#[60000+#549] #592=#5223+[#591-.0315] G65P9810Z-#592F100. Return to Top of Page
Macro to Automatically Set Tool Lengths on a Mazak Mill (12/7/97) This simple macro automates setting tools on a Mazak mill with a tool eye. The operator enters the starting tool number to be set in #537 and the ending tool number in #538. You could change #537 and #538 to a variable for a tool number if that would be more convenient. For example, change #537 to #2064 to use tool offset 64 instead of macro variable 537. You will need to edit the line IF[#537GT29]GOTO100 to equal the number of tool in your machine. This machine had a 30 station tool changer but station 30 is dedicated to a Renishaw probe. % O9103 (SET TOOL LENGTHS) (#537=STARTING TOOL NUMBER) (#538=ENDING TOOL NUMBER) G0G91G30Z0 G0G91G30Y0 IF[#537GT#538]GOTO101 IF[#537GT29]GOTO100 IF[#538GT29]GOTO100 WHILE[#537LE#538]DO1 T#0T#537M6 T#537T0M6 M196 T#537 M197 G0G91G30Z0 G0G91G30Y0 #537=#537+1 END1 GOTO102 N100#3000=1(#537 IS TOO LARGE) N101#3000=1(#537 GREATER THAN 538) N102 G0G91G30Z0 G0G91G30Y0 M30 % Return to Top of Page
Calibrating a Renishaw Probe's Tool Length (12/23/97) This program uses two variables, #537 and #538, to position the probe in X and Y and then calibrates the probe's tool length. An approximate tool length Offset must be entered for the probe before running this program. Using variables to position the probe makes the program very flexible. Simply move the machine to the point where you want to touch the stylus and look at the position display. Enter these values for #537, #538 and run the program. You will need to edit T60 to match the tool number of your probe. % O9102 (SET PROBE TOOL LENGTH) (#537=X POSITION TO TOUCH) (#538=Y POSITION TO TOUCH) G0G91G30Z0 G0G91G30Y0 T60T0M6 #5203=0(CLEAR COMMON Z) G0G90G54X#537Y#538 G65P9810Z2.0F200.0 G65P9801Z0T24 G65P9810Z2.0F200.0 G0G91G30Z0 G0G91G30Y0 M30 %
Return to Top of Page
Calibrating a Renishaw Probe on a Machining Center (11/28/97) A spindle mounted probe can be one of the best tools you'll ever buy for increasing productivity but keeping it calibrated or calibrating after breaking a stylus (a rare event of course) can be a pain. Using the program and fixture in this tip makes calibrating a simple task that can be done in a few minutes. This example calibrates the probe's stylus offset and diameter. The probe's tool length offset must be calibrated before using this example. The first step is to purchase a 1.000 ring gage that can be dedicated to the fixture. Next, decide how the fixture can be mounted to the machine quickly and easily. The fixture in the figure is held in a three jaw chuck on one mill, bolts to a sub-plate on another mill and bolts to a two axis tilting table on another. The key feature is that it can be mounted quickly and without major problems. 
In the figure, the ring gage is held down on the left side of the fixture and a replaceable aluminum plate is held on by two cap screws in the center. To calibrate the probe a boring bar is used to bore a hole in the plate at X0Y0. This establishes an exact center to set the stylus's X, Y offset. When the bore gets too large simply throw the plate away and make another one. To calibrate the probe, a G54 coordinate system is established and then the top of the plate is probed to set an exact Z0, and the bore is probed to set an approximate X0, Y0. Next, the boring bar opens the bore up to establish the exact X0, Y0 of the plate. Make sure that the bore was completely cleaned up by the boring bar. The probe is then positioned over the plate and the bore is probed using the standard Renishaw 9802 cycle. Next the ring gage is probed using 9804 Vector calibration. The whole cycle should only take a few minutes and when finished the probe is calibrated for stylus offset and stylus diameter. In this example, G54 X, Y, Z are preset in the program using the code #5221=-9.1607 #5222=-6.8235 #5223=-21.7230
The code #5203=0(CLEAR COMMON Z) is an important safety feature that you should include in all probe programs. If the operator had put an offset in the Z axis common work shift and then runs the probe, the offset is added to the coordinate system and the probe will error. However, if the operator notices the offset, presses Slide Hold, clears the offset and then presses Cycle Start the machine will rapid the amount of the offset and wont be in protect position mode. In any event, this one line of code will prevent wasted time. You will have to use values that fit the location of your fixture. Presetting the coordinate system like this removes the operator from the setup and eliminates the risk of a crash and the lost time indicating the fixture. The probe is tool 19 in this machine. You'll have to edit the tool change to fit your particular machine. Here's the program: % O0621 (CALIBRATE PROBE STYLUS) (BORING HEAD IS USED) (TO ESTABLISH AN EXACT) (X0Y0 BEFORE CALIBRATING) G91G30Z0 G91G30Y0 T19T0M06 #5221=-9.1607(SET G54 X0) #5222=-6.8235(SET G54 Y0) #5223=-21.7230(SET G54 Z0) #5203=0(CLEAR COMMON Z) G0G90G54X1.4Y0 G65P9810Z1.F100. G65P9811Z0S1(UPDATE G54 Z0) G54 G65P9810X0Y0 G65P9810Z-.25 G65P9814D1.5S1 G91G30Z0 G91G30Y0 M01 N2(BORING HEAD) G91G30Z0 G91G30Y0 T1T19M06 S1500M04 G0G90G54G95X0Y0 G0Z1.0M08 G89Z-.6R.1F.004 G91G30Z0M9 G91G30Y0 M00 (BLOW OFF CHIPS) N3(PROBE) G91G30Z0 G91G30Y0 T30T0M06 G0G90G54G94X0Y0 G65P9810Z-.25F100.0 G65P9802D1.5 G65P9810Z2.F100. G65P9810X-2.775Y0F200.0 G65P9810Z-.55F100.0 G65P9804D1.0000 G65P9814D1.000 G65P9810Z2.F200.0 G91G30Z0 G91G30Y0 T01T0M06 M30 % Return to Top of Page
Clearing Common Work Shift Offsets before Probing (11/28/97) Have you ever been called to the shop to troubleshoot a probe routine only to find out the operator had put an offset in the Z axis Common Work Shift when he proofed the machining program and forgot to remove it? You can add one line of code in your probe programs to prevent this problem. The code #5203=0(CLEAR COMMON Z) is an important safety feature that you should include in all probe programs. If the operator had put an offset in the Z axis Common Work Shift and then runs the probe, the offset is added to the coordinate system and the probe will probably error because it will miss the part. However, if the operator notices the offset, presses Slide Hold, clears the offset and then presses Cycle Start the machine will rapid the amount of the offset and wont be in protected positioning mode. In any event, this one line of code will prevent wasted time. To use this tip insert #5203=0(CLEAR COMMON Z) before calling G54 and positioning the probe to the part. Also, don't put this code in the machining program. If the operator expects the tool to position above the part and you have cancelled his Z axis Common Offset a crash can occur. Return to Top of Page
Debugging a macro using DPRNT (12/23/97) Sometimes debugging a large macro program can be difficult. You're trying to look at the program screen, position data and see what value your variables are set to. I use this small macro to dynamically output the value of variables to a computer connected to the machine tool. If you use a terminal program like Windows terminal you can see the data as it is received. To use this macro put an M98P626 in the program you're debugging anywhere you want to check the value of variables. Of course you will need to modify the macro to output the variables you are interested in but you get the idea! % O626 POPEN DPRNT [V154**#154[24]***V156**#156[24]***V158**#158[24]] DPRNT [V160**#160[24]***V162**#162[24]***V164**#164[24]] DPRNT [V168**#168[24]***V170**#170[24]***V172**#172[24]] DPRNT [V174**#174[24]***V176**#176[24]***V178**#178[24]] DPRNT [V180**#180[24]***V182**#182[24]***V154**#184[24]] DPRNT [V186**#186[24]***V188**#188[24]***V190**#190[24]]] DPRNT [G54*X**#5221[24]***G54**Y**#5222[24]***G54*Z**#5223[24]] DPRNT [G55*X**#5241[24]***G55**Y**#5242[24]***G55*Z**#5243[24]] DPRNT [G56*X**#5261[24]***G56**Y**#5262[24]***G56*Z**#5263[24]] DPRNT [G57*X**#5281[24]***G57**Y**#5282[24]***G57*Z**#5283[24]] DPRNT [G58*X**#5301[24]***G58**Y**#5302[24]***G58*Z**#5303[24]] PCLOS M99 %
In this example, DPRNT [V154**#154[24]***V156**#156[24]***V158**#158[24]], the value of variable #154 is output with 2 places before the decimal and four after. V154 is output before the value of #154 for readability. In this example, DPRNT [G54*X**#5221[24]***G54**Y**#5222[24]***G54*Z**#5223[24]], the value of G54 X is output with 2 places before the decimal and four after. G54 X is output before the value for readability. Here is a sample of the output from the macro: % V154 0.4060 V156 0.1051 V158 0.0272 V160 0.4800 V162 0.1015 V164 2.0235 V168 71.4336 V170 6.3552 V172 46.4336 V174 -5.2954 V176 3.5138 V178 0.5109 V180 1.8244 V182 73.1520 V154 6.2947 V186 48.1520 V188 3.5138 V190 0.0000 G54 X -12.9893 G54 Y -8.0718 G54 Z -16.9907 G55 X -12.9893 G55 Y -13.3672 G55 Z -19.1225 G56 X -12.4784 G56 Y -13.3672 G56 Z -19.1225 G57 X -12.9755 G57 Y -13.3672 G57 Z -19.1225 G58 X -13.5002 G58 Y -13.3672 G58 Z -19.1225 %
Return to Top of Page
Timing Tools on a Mazak (12/23/97) Have you ever wanted to compare the time your CAM system says a tool will take to the actual time it takes on the machine? Don't stand around with a stop watch, this simple macro will do it automatically. At the beginning of the tool you want to time add #3001=0 to reset the machine's timer to 0. Then add M98P9100 to the end of the tool. The macro will put the time for the tool in variable 510 plus the tool number. For example, the time for tool 1 will be stored in #511. This macro is useful if you embed it into your CAM system's post processor and output it as part of the CNC program. % O9100 #2=#51999(ACTIVE TOOL) #100=#3001(TIMER VALUE) #100=#100/1000 #[510+#2]=#100(WRITE TIME) M99 %
Return to Top of Page
Using a probe to verify that a tilting table is at 90 degrees (12/23/97) If you have a CNC tilting table on your mill you have probably overloaded it and caused it to move off location. This macro uses your spindle mounted probe to verify/set the table to 90 degrees. This macro verifies that the current G55 X, Y and Z values are appropriate before probing. This is done to prevent damage to the probe if the coordinate system is set wrong. You will need to modify the values in the macro to fit your machine's configuration but the effort is worth it if it prevents one crash of the probe. For example: IF[ABS[#5241+32.984]GT.2]GOTO997 checks to see if G55 X is within .2 of 32.984 which is the X center of the tilting table. If the coordinate system has been changed by more than .2, the macro will jump to an error message. Change 32.984 to match the table on your machine. T30 is the tool number of the probe, modify it to fit your application. This table has a rotary and a tilt axis and the tilt axis is programmed as the B or 5th axis. The macro uses #5245=#5245-.5 to force a .5 degree error in the table's tilting axis. This is so that I'm not doing trig on very small values. Most machine control's recommend against using trig functions on very small values. In this example, Z zero is the center of rotation of the table and the probe uses Z values that are 2" apart. This program typically sets the table to within a couple tenths in 2 inches. % O606 (THIS PROGRAM CHECKS ROTARY AT 90 DEG.) G90 G40 G80 G17 G95 G91 G30 Z0. G30 X0. Y0. G90 G00 G55 B0.0 G90T30T0M6 IF[ABS[#5241+32.984]GT.2]GOTO997 IF[ABS[#5242+8.760]GT.2]GOTO998 IF[ABS[#5243+21.4967]GT.2]GOTO999 (FORCE .5 DEGREE OF ERROR IN B) #5245=#5245-.5 #5201=0(CLEAR COMMON X) #5202=0(CLEAR COMMON Y) #5203=0(CLEAR COMMON Z) (X4.332 IS FACE OF ROTARY) G0G90G94G55X6.432A0B90. G0Y0 G65P9810Z7.630F200. G65P9810X4.582F200. G65P9811X4.332Q.25 #100=#135 G65P9810Z5.630F100. G65P9811X4.332Q.25 #101=ATAN[[#100-#135]/2] (#101 IS THE ERROR VALUE IN B) #5245=#5245-#101 G91G30Z0 G91G30X0Y0 GOTO1000 N997#3000=1(G55 X SET WRONG) N998#3000=1(G55 Y SET WRONG) N999#3000=1(G55 Z SET WRONG) N1000M30 % Return to Top of Page
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 |
Return to Top of Page
|