What's new
What's new

Accurate CNC 360 Milling G-Code

PillowCloud

Plastic
Joined
Sep 26, 2023
N1 G90
N2 G20
N3 T0 S10000 ( 0.0610"/1.549mm DRILL Hole : 0.060"/1.550mm, {Z-0.00500"/-0.127mm, TH07} Pin1-1.550mm )
N4 G0 X4.75212307 Y3.76442850 (Stop-point)
N5 G91 G81 X0.39370079 Y0.39370079 Z-0.08000 R0.05000 F3.0
N6 G90
N6 T1 S10000 ( 0.0807"/2.050mm DRILL Hole : 0.080"/2.029mm, {Z-0.00500"/-0.127mm, TH08 } Guide Pin-2.050mm)
N4 G0 X4.75212307 Y3.76442850 (Stop-point)
N7 G91 G81 X0.39370079 Y3.60236221 Z-0.08000 R0.05000 F3.0
N8 X1.14173228 Y0.0000
N9 X0.000007 Y-3.20866142
N10 G00 Z0.05000

Hi guys, The G91 and G81 g-code seems not to work when I import it into the milling machine. It does not drill through the object, instead it increase the "Z" value. How do I edit the code so that it can drill through the object?
 
It is measuring R from the initial tool position, and going upwards, as R is positive.
You would need to make it negative, and calculate its value, based on initial height.

If only one hole is needed, it is better to use G90, to avoid any confusion. Subsequent holes can be made in G91 mode, without commanding R. For equidistant holes, K can be added.
 
On our mills I just add the next hole in the cycle like this
G90
G20
T1
S3000 M3
G0 X5.0 Y5.0
G43 Z1.0 H1
G81 Z-.5 R0.1 F3.0
Y10.0
X8.0
G00 Z0.1
G80

Does your drill cycles not work the same?
 
On our mills I just add the next hole in the cycle like this
G90
G20
T1
S3000 M3
G0 X5.0 Y5.0
G43 Z1.0 H1
G81 Z-.5 R0.1 F3.0
Y10.0
X8.0
G00 Z0.1
G80

Does your drill cycles not work the same?
He is using incremental mode.
In this mode, R is measured from the initial tool height, and Z is measured from the defined R.
 
I have to agree with Sinha. The first hole in any pattern should be defined with G90 and then if appropriate (say multiple holes in a straight line) you can switch to G91 to shorten the code.
 
I have to agree with Sinha. The first hole in any pattern should be defined with G90 and then if appropriate (say multiple holes in a straight line) you can switch to G91 to shorten the code.
you don't have to use g91. Just move to you next position and drill after the g81 line.
 
you don't have to use g91. Just move to you next position and drill after the g81 line.
That is correct.
However, there can be two cases for preferring G91 for subsequent holes.
1. If there are a large number of equidistant holes, all can be drilled by one line of code, by using K (number of repeats).
2. If the drawing specifies center-to-center distances (which is more likely), then G91 is more convenient. G90 would need calculations.
 
That is correct.
However, there can be two cases for preferring G91 for subsequent holes.
1. If there are a large number of equidistant holes, all can be drilled by one line of code, by using K (number of repeats).
2. If the drawing specifies center-to-center distances (which is more likely), then G91 is more convenient. G90 would need calculations.
I 100% agree with the first part about the equidistant holes and using incremental instead of absolute when you have a large number of holes. The second I may be missing your point. Every blueprint I have ever drawn or seen has the center to hole dimension called out. Are you talking about having the first hole called out from edge datums and the rest called out from the center of the first hole to the center of the rest of the holes? If so again I can agree that incremental can be beneficial there as well as long as the depth is the same for all of them. Like most things how you approach it is situational to the part you are making.
 
What kind of machine is this for? And can you limit the decimal places to 4 in your CAM software? I doubt your equipment can do anything with numbers beyond that.
 
What kind of machine is this for? And can you limit the decimal places to 4 in your CAM software? I doubt your equipment can do anything with numbers beyond that.
Extra digits (beyond 4 after decimal in inch mode, in IS-B) would be simply truncated. This may be undesirable in some cases where we may want rounding instead of truncating. Therefore, as you said, the CAM software should be made to output only 4 digits after decimal. It will round the value.
 
Last edited:
Are you talking about having the first hole called out from edge datums and the rest called out from the center of the first hole to the center of the rest of the holes?
Yes.
The second hole dimensioned wrt the first hole, the third hole wrt the second hole, and so on.
.
 
as well as long as the depth is the same for all of them
Same depth is required only if K is being used, in incremental mode.
If the pattern is not regular, K cannot be used. Each hole would require independent G81. Z can be different in such cases.
Even in this case, G91 may be preferred if every subsequent hole is dimensioned wrt the previous hole. No calculation for XY would be needed. Of course, if Z is different, then one has to keep track of it. One may prefer G90 in such cases.
 
Except for some cases discussed above, it is better to use absolute mode, as some mistake at some place is not carried forward. Moreover, analyzing a program is more convenient because one does not need to back-track to know where exactly the tool currently is.
 
Same depth is required only if K is being used, in incremental mode.
If the pattern is not regular, K cannot be used. Each hole would require independent G81. Z can be different in such cases.
Even in this case, G91 may be preferred if every subsequent hole is dimensioned wrt the previous hole. No calculation for XY would be needed. Of course, if Z is different, then one has to keep track of it. One may prefer G90 in such cases.
I do believe my earlier comment said the incremental can be used only if the z depths was the same so yea you are correct in that.

On Haas mills you can have different z depths within the drilling can cycle. I have done it many times. You take the same little cycle I posted above and you can have different depths for each hole.
G20
T1
S3000 M3
G0 X5.0 Y5.0
G43 Z1.0 H1
G81 Z-.5 R0.1 F3.0
Y10.0 Z-.75
X8.0 Z-.325
G00 G80 Z0.1


 
I do believe my earlier comment said the incremental can be used only if the z depths was the same so yea you are correct in that.

On Haas mills you can have different z depths within the drilling can cycle. I have done it many times. You take the same little cycle I posted above and you can have different depths for each hole.
G20
T1
S3000 M3
G0 X5.0 Y5.0
G43 Z1.0 H1
G81 Z-.5 R0.1 F3.0
Y10.0 Z-.75
X8.0 Z-.325
G00 G80 Z0.1
Fanuc will do the same.
 








 
Back
Top