Wednesday, September 30, 2009

About Bleier CNC Training

My special expertise is training operators at the machine making commercial workpieces. In recent years I have been doing mostly 5-axis aerospace machining and 5-sided machining for heavy equipment manufacturing. I do the Siemens 840D and the members of its family (840Di, 810D & 802D).

Foreign builders of machines imported into the U.S. and Canada would benefit greatly from my services since . . .

  • English is my native language.
  • I understand the sensibilities of U.S. operators.
  • I can prepare cycles (macros)
  • I am experienced with Siemens measuring cycles
  • I can do minor engineering tasks (PLC edits, machine data changes, etc.)

I am an accomplished lecturer and presenter with years of classroom teaching experience. Because of the latter mostly, I know how little the operator takes from the class to the machine. This is why I prefer to do training at the machine in the process of making commercial workpieces.

My posts, on the other hand, are for programmers and advanced CNC workers. I write from the perspective of a "scientific" CNC worker. Hopefully, I have achieved success in crafting high level explanations for people who do not have degrees in math, science or technology. I am aware that simply understanding CNC at an advanced level does not necessarily translate into greater margin because servo optimization has a great deal to say about cycle time, surface finish and accuracy.

If the machine's servos have not been carefully optimized, you are left to experiment for a combination of functions and features for best results. You might find that it is six of one and half a dozen of another. If your servos have been carefully optimized by an experienced mechatrician then the mechatrician is often the one who can best tell you what combination to use. In saying this I do not want to short shrift my own services in training programmers about the high speed and 5-axis features of the 840D. It can empower the programmer to make sense about what he has and what people are telling him.

Email me BleierCNCTraining@gmail.com or call me (847) 917-8145 if I can be of service to you

Wednesday, August 26, 2009

Exact Stop Mode G60 / Exact Stop Check G601 & G602

G60 G601 is exact stop with fine in-position check
G60 G602 is exact stop with coarse in-position check
G60 G603 is exact stop without in-position check

G60 tells the CNC to decelerate the axes to a stop at block boundaries. G601, G602 and G603 define conditions that must be met before the CNC moves on and begins to execute the next motion block.

You would program G60 when you want sharp corners. You would program G60 (or G09) in drilling because you want the tool to get to final depth before the drill pulls out.

Following error - the difference between the actual position of the axes and the commanded position - is a property of CNC's proportional position control. When the CNC gets to the block end point in its processing of the geometric data, the axes are shy of this position by following error.

-------------------------------------------------------------

G60 is the modal exact stop mode and G09 is the non-modal exact stop mode.

G60 is the default member of group 10 that includes G60, G64 and G642 to G644.

G09 is in group 11.

You can change the G60 default to G64 by putting a "2" in MD 20150 $MC_Gcode_Reset_Value[9]. (The index is one less than the group number.) Put in a "3" and you have changed the default to G642.

It is important to know that exact stop is one thing and exact stop check is another, subordinate thing. We will see that not all exact stops require an exact stop check.

G60 is like driving a car and having to stop at ever intersection and at every point where the road blends from a straight away into a curve and vice versa.

In the exact stop mode the axes are decelerated by the CNC as they approach the block end point so at least in the mind of the CNC they are stopped (at stand still) when they get to this point. If asked, the numerical control does an in-position check and if the axes are within a prescribed tolerance of the end point the CNC moves on and begins execution of the next block.

Following error is the primary reason the axes could be out of the in-position tolerance when the CNC has consumed the interpolation function of the current block. However, before discussing following error, lets clarify how we ask the CNC to do an in-position check and the in-position tolerance.

There are two in-position tolerances called coarse and fine. These tolerances are set in the following machine data:

MD36000 $MA_Stop_Limit_Coarse
MD36010 $MA_Stop_Limit_Fine

The coarse default is 0.0016" (0.04 mm).
The fine default is 0.0004"

There is also MD36012 $MA_Stop_Limit_Factor (default is "1") that one expects is a scale factor on the coarse and fine in-position tolerances although the Siemens manual does not say this explicitly.

