G-code
Supported G-code

G61, G64 (Path Control Mode and Look Ahead Feed)

12min

Ideally one would like to have constant cutting speed during the work and maximum accuracy. This ideal is physically not possible, similar to driving a racecar on curvy roads is not possible with constant velocity. It is trivial that it needs to brake in the curves and accelerate on straight roads. If you would do the same speed in the curves as on a straight road, the car will spin out of control and collide. This analogy holds for CNC machines, constant speed and accuracy together are physically not possible. It would require infinite acceleration to go through a corner from one direction to another. In a CNC machine, this would result in position/step loss of stepper motors or high following error with servos. If a motion path consists of small lines (G1) it is even worse than driving a racecar because there is a sharp corner between every line. This is often the case with CAM-generated motion paths (g-code).

So a compromise has to be made. There are various options to choose the optimum between accuracy and constant speed or fast speed versus jerkiness.

G61

G61 puts the machine into exact path mode, In G61, the motion velocity between motion segments goes to zero, and the end position in corners is exactly reached, use this if you require maximum accuracy. When a workpiece consists of many small lines this gives a quite jerky/vibrating machine because of the continuous acceleration-deceleration-stop behavior. It is more practical to use G64 and G64 P… as specified below.

G64

G64 is to be used for more smooth and fast motion. There are 4 parameters that can be used, they are explained below individually but they can be combined on one line.

G64

G64 without additional parameters switches on continuous/smooth velocity mode. In G64, subsequent moves are blended, when the previous move starts to decelerate and reaches a velocity such that the specified accuracy isn’t violated, the next move starts to accelerate, and the two motions are added. The result is smooth motion with the highest constant speed. The corners however are rounded. The amount of rounding is depending on the max acceleration of the machine. The higher the acceleration, the less rounding.

G64 P…

The optional P value specifies the distance reached to the corner while blending. The next move is blended with the current such that the tool path remains no more than P from the corner. This will cause a velocity ramp down in the corner but not to zero. The figure below is a rectangle of 10x10 milled with F2000. This is done with P values from 0.1 to 1, you can see the impact. This gives the best compromise between accuracy and smooth motion. So you can say G64 P... is like a compromise between G61 and G64 without P.



This figure shows the impact of the P parameter on the amount of rounding.
This figure shows the impact of the P parameter on the amount of rounding.


You may also conclude here that it is very important to have high acceleration on the machine because we can ramp down faster in the corner and have more accurate corners at higher speeds.

G64 Q…

The optional Q parameter activates an embedded line simplification algorithm, which tries to combine short lines and make one long line. The optional Q parameter gives the tolerance used in the algorithm. Again to reduce the number of small corners.

The behavior of a long g-code program with short line segments is further optimized by the look ahead feed, see next page.

Look Ahead feed

To explain this, we will compare a running CNC machine again with driving a race car.



Example race track
Example race track


The road maximum velocity signs have to be obeyed and you have to drive your car exactly over the white line in the middle of the road. You will try to reach the maximum allowed velocity where possible. When you see a curve coming up ahead, you will brake so that you will not drift off the white line. You will try to look ahead as far as you can see and you take care that you can stop in time if the road suddenly stops.

When you would maintain your speed in sharp curves, you will drift off the road possibly resulting in a car accident. When the road has many short curves, then you will not be able to reach the desired speed. The more power you have in the car, the higher speed you will reach because you can accelerate faster.

This is a good comparison with a CNC machine, the same issues apply. A machine cannot suddenly change velocity, to reach a velocity the motors must accelerate first for a certain time to reach the velocity.

Eding CNC LAF behaves like the ideal racecar driver, it will reach the highest possible velocity without violating the maximum motor accelerations.

There is one additional problem while running CNC programs, some programs consist of short line segments. When the line pieces connect tangentially (are in line), then LAF will accelerate through over the lines, reaching the maximum allowed speed. Without LAF the speed would not be reached.

The angle to which LAF considers the segments in line is a setup parameter. The theoretical ideal value would be very small so that no acceleration value occurs.

More practical values are in the range of 1 to 4 degrees, the experience learns that most machines can handle acceleration spikes up to a certain limit.

The value can be set up to 180 degrees, in this case, you must know what you are doing, it can be useful during e.g. foam cutting. Be aware however that if the curve contains real sharp angles that step pulse loss may be the result when using large minimum LAF angles.

