This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
en:x300:g-code_and_m-code [2022/09/28 11:26] erik.ketele |
en:x300:g-code_and_m-code [2023/05/17 10:05] (current) |
||
|---|---|---|---|
| Line 151: | Line 151: | ||
| G-codes | G-codes | ||
| - | | \\ <font 11pt/ | + | |G-code|meaning| |
| - | | \\ <font 11pt/ | + | |G0|rapid positioning| |
| - | | | + | |G1|linear interpolation| |
| - | | \\ <font 11pt/ | + | |G2|helical interpolation (clockwise)| |
| - | | \\ <font 11pt/ | + | |G3|circular/ |
| - | | | + | |G4|dwell| |
| - | | \\ <font 11pt/ | + | |G10|coordinate system origin setting| |
| - | | \\ <font 11pt/ | + | |G17|XY-plane selection| |
| - | | | + | |G18|XZ-plane selection| |
| - | | \\ <font 11pt/ | + | |G19|YZ-plane selection| |
| - | | \\ <font 11pt/ | + | |G20|inch system selection| |
| - | | | + | |G21|millimeter system selection| |
| - | | \\ <font 11pt/ | + | |G28|move to park position 1, setup on variable page| |
| - | | \\ <font 11pt/ | + | |G30|move to park position 2, setup on variable page| |
| - | | | + | |G33|Lathe, motion synchronized to spindle| |
| - | | \\ <font 11pt/ | + | |G38.2|straight probe| |
| - | | \\ <font 11pt/ | + | |G40|cancel cutter radius compensation| |
| - | | | + | |G41|start cutter radius compensation left| |
| - | | \\ <font 11pt/ | + | |G42|start cutter radius compensation right| |
| - | | \\ <font 11pt/ | + | |G43|tool length offset (plus) , tool X offset for lathe| |
| - | | | + | |G49|cancel tool length offset| |
| - | | \\ <font 11pt/ | + | |G53|motion in machine coordinate system| |
| - | | \\ <font 11pt/ | + | |G54|use preset work coordinate system 1| |
| - | | | + | |G55|use preset work coordinate system 2| |
| - | | \\ <font 11pt/ | + | |G56|use preset work coordinate system 3| |
| - | | \\ <font 11pt/ | + | |G57|use preset work coordinate system 4| |
| - | | | + | |G58|use preset work coordinate system 5| |
| - | | \\ <font 11pt/ | + | |G59|use preset work coordinate system 6| |
| - | | \\ <font 11pt/ | + | |G59.1|use preset work coordinate system 7| |
| - | | | + | |G59.2|use preset work coordinate system 8| |
| - | | \\ <font 11pt/ | + | |G59.3|use preset work coordinate system 9| |
| - | | \\ <font 11pt/ | + | |G61|set path control mode: exact path| |
| - | | | + | |G61.1|set path control mode: exact stop| |
| - | | \\ <font 11pt/ | + | |G64|set path control mode: continuous| |
| - | | \\ <font 11pt/ | + | |G68|XY rotation| |
| - | | | + | |G76|Lathe, threading| |
| - | | \\ <font 11pt/ | + | |G80|cancel motion mode (including any canned cycle)| |
| - | | \\ <font 11pt/ | + | |G81|canned cycle: drilling| |
| - | | | + | |G82|canned cycle: drilling with dwell| |
| - | | \\ <font 11pt/ | + | |G83|canned cycle: peck drilling| |
| - | | \\ <font 11pt/ | + | |G84|canned cycle: right hand tapping| |
| - | | | + | |G85|canned cycle: boring, no dwell, feed out| |
| - | | \\ <font 11pt/ | + | |G86|canned cycle: boring, spindle stop, rapid out| |
| - | | \\ <font 11pt/ | + | |G87|canned cycle: back boring| |
| - | | | + | |G88|canned cycle: boring, spindle stop, manual out| |
| - | | \\ <font 11pt/ | + | |G89|canned cycle: boring, dwell, feed out| |
| - | | \\ <font 11pt/ | + | |G90|absolute distance mode| |
| - | | | + | |G91|incremental distance mode| |
| - | | \\ <font 11pt/ | + | |G92|offset coordinate systems and set parameters| |
| - | | \\ <font 11pt/ | + | |G92.1|cancel offset coordinate systems and set parameters to zero| |
| - | | | + | |G92.2|cancel offset coordinate systems but do not reset parameters| |
| - | | \\ <font 11pt/ | + | |G92.3|apply parameters to offset coordinate systems| |
| - | | \\ <font 11pt/ | + | |G93|inverse time feed rate mode| |
| - | | | + | |G94|units per minute feed rate mode| |
| - | | \\ <font 11pt/ | + | |G98|initial level return in canned cycles| |
| - | | \\ <font 11pt/ | + | |G99|R-point level return in canned cycles| |
| - | | | + | |
| - | | \\ <font 11pt/ | + | === Linear Motion at Feed Rate - G1 === |
| - | | \\ <font 11pt/ | + | |
| - | | | + | For linear motion at feed rate (for cutting or not), program G1 X… Y… Z… A…, where all the axis words are optional, except that at least one must be used.\\ |
| - | | \\ <font 11pt/ | + | The G1 is optional if the current motion mode is G1. This will produce coordinated linear motion to the destination point at the current feed rate (or slower if the machine will not go that fast).\\ |
| - | | \\ <font 11pt/ | + | It is an error if:\\ |
| - | | | + | • • All axis words are omitted. |
| - | | \\ <font 11pt/ | + | |
| - | | \\ <font 11pt/ | + | === Arc at Feed Rate - G2 and G3 === |
| - | | | + | |
| - | | \\ <font 11pt/ | + | A circular or helical arc is specified using either G2 (clockwise arc) or G3 (counterclockwise arc). The axis of the circle or helix must be parallel to the X, Y, or Z-axis of the machine coordinate system.\\ |
| - | | \\ <font 11pt/ | + | The axis (or, equivalently, |
| - | | | + | If a line of RS274/NGC code makes an arc and includes rotational axis motion, the rotational axes turn at a constant rate so that the rotational motion starts and finishes when the XYZ motion starts and finishes. Lines of this sort are hardly ever programmed.\\ |
| - | | \\ <font 11pt/ | + | Two formats are allowed for specifying an arc. We will call these the center format and the radius format. In both formats the G2 or G3 is optional if it is the current motion |
| - | | \\ <font 11pt/ | + | |
| - | | | + | == Radius format arc == |
| - | | \\ <font 11pt/ | + | |
| - | | \\ <font 11pt/ | + | In the radius format, the coordinates of the end point of the arc in the selected plane are specified along with the radius of the arc. Program G2 X… Y… Z… A… R… (or use G3 instead of G2). R is the radius.\\ |
| - | | | + | The axis words are all optional except that at least one of the two words for the axes in the selected plane must be used. The R number is the radius.\\ |
| - | | \\ <font 11pt/ | + | A positive radius indicates that the arc turns through 180 degrees or less, while a negative radius indicates a turn of 180 degrees to 359.999 degrees. If the arc is helical, the value of the end point of the arc on the coordinate axis parallel to the axis of the helix is also specified.\\ |
| - | | \\ <font 11pt/ | + | It is not good practice to program radius format arcs that are nearly full circles or are semicircles (or nearly semicircles) because a small change in the location of the end point will produce a much larger change in the location of the center of the circle (and, hence, the middle of the arc).\\ |
| - | | | + | The magnification effect is large enough that rounding error in a number can produce out-of-tolerance cuts. Nearly full circles are outrageously bad, semicircles (and nearly so) are only very bad. Other size arcs (in the range tiny to 165 degrees or 195 to 345 degrees) are OK.\\ |
| - | | \\ <font 11pt/ | + | Here is an example of a radius format command to mill an arc: **G17 G2 x 10 y 15 r 20 z 5.** \\ |
| - | | \\ <font 11pt/ | + | That means to make a clockwise (as viewed from the positive Z-axis) circular or helical arc whose axis is parallel to the Z-axis, ending where X=10, Y=15, and Z=5, with a radius of 20. If the starting value of Z is 5, this is an arc of a circle parallel to the XY-plane; otherwise it is a helical arc. |
| - | | | + | |
| - | | \\ <font 11pt/ | + | == Center format arc == |
| - | | \\ <font 11pt/ | + | |
| - | | | + | In the center format, the coordinates of the end point of the arc in the selected plane are specified along with the offsets of the center of the arc from the current location. In this format, it is OK if the end point of the arc is the same as the current point. It is an error if:\\ |
| - | | \\ <font 11pt/ | + | • When the arc is projected on the selected plane, the distance |
| - | | \\ <font 11pt/ | + | When the XY-plane is selected, program **G2 X… Y… Z… A… I… J…** (or use G3 instead of G2). The axis words are all optional except that at least one of X and Y must be used. I and J are the offsets from the current location (in the X and Y directions, respectively) of the center of the circle.\\ |
| - | | | + | I and J are optional except that at least one of the two must be used. It is an error if:\\ |
| - | | \\ <font 11pt/ | + | * I and J are both omitted.\\ |
| - | | \\ <font 11pt/ | + | \\ |
| - | | | + | When the XZ-plane is selected, program **G2 X… Y… Z… A… I… K…** (or use G3 instead of G2). The axis words are all optional except that at least one of X and Z must be used. I and K are the offsets from the current location (in the X and Z directions, respectively) of the center of the circle.\\ |
| - | | \\ <font 11pt/ | + | I and K are optional except that at least one of the two must be used. It is an error if:\\ |
| - | | \\ <font 11pt/ | + | * I and K are both omitted.\\ |
| - | | | + | \\ |
| - | | \\ <font 11pt/ | + | When the YZ-plane is selected, program **G2 X… Y… Z… A… B… C… J… K…** (or use G3 instead of G2). The axis words are all optional except that at least one of Y and Z must be used. J and K are the offsets from the current location (in the Y and Z directions, respectively) of the center of the circle.\\ |
| - | | \\ <font 11pt/ | + | J and K are optional except that at least one of the two must be used. It is an error if:\\ |
| - | | | + | * J and K are both omitted.\\ |
| - | | \\ <font 11pt/ | + | \\ |
| - | | \\ <font 11pt/ | + | Here is an example of a center format command |
| - | | | + | **G17 G2 x10 y16 i3 j4 z9.** \\ |
| - | | \\ <font 11pt/ | + | \\ |
| - | | \\ <font 11pt/ | + | That means to make a clockwise (as viewed from the positive z-axis) circular or helical arc whose axis is parallel to the Z-axis, ending where X=10, Y=16, and Z=9, with its center offset in the X direction by 3 units from the current X location and offset in the Y direction by 4 units from the current Y location.\\ |
| - | | | + | If the current location has X=7, Y=7 at the outset, the center will be at X=10, Y=11. If the starting value of Z is 9, this is a circular arc; otherwise it is a helical arc. The radius of this arc would be 5.\\ |
| - | | \\ <font 11pt/ | + | \\ |
| - | | \\ <font 11pt/ | + | In the center format, the radius of the arc is not specified, but it may be found easily as the distance from the center of the circle to either the current point or the end point of the arc |
| - | | | + | |
| - | | \\ <font 11pt/ | + | === Dwell - G4 === |
| - | | \\ <font 11pt/ | + | |
| - | | | + | For a dwell, program G4 P… . This will keep the axes unmoving for the period of time in seconds specified by the P number. It is an error if the P number is negative.\\ |
| - | | \\ <font 11pt/ | + | === Length Units - G20/G21 and G70/G71 === |
| - | | \\ <font 11pt/ | + | |
| - | | | + | Program G20 to use inches for length units. Program G21 to use millimeters.\\ |
| - | | \\ <font 11pt/ | + | It is usually a good idea to program either G20 or G21 near the beginning of a program before any motion occurs, and not to use either one anywhere else in the program.\\ |
| - | | \\ <font 11pt/ | + | It is the responsibility of the user to be sure all numbers are appropriate for use with the current length units. G70/G71 is added for CAM software compatibility.\\ |
| - | | | + | === Return to Home - G28 and G30 === |
| - | | \\ <font 11pt/ | + | |
| - | | \\ <font 11pt/ | + | Two home positions are defined (by parameters |
| - | | | + | To return to home position by way of the programmed position, program G28 X… Y… Z… A… (or use G30). All axis words are optional.\\ |
| - | | \\ <font 11pt/ | + | The path is made by a traverse move from the current position to the programmed position, followed by a traverse move to the home position.\\ |
| - | | \\ <font 11pt/ | + | If no axis words are programmed, the intermediate point is the current point, so only one move is made. The order of Z depends on its position, if the end position is higher as the current Z position Z will move first, otherwise Z will move last, this is to prevent collision.\\ |
| - | | | + | \\ |
| - | | \\ <font 11pt/ | + | ==== Input M codes ==== |
| - | | \\ <font 11pt/ | + | |
| - | | | + | M codes of the RS274/NGC language are shown in the following table.\\ |
| - | | \\ <font 11pt/ | + | |M code|Meaning| |
| - | | \\ <font 11pt/ | + | |M0|program stop| |
| - | | | + | |M1|optional program stop| |
| - | | \\ <font 11pt/ | + | |M2|program end| |
| - | | \\ <font 11pt/ | + | |M3|turn spindle clockwise| |
| - | | | + | |M4|turn spindle counterclockwise| |
| - | | \\ <font 11pt/ | + | |M5|stop spindle turning| |
| - | | \\ <font 11pt/ | + | |M6|tool change| |
| - | | | + | |M7|mist coolant on| |
| - | | \\ <font 11pt/ | + | |M8|flood coolant on| |
| - | | \\ <font 11pt/ | + | |M9|mist and flood coolant off| |
| - | | | + | |M30|progrma end, spindle and coolants off and rewind.| |
| - | | \\ <font 11pt/ | + | |M48|enable speed and feed overrides.| |
| - | | \\ <font 11pt/ | + | |M49|disable speed and feed overrides.| |
| - | | | + | |M90|standard head/spindle| |
| - | | \\ <font 11pt/ | + | |
| - | | \\ <font 11pt/Calibri,sans-serif;; | + | == Program Stopping and Ending |
| - | | | + | To halt a running program temporarily, |
| - | | \\ <font 11pt/ | + | **M30** for next effects:\\ |
| - | | \\ <font 11pt/ | + | • Distance mode is set to MODE_ABSOLUTE (like G90).\\ |
| - | | | + | • Feed |
| - | | \\ <font 11pt/ | + | • Feed and speed overrides are set to ON (like M48).\\ |
| - | | \\ <font 11pt/ | + | • The spindle is stopped (like M5).\\ |
| - | | | + | • Coolants are turned off (like M9).\\ |
| - | | \\ <font 11pt/ | + | • Program is re-winded to the first line, ready for next start.\\ |
| - | | \\ <font 11pt/ | + | \\ |
| - | | | + | Program **M60** instead of M30 if the spindle and coolants should remain ON.\\ |
| - | | \\ <font 11pt/ | + | \\ |
| - | | \\ <font 11pt/ | + | == Spindle/Head Control - M3, M4, M5, M90-M97 == |
| - | | | + | To start the spindle turning clockwise at the currently programmed speed, program M3.\\ |
| - | | \\ <font 11pt/ | + | To start the spindle turning counterclockwise at the currently programmed speed, program M4.\\ |
| - | | \\ <font 11pt/ | + | To stop the spindle from turning, program M5.\\ |
| - | | | + | It is OK to use M3 or M4 if the spindle speed is set to zero. If this is done (or if the speed override switch is enabled and set to zero), the spindle will not start turning.\\ |
| - | | \\ <font 11pt/ | + | If, later, the spindle speed is set above zero (or the override switch is turned up), the spindle will start turning. It is OK to use M3 or M4 when the spindle is already turning or to use M5 when the spindle is already stopped.\\ |
| - | | \\ <font 11pt/Calibri, | + | \\ |
| - | | | + | **__Note: |
| - | | \\ <font 11pt/Calibri, | + | \\ |
| - | | \\ <font 11pt/ | + | == Coolant Control - M7, M8, M9 == |
| - | | | + | To turn mist coolant on, program M7. To turn flood coolant on, program M8. To turn all coolant off, program M9. It is always OK to use any of these commands, regardless of what coolant is on or off.\\ |
| - | | \\ <font 11pt/ | + | \\ |
| - | | \\ <font 11pt/Calibri,sans-serif;; | + | |
| - | | | + | |
| - | | \\ <font 11pt/ | + | |
| - | | \\ <font 11pt/ | + | |
| - | | | + | |
| **Continue to [[: | **Continue to [[: | ||