(The problem with the manuals not saying what they mean explicity in the technical language of science and technology - mathematics - is that the same text explanation could apply to any number of situations when words are not chosen carefully and when the writer does not know the cultural and technical sensibilities of his readers.)

If in fact, Stop_Limit_Factor is a scale, if this MD is set to "2", the in-position tolerances is double. This could be useful when machining workpieces that are at the upper end in mass for the specifications of the machine provided inspection can accept the consequences of a larger in-position tolerance.

G60 G601 commands the CNC to do an exact stop fine in-position check.

G60 G602 commands the CNC to do an exact stop coarse in-position check.

There is also G60 G603. G603 is a cancelation of exact stop check. G603 does not do an in-position check following deceleration of the axes to commanded stand still. Rather, after the CNC has consumed the interpolation function of the current block, it begins consuming the interpolation function of the next block.

G603 could result in a rolling stop which would be similar to G602 with very large in-position tolerances because residual following error keeps the axes moving.

Following error is a servo concept. The CNC samples the interpolation function on a time grid to issue incremental setpoints to the position servos. The servo algorithm used by CNC is proportional position control.

If you read a massively heavy volume on control theory you will find near-nothing on proportional control because is it so basic that authors feel it is spontaneously understood. With proportional control, in order to get go, there must be a difference between where the controller has commanded the position servo to be and where the position servo actually is at. This difference is called following error. Internally, within the position control loop, the velocity command to the servo drives is . . .

velocity_command = position_control_gain * following_error