In practice, we have seen that milling times of complex 3D workpieces can be done within 50% of the time compared to competitors who do not have LAF. With G64 R... the LAF angle can be changed in the g-code file. The standard LAF angle is in the software setup. To give some realistic values: A value of 3 is good for most machines. A value of 6 may already give too much Jerky ness on some machines. Still, there are customers using values of 20 here, but they have quite specific machine constructions and applications e.g. dental milling.

G64 F...

The F parameter defines the value of the Accel/Decel filter placed behind LAF. LAF with high R values (Angle) can cause acceleration spikes because LAF will travel through corners without stopping. The F parameter filters the trajectory generated by LAF and takes care the acceleration is never violated.

F1 will give a RAMP time that matches with the max velocity / max acceleration from the setup and so F1 and maximum speed will lead to the max acceleration that is allowed. Smaller F values filter less. This can be used if the milling velocity is less than the max velocity of the machine. Example:

The max velocity in the setup is 200 and the used milling velocity is F6000 (100 mm/s),

Then F0.5 is safe to use. So now you can do this G64 R100 F1 and you will not get acceleration spikes but a very smooth and fast movement. The price to pay is corner rounding which is depending on the max acceleration of the machine, the higher the max acceleration, the less corner rounding.

A good application example is with milling rubber or similar flexible material, the milling speed must be constant otherwise more material is removed in the corners due to the lower speed and the flexibility of the rubber. The F1 in combination with R100 will give constant and high speed for good milling surface quality of the rubber.

For milling e.g. rubber when constant speed is more important than rounding. To have an acceptable amount of rounding the machine needs to have very high acceleration. This function was tested and used on a machine with a relatively low speed (100 mm/sec) and very high acceleration (4000 mm/sec * sec).

G64 R…

The R parameter is the look-ahead feed angle. When subsequent lines/arcs have an angle together less than this value, the trajectory-generator will accelerate through these segments and this way optimizes the production time. With R0, LAF is switched off, and with LAF off a (much) lower but more constant speed is achieved. The higher the angle, the higher the speed, but the jerkier the motion becomes because of high acceleration peaks. This needs to be tuned depending on the quality of the machine and the power of the used motors. A compromise is to be found between speed and machine behavior.

G64 R... S... D... (NEW for V4.03.xx)

New algorithm (Still experimental, but successfully used by a few customers): With the standard LAF setting G64 R... (no S... and no D...), the velocity in corners will be zero if the angle between the segments is bigger than LAF angle in the set-up. But there are angles that are big and also smaller angles, so we found a solution where depending on the angle size, the speed in the corner the velocity is limited but not to zero and further limited if the angle gets bigger. This allows faster production, especially for 3D work.

Putting a circle to the original path would be a solution. But this cannot be done in real-time and is also not always wanted because we want the contour to be milled as specified in the g-code.

However, we can calculate a circle between 2 segments when knowing their start and end vectors. The circle radius can then be used to calculate an allowable velocity in the corner taking the max acceleration into account like this:

Vcorner = SQRT ( Amax * R) Where A max is the maximum possible acceleration which is known by the setup and R is the calculated Radius depending on the angle between the segments and the D value supplied in the G64 command.

This is basically the idea. If we draw it, it gets more clear:

Document image


Segment 1 and Segment 2 are 2 subsequent motion segments.

Alfa is the change of direction angle between the segments. Beta is the angle between the lines to fit the circle. D is the user-supplied max deviation between the junction and the circle, this determines how far the junction speed is limited. R is the calculated radius from D and Beta.

So D is the parameter that determines the amount of speed reduction in the corner. Practical values are in the order of 0.01 to 0.0001 for D. The smaller the value the smaller the circle radius, the smaller the velocity in the corner becomes.

This value needs to be tuned by experimenting on the target machine, if the value is too high the machine will move jerkily. Note that the original path is traveled, but the corner velocity is limited in the corner as if there was an arc between the segments.

Both new and old algorithms co-exist in the software. So the user can specify 2 angles and the D parameters now with G64 together with the existing P parameter.

G64 P... R... S... D...

P: Parameter for max rounding when blending R: LAF angle for standard algorithm where LAF will travel full speed of angle is lower. S: 2nd angle, the new algorithm will work between the R... angle and S... angle. D: deviation of the virtual circle in the corner used in the algorithm. Example: G64 P0.1 R3 S90 D0.001

The machine operates at full speed when the angle is less than the R angle. Reduced speed depends on D when the angle is between the R and S angle. For angles bigger than S... angle blending kicks in and uses the P... as tolerance.

G64 P... Q... R... S... D... F...

There are 6 parameters that can be combined with G64. For normal milling, mostly G64 P... is used.