(Clearly the position control gain has to have dimensions of per time since velocity is length over time. Per time is called inverse time and it is usually inverse seconds. A gain of "1" is 16.67 inverse seconds. A gain of "1" produces 0.0010 inch of following error at 1 inch/minute feedrate. There is 0.100" following error at 100 in/min. High gains result in less following error but high gains require more rigid axes which is one reason high speed machines are more expensive.)

When the rate at which the position control loop receives position feedback is equal to the rate at which the CNC issues new position commands, the following error remains constant. Once the CNC has consumed the interpolation function of the current block it no longer issues incremental position setpoints, not until it can move on and begine to consume the interpolation function of the next block. However, there is still following error in the system and this following error results in a velocity command. It is like pulling a wagon with a bunji cord. The stretch in the cord is the following error of this system. When you stop walking, there is still stretch. However, wait a bit, and the stretch will cause the wagon to come along until there is no stretch (maybe a little because of friction but lets assume there is none).

When the position control gain is low and the feedrate is high the following error is considerable. This is why, if you cannot tolerate large corner contours due to following error, first you want the CNC to command the axes to a stop at the block end point and even then, you want to make sure that the residual following error has been worked out so that it is not just in the mind of the CNC that the axes are at their end point but they actually are at their end point. The latter is what the end position check is all about.

Some CNC workers have problems with an exact stop check that is not exactly exact. Get over it. We do not machine to exactness. We machine to tolerance.

Tuesday, August 25, 2009

Continuous Path Control & Look Ahead

G64 turns on Look Ahead and so does any one of G641 to G645. These preparatory functions are called continuous path control.

Continuous path control is a broadly defined concept that includes Look Ahead and a number of functions that are subordinate to it. However, Continuous Path Control and Look Ahead are the same thing from the point of view of the programmer and operator.

Look Ahead seeks to achieve a smooth, continuous velocity along the interpolated path, trying as much as possible to hold the velocity constant at the programmed feedrate without exceeding the dynamic limits of the axes. When the dynamic limits would exceed the programmed feedrate the axes have to slow down much like a car slows down to take a turn at an unprotected intersection.

To continue with the car analogy, Look Ahead can be compared to driving a winding road in hill country with radar vision. Since you can see ahead you do not have to stop to see if the road is washed out over the next hill.

Look Ahead is turned off with G60. G60 is called the exact stop mode. It is like stopping for stop signs at every intersection.

Continuous path control needs Look Ahead to do its thing. Its thing is to smooth corners while keeping the path velocity as close to the programmed feedrate as possible. In the main, it accomplishes this by inserting rounding blocks at corners and by limiting velocity and acceleration so the axes do not flutter at block transitions.

The rounding blocks that span the corner to "connect" two contour elements smoothly are akin to the wedges used by picture framers to hold the corners together. These wedges are called splines. Thus, spline is my prefered term for the inserted rounding block that connects two contour elements. Coincidently, the contour of the rounding block is a polynomial produced by the 840D's b-spline algorithm. Thus it is more correct to talk about inserting a spline block at corners as opposed to a rounding block since the inserted path is not the arc of a circle. However, Siemens documentaion calls them rounding blocks and so will I.

Back to G64 & G641 - G645 and Overload Factor versus Compressor Tolerance . . .

The Overload Factor is a machine data setting. It is used by the 840D to limit the step change in velocity at a corner. I will discuss the vector diagram later that illustrated how there can be a step change in velocity at a point while the velocity remains constant. For the time being . . .

If the step change at the programmed feedrate exceeds the maximum allowable step change of the Overload Factor equation (discussed later), the 840D decelerates into the corner so that when the tool enters the corner the servos can accomplish the step change and thus, the change in direction, in one period of the interpolation cycle.

The formal Siemens documentation does not say that the corner is actually commanded to be taken in one cycle. To compound the matter, the one cycle change in direction cannot be conclusively inferred from the definition of the Overload Factor because at other places in the documentation Siemens implies that a rounding block is inserted in the corner. My attempts to get clarification on this have not addressed the contradictory nature of the documentation. Thus, when I write that with G64, corner smoothing is a consequence of residual following error I am not 100% confident that this tells the whole story.

Uncertainty with regards to G64's precise behavior is not a burning issue for most programmers. However, for people who seek to be problem solvers, an in-depth understanding of any detail of CNC is often a lever to understand other details that don't have a legacy of practice to give us confidence that it works even if we do not fully understand why.

There is no uncertainty in the documentation with regards to the 3-digit G64x and especially G642, the one must used. Corner smoothing is achieved by inserting a rounding block between two blocks whose intersection is a corner. The block must pass within the Compressor Tolerance of the corner point. Like the Overload Factor, the Compressor Tolerance is a machine data setting that I discuss in my post on Cycle832. I also discuss the Compressor Tolerance in my Directory of Terms. If you have the wherewithal to read my posts you should definitely email me BleierCNCTrainin@gmail.com for an e-copy.

You would typically use G64 for 2 ½ machining and G642 for high speed kellering and 5-axis aerospace contouring. Your machine tool builder may advise you differently since there are slight differences between individuals of the 3-digit group.

Siemens recommends you use G642 with CompCurv and CompCad. This recommendation needs elaboration since CompCurv/CompCad are themselves smoothing functions. So, here we go . . .

CompCurv/CompCad are b-spline algorithms that act on short G01 blocks to produce one polynomial block out of a sequence of G01 blocks (typically 5 to 10 G01 blocks in the sequence). This one block blends tangentially with the the polynomial block produces by the next sequence of G01 blocks and on and on. As a consequence of this tangential blending there are no corners. However, there can be corners when the algorithm temporarily suspends doing its thing at an intersection point where the next block is very long or the next block is not a G01 block. In this case the intersection between the most recently produced polynomial block and the the next block could be a corner and G64/G642 (whichever you use) would do its thing at this corner and any subsequent corners until CompCurv/CompCad resume producing polynomial blocks.

By default, a long G01 block is longer than 20 mm (0.7874 inches).

The best recommendation regarding G64 or G642 (or another member of the 3-digit G-codes) should come from your machine tool builder because he is the one who knows how the servos were optimized.

If your machine tool builder is no longer in the picture, or heavens forbid, he doesn't know, you may be left with trial and error to discover what works best. In this case, you may find my additional discussion below useful.

---------------------

Newtonian mechanics is part of a deeper discussion of continuous path control since CNC moves masses. It moves masses with servos. Servo is about negative feedback to control the position, velocity and acceleration of masses. With regards to servos it is probably sufficient to say that servo optimization consumes some choices. For example, if your axes have been optimized with Feed Forward turned on, whether you machine with FFWON or FFWOF is a choice that has already been made; you must always machine in FFWON.

About G64 . . .

The people who developed the 840D decided that the Overload Factor would be used to limit velocity steps at corners when G64 is active.

To understand velocity steps we need to recall that velocity is a vector with magnitude and direction. With G64, only the direction changes at corners. However, even a directional change results in a change in velocity as illustrated in the vector diagram below where the length of arrows Vin and Vout is the same. The velocity change is the ΔV arrow.




If the feedrate into and out of an intersectional point at the corner of two linear blocks is 100 in/min, the magnitude of the change in velocity at a 90 degree corner is 141.4 in/min (the square root of the sum of the squares). This is a step change in velocity since it occurs at the point. Keep in mind that the 141.14 is not the velocity at the point but rather, the change in the velocity vector at the point.

ΔV is also called the velocity jump and velocity step.

ΔV is limited according to the following equation:

ΔV <= axis_acceleration * (overload_factor-1) * IPO where

axis_acceleration is the linear acceleration of the least dynamic axis of the axes involved in the path interpolation. The axial linear acceleration is in MD32300 $MN_MAX_AX_ACCEL.

overload_factor is a value set in machine data 32310 $MN_Max_Accel_Ovl_Factor

IPO is the period of the interpolation cycle

The interpolation cycle is called the IPO (pronounced with long ee-PO) and just as often IPO means the period of the cycle. Ball park periods are 2 milliseconds for high speed machines and 4 milliseconds for machines with serious ambitions for high speed. Lets suppose it is 4 milliseconds. Every 4 milliseconds the CNC samples the interpolation function to output an incremental set point to the position control servos.

We get acceleration when we divide both sides of the equation by IPO, and since IPO is a scalar, this acceleration is in the direction of the ΔV vector.

ΔV/IPO <= axis_acceleration * (overload_factor-1)

This acceleration - the consequence of a step increase in thrust impressed on the load through the drive linkages and originating from a rapid increase in torque from the motor - acts for one IPO.

The default setting for the Overload Factor is 1.2. In this case, the acceleration ΔV/IPO is 20% of the linear acceleration of the least dynamic axis.

To be sure, an infinite acceleration would be required for the direction to change at a point. However, the change can occur on a dime because a dime has a radius. The radius of the dime is the travel that can occur in the time of one IPO at the feedrate of the tool when it enters the dime.

[To my international readers, a dime is smaller in size than the U.S. penny. Its value is 1/10 of a dollar. In the U.S. we say that a car cannot stop on a dime.]

To return to the 100 in/min example, if the interpolation period is 4 milliseconds, the ΔV/IPO acceleration is 589.25 in/sec2. This is 1.53G since 1G is 386.0892 inches/sec2. If the corner is actually taken at a feedrate of 100 in/minute, the X and Y servos must be able to accelerate the X and Y axes at 1.08G and the CNC must be told that it can do its calculation on the assumption that the axes can accelerate/decelerate at 1.08G without going unstable.

If the axes cannot accelerate/decelerate simultaneously this quickly, the CNC must decelerate into the corner so that its velocity at the start of the interpolation cycle wherein the change in direction will occur is small enough so that ΔV of the equation is not exceeded.

The Siemens manual says that G64 takes corners at a constant velocity. This means the magnitude of the velocity out of the dime is equal to the magnitude into the dime. Having come out of the dime the axes accelerate back to the programmed feedrate.

To return to the acceleration of the vector diagram – ΔV/IPO – this acceleration is a consequence of the thrust generated by the servos. If linear motors are used, the thrust is generated directly by the interaction of magnetic fields. If rotary motors are used, mechanical linkages convert motor torque into thrust. Typical linkages are ball screw & ball nut and rack & pinion.

[The servo drives must be able to generate changes in linear motor thrust or rotary torque in much shorter time periods than the IPO. The torsion wave must be able to travel smoothly through the drive linkages.]

The acceleration – ΔV/IPO – is lateral acceleration. Lateral acceleration is sideways to the motion.

When you drive a car quickly along a tight radius, your inertia keeps you moving in a straight line. The door collides with you and pushes on you. This push is the force that produces the lateral acceleration that keeps you with the car. Of course, in a real world situation, some of the lateral force is from the contoured seat back, the seat belt and the static friction between your bottom and the seat. Still, if you go fast enough and the car stays on the curve these contributions may not be enough to prevent the door from smashing into you.

Physicists use the term centripetal acceleration for lateral acceleration. Your science teacher may have called it centrifugal acceleration. Your teacher was wrong. The force that keeps a mass on a curve is inward acting and centripetal is the term that names the acceleration that is a consequence of this.

Back to CNC axes . . . , the lateral acceleration is a fraction of the linear acceleration and this fraction is determined by the Overload Factor that has already been mentioned. An Overload Factor of 1.2 means that the limit on lateral acceleration is 20% of the linear acceleration of the least dynamic axis of the axes involved in the path interpolation. Thus, if the least dynamic axis is limited to 0.5G of linear acceleration, the lateral acceleration is limited to 0.1G.

However, ΔV is limited, not ΔV/IPO. The CNC uses the 0.1G to calculate an upper bound for feedrate and if this upper bound exceeds the programmed feedrate the CNC decelerates the axes into the corner so that when the last IPO of the interpolation function is due, the feedrate into the dime is <= the upper bound.

The Overload Factor is a machine data setting that is established when the servos are optimized. The factor is a compromise between cycle time and surface finish. If the factor is too high for the rigidity of the mechanical elements the axes will flutter at corners (same as saying "oscillate at corners") and this will be recorded in the surface finish. The Overload Factor can be higher for roughing if the flutter is not so severe that it degrades the mechanical rigidity of the linkages.

Ideally, the machine tool builder employs Cycle832 to set the Overload Factor for the mode of machining (roughing, semi-finishing, finishing).

The servos may be able to drive the tool into a change of direction that is greater than our example 0.1G. However, the mechanical linkages may not be able to withstand the inertial forces that this produces. In other words, the axes are not rigid enough. They will tend to flutter and degrade the surface finish. Engineers who do servo optimization have software tools that reside in the CNC to observe the behavior of the axes and determine an optimum value for the Overload Factor.

To repeat what has already been said, if the velocity step to take the the next corner exceeds the maximum velocity step derived from the Overload Factor, the CNC must decelerate the tool along the interpolated path as the tool approaches the corner so that when the interpolation cycle comes due to make the change in direction, the magnitude of the feedrate is reduced so that the velocity step stays within bounds.

If the Overload Factor is set to "1" the allowable step change in velocity is "0". In this case, the CNC must bring the path axes to a stop at corners and G64 appears the same as G60.

With regards to G64 at tangential intersections, the intersection between two blocks is not a corner when the geometric elements blend together tangentially such as a line meeting the arc of a circle tangentially. There is no step change in velocity at a tangential intersection so the Overload Factor is not at play here. However, there is a step in lateral acceleration since lateral acceleration is always required to achieve curved motion. Unless there is another scheme to limit this acceleration the servos get on with doing what they do without constraints. The shock of this step can cause flutter that gets recorded in the surface finish.

For the record, G643 employs the Overload Factor to limit lateral steps in acceleration at tangential intersections.

By the way, a linear acceleration of 0.5G is very dynamic. The upper limit on mechanical drive systems for small machine tools is roughly 2G but normally, accelerations of this magnitude require linear motors.

By the way again: A "G" is the acceleration of gravity at the Earth surface. It is 9.8067 meters/second per second. It is 32.1741 feet/second per second.

About G642 . . .

G642 does smoothing by inserting a rounding block (b-spline) at the corner. The path must pass within the so-called Compressor Tolerance of the corner. The easiest way to set the Compressor Tolerance is with Cycle832 discussed in another post.

Monday, August 3, 2009

Alike and Different: CNC and Siemens CNC

I have continued to develop the draft of the booklet Alike & Different since retiring from Siemens.

The booklet was written for Fanuc programmers to learn Siemens.

The booklet reflects my experience in 5-sided machining (with attachment heads) and 5-axes aerospace machining.

If you would like an e-copy of the most recent draft, email me . . .

BleierCNCTraining@gmail.com.

The booklet does not say much about turning so I will state my essential contribution regarding lathes here . . .

CNC is always right handed. Right handedness does not recognize turrets. It doesn't matter if the turret is front or rear (or no turretl), CNC is right handed. Blueprints, on the other hand, can be left handed and VTL blueprints frequently are. In this case, view the blueprint from the back and program from this perspective. As a general rule, if you program all your lathes from the perspective of a right handed blueprint, the program will run perfectly well regardless of the location of the turret. The same is true for setting the tool orientation in the D-code. A tool that does OD turning and facing is a "3" setting no matter if the machine is front or rear.

Directory of Terms for Siemens 840D CNC Users

I have continued to develop the Directory since my retirement from Siemens.

Email me for a copy BleierCNCTraining@gmail.com.

The Directory is over 140 pages. My goal is to transform it into an encyclopedia of 840D CNC primarily for programmers and operators. Whenever I learn something new that I think is important to programmers and operators (or whenever I discover that something I have written needs to be modified) I tend to do this first in the Directory before updating the drafts of other materials I have written. So, of all my materials, the Directory might be most contemporary. Of course, I update my posts but my posts are not as extensive as the Directory.

Thursday, July 30, 2009

Cycle997 to Measure Tooling Balls

Cycle997 for 840D CNC by Siemens is a standard Siemens measuring cycle to probe tooling balls to find their ball centers. Cycle997 can probe three tooling balls and calculate an error frame that when added to the currently active frame will align the G54 system (or the one you use) to the workpiece as it sits translated, out of square and cocked in the work envelop of the machine.

The example of this post is from an aerospace shop where the workpiece came to our machine with 4 tooling balls with documentation regarding their ideal locations from a previous operation on a different machine. We indicated one of the balls with a mechanical probe and scratched a zero offset into G54.

The first Cycle997 in the program below measures this ball for more precise G54 determination.

The second Cycle997 measures 3 of the 4 balls to align G54 to the workpiece as it sits out of square and cocked in the work envelop of the machine.

In our first run of the program the probe missed a ball by a hair. We picked a different set of 3 and did fine. Alternatively, we could have fudged the diameter of the balls by making _setval slightly less than 0.5”.

%_N_Job1942_MPF
N05 T9999 M06 ;touch probe
N10 Jog_spin ;sub to jog spindle to turn on probe
N15 TRAORI
N20 G00 G70 G54 Z30 D1 ;establish an initial level
N25 _mvar=119 ;measure a single ball for G54 determination
N30 _setval=.5 ;diameter of tooling ball
N35 _setv[0]=-70.7904 _setv[1]=36.9768 _setv[2]=18.8512 ;ideal XYZ center of tooling ball
N40 _knum=1 ;correct G54
N45 _fa=10 ; cycle997 will position the probe 10 mm off of the touch point. The distance-to-go of the measurement infeed is 2*_fa. _fa always has mm units. Don’t ask why!
N50 _tsa=.3 ;_tsa is a tolerance. See explanation in text after the program
N55 _vms=10 ;the feedrate for the G01 measure move
N60 _nmsp=1 ;one hit at each location
N65 _prnum=1 ;the number assigned to the probe for calibration
N70 Cycle997 ;measure 1 ball for G54 determination
N75 _mvar=10119 ;code for 3-ball measurement for G54 correction
N80 _setv[0]=23.7217 _setv[1]=36.4123 _setv[2]=18.878;XYZ 1st ball
N85 _setv[3]=69.6605 _setv[4]=-35.4953 _setv[5]=27.6538 ;2nd ball
N90 _setv[6]=-70.7904 _setv[7]=36.9768 _setv[8]=18.8512 ;3rd ball
N95 _tnvl=.1 ;tolerance for sum of sides difference[1]
N100 _chbit[2]=0 ;collision monitor off. rapid between balls
N105 Cycle997 ;measure 3 balls for G54 alignment to workpiece
N110 Jog_spin ;turns off probe
N115 M30

The distance-to-go of the measurement infeed is 2*_fa. The cycle will alarm if the probe does not touch before over traveling the target by the _tsa distance.
[1] Each ball is at the vertex of a triangle. The sum of the sides of the ideal triangle and the actual triangle must not differ by more than the _tnvl amount or the cycle alarms.

Cycle971 for Tool Measurement

Cycle971 for the 840D CNC is a standard Siemens Measuring Cycle that works in conjuntion with a tool probe to measure tool length and tool radius.

The program of this post was prepared and tested on a horizontal boring machine with an AC head to orient the tool. The program makes use of Cycle971 to measure the length of a drilling tool and the length or length & radius of a milling tool.

Tools that are defined in the drill family of cutters are measured for length with a stationary spindle.

Tools that are defined in the milling family of cutters are measured for length with a spinning spindle. If the Call is Meas_TL(1), the tool is measured for length and radius. By default the speeds and feeds are calculated by Cycle971.

Since the program is highly commented I will leave it to you to learn the technology from it. Keep in mind that the program is highly specific to the machine in question.

The program assumes you have set the D-code for the tool within a tolerance of 1/4th inch.

Good luck.


%_N_MEAS_TL_SPF
;$PATH=/_N_CUS_DIR
;Last edited 07/10/2009
N1 Proc Meas_TL(Bool Radius_Also, Real _myID, Bool Use_MFS) Save
;check that A & C rotary axes are at zero
N2 IF TRUNC(1000*$aa_im[C])<>0 AND TRUNC(1000*$aa_im[A])<>0
N3 Not_OK: MSG("Axes C or A - or both - are not at zero")
N4 G4 F3
N5 MSG("Reset & program C and A to zero.")
N6 G4 F3
N7 GOTOB Not_OK
N8 ENDIF
;Check for an active tool and D-code
N9 IF ($p_toolno==0)OR($p_tool==0)
N10 Not_OK: MSG("T-code not programmed or D-code is D0.")
N11 G4 F3 ;reset and program a T-code or D-code
N12 GOTOB Not_OK
N13 ENDIF
N14 $mn_g53_toolcorr = 0 ;so SUPA does not cancel the D-code
N15 Newconf ;to activate the machine data change
N16 IF $p_ad[1]==121 ;end mill with corner rounding
N17 _id=$p_ad[7]
N18 ELSE
N19 _id=_myID
N20 ENDIF
N21 M64 ;tool probe on
N22 G4 F3 ;delay for tool probe to turn on
N23 _speed[1]=75 ;feed for positioning in the XY plane
N24 _speed[2]=40 ;feed for positioning in the Z-axis
N25 _chbit[3]=0 ;wear monitor disabled for a 1st measurment
N26 _chbit[2]=1 ;collision monitoring on
N27 _chbit[17]=0 ;_speed[1] & [2] for positioning. _vms for measuring
N28 STOPRE
N29 IF ($P_AD[1]>=100)AND($P_AD[1]<200)>=200)AND($P_AD[1]<300) ;if drilling tool
N31 MSG("Measuring Length with Stationary Spindle")
N32 M5
N33 G00 SUPA X=(_tp[0,0]+_tp[0,1])/2 Y=((_tp[0,2]+_tp[0,3])/2)-2*$p_ad[6]
N34 SUPA Z=_TP[0,4]+1 D1
N35 _MVAR=1 ;measure tool with motionless spindle
N36 _MA=203 ;Offset in Y. Probe in Z
N37 _FA=12.7 ;stand off clearance. 0.5 inch in English.
N38 _TSA=0.501 ;Overtravel limit on the measurement move.
N39 _TZL=0 ;scatter range
N40 _TDIF=0.5 ;not applicable when _chbit[3]=0
N41 _PRNUM=1 ;use calibration data from row 0 of tool probe array
N42 _VMS=5.5;measure feedrate.
N43 _NMSP=2 ;make 2 measurements and average
;N39 _ID=_myID;additional centerline offset for tools with radius in D-code
N44 _EVNUM=0;no empirical value memory specified. No _mv correction
N45 STOPRE ;not necessary but some people like it for comfort
N46 MSG("Measuring Length with zero spindle speed for tools defined as type 1xx like drills, ball end mills, reamers, taps, etc.")
N47 Cycle971
N48 SUPA Z=_TP[0,4]+10
N49 ELSE
N50 Wrong_Tool: MSG("Tool not type 1xx or 2xx")
N51 G4 F5 ;tool not of the type that can be measured by this cycle
;reset to clear message
N52 GOTOB Wrong_Tool
N53 ENDIF
N54 GOTOF _n9999 ;
N55 Spin_On:;Measure tool length with spin turning
N56 IF NOT Use_MFS GOTOF Use_CM
N57 _chbit[12]=1 ;use _mfs values
N58 _mfs[0]=$p_s[1];most recent programmed speed
N59 _mfs[1]=$p_f ;most recently programmed feed
N60 _mfs[2]=1.25*$p_s[1];spindle speed for 2nd meas
N61 _mfs[3]=$p_f/10;feed for 2nd meas
N62 _mfs[4]=0;no 3rd meas
N63 _mfs[5]=0;feed for 3rd meas
N64 GOTOF Meas_Length:
N65 Use_CM: ;cycle calculates speeds, feeds
N66 _chbit[12]=0 ;Calculate F&S from _CM data
N67 _cm[0]=300 ;SFM feet/min
N68 _cm[1]=3000 ;upper limit on spindle speed
N69 _cm[2]=.075;in/min lower limit on feed
N70 _cm[3]=0.0005 ;measuring accuracy. measuring feed = spin_speed*_cm[3]
N71 _cm[4]=1.25 ;in/min upper limit on feed
N72 _cm[5]=4 ;spindle direction for measuring
N73 _cm[6]=1 ;feed factor 1
N74 _cm[7]=0 ;feed factor 2
N75 Meas_Length: G00 SUPA X=(_tp[0,0]+_tp[0,1])/2 Y=((_tp[0,2]+_tp[0,3])/2)-2*$p_ad[6]
N76 SUPA Z=_TP[0,4]+1 D1
N77 _MVAR=2;measure with spindle turning
N78 _MA=203 ;offset in Y, measure in Z
N79 _FA=12.7 ;the stand-off clearance. 0.5 inch in English.
N80 _TSA=0.5001 ;Overtravel limit on the measurement move.
N81 _TZL=0 ;scatter range
N82 _TDIF=0.5 ;no significance when _chbit[3]=0
N83 _PRNUM=1 ;calibration data fm row 0 of tool probe array
N84 _VMS=0 ;no significance since feedrate is calculated by cycle
N85 _NMSP=1 ;make 1 measurement
;N82 _ID=_myID ;additional offset in addition to radius
N86 _EVNUM=0;no empirical value memory specified. No _mv correction
N87 _chbit[3]=0 ; correction applied to tool geometry with resetting of wear
N88 MSG("Measuring Length of tools defined as milling of type 1xx with Spinning Spindle")
N89 Cycle971
N90 SUPA Z=_TP[0,4]+1
N91 Meas_Radius: ;measure tool radius with spin turning
N92 IF NOT Radius_Also GOTOF _n9999
N93 G01 F10 SUPA X=(_tp[0,0]+_tp[0,1])/2 Y=((_tp[0,2]+_tp[0,3])/2)-2*$p_ad[6]-.25
N94 SUPA Z=_TP[0,4]+1 D1
N95 _MVAR=2 ;measure with spindle turning
N96 _MA=2 ; measure radius in Y direction
N97 _FA=6.35 ;the stand off clearance. 0.25 inch in English.
N98 _TSA=0.2501 ;Overtravel limit on the measurement move.
N99 _TZL=0 ;scatter is zero
N100 _TDIF=0.25 ;no significance when _chbit[3]=0
N101 _PRNUM=1 ;calibration data fm row 0 of tool probe array
N102 _VMS=0 ;cycle calculates feedrate
N103 _NMSP=1 ;number of hits at single location
;N101 _ID=_myID ;no additional travel in the plunge move
N104 _EVNUM=0;no empirical value correction. No _mv correction
N105 MSG("Measure tool radius")
N106 Cycle971;measure tool radius
N107 _n9999: SUPA Z=_TP[0,4]+10 D1
N108 STOPRE
N109 m65
N110 RET