Skip to content

Commit dccd2b5

Browse files
authored
Merge pull request #4916 from grandixximo/interp-word-checks
interp: word checks on G12.1, G53.x and G68.x
2 parents 1dfbd9d + 7d18e90 commit dccd2b5

10 files changed

Lines changed: 35 additions & 11 deletions

File tree

‎docs/src/gcode/g-code.adoc‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ G13.1 (back to the machine frame kinematics)
10111011
It is an error if:
10121012

10131013
* 'G12.1' is used without a 'P' word.
1014-
* The 'P' word is negative.
1014+
* The 'P' word is negative or not a whole number.
10151015
* The 'P' word names a kinematics the module does not provide.
10161016
* A 'P' word is used with 'G13.1'.
10171017
* 'G13.1' is used and the module declares no identity or machine frame kinematics.
@@ -2140,7 +2140,7 @@ It is an error if:
21402140
names it the way 'P' asks for, or the machine has no pair of poses a
21412141
tilting joint tells apart.
21422142
* 'Q' is anything but 0 or 1.
2143-
* Axis words are used with 'G53.1', 'G53.2' or 'G53.6', or words other than
2143+
* Axis words, polar '@' and '^' included, are used with 'G53.1', 'G53.2' or 'G53.6', or words other than
21442144
'X', 'Y' and 'Z' with 'G53.3'.
21452145
* Cutter compensation is on.
21462146

@@ -2638,6 +2638,7 @@ It is an error if:
26382638
* 'R' is given on more than one block of a 'P2' definition.
26392639
* 'G68.4' is used with no plane active.
26402640
* 'G68.2', 'G68.3' or 'G68.4' is used while a 'G52' given in the plane is in effect.
2641+
* 'G68.2', 'G68.3' or 'G68.4' shares a line with another code that takes axis words, such as 'G52', 'G92', 'G10' or 'G28'.
26412642
* 'G68.3' is used where the kinematics cannot be evaluated, is the identity
26422643
kinematics, or reports no frames.
26432644
* 'G68.3' is given 'I', 'J', 'K', 'P' or 'Q', or 'G69' any of those or 'R':

‎src/emc/rs274ngc/interp_check.cc‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ int Interp::check_g_codes(block_pointer block, //!< pointer to a block to be c
119119
} else if (mode0 == G_92) {
120120
} else if (mode0 == G_53_1 || mode0 == G_53_2 || mode0 == G_53_6) {
121121
CHKS((block->x_flag || block->y_flag || block->z_flag || block->a_flag || block->b_flag ||
122-
block->c_flag || block->u_flag || block->v_flag || block->w_flag),
122+
block->c_flag || block->u_flag || block->v_flag || block->w_flag ||
123+
block->radius_flag || block->theta_flag),
123124
_("Cannot use axis words with G53.1, G53.2 or G53.6"));
124125
} else if (mode0 == G_53_3) {
125126
CHKS((block->a_flag || block->b_flag || block->c_flag || block->u_flag || block->v_flag || block->w_flag),

‎src/emc/rs274ngc/interp_convert.cc‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6908,7 +6908,8 @@ int Interp::convert_kins_switch(int code, //!< G_12_1 or G_13_1
69086908
} else {
69096909
kins_type = round_to_int(block->p_number);
69106910

6911-
CHKS((kins_type < 0), _("G12.1 requires a non-negative P word"));
6911+
CHKS((block->p_number != kins_type || kins_type < 0),
6912+
_("G12.1 requires a whole-number, non-negative P word"));
69126913
// say so at read time rather than aborting mid-program in motion
69136914
CHKS((kins_type_info_available()
69146915
&& GET_EXTERNAL_KINS_TYPE_FLAGS(kins_type) < 0),

‎src/emc/rs274ngc/interp_internal.cc‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ int Interp::enhance_block(block_pointer block, //!< pointer to a block to be c
168168
(block->b_flag) || (block->c_flag) ||
169169
(block->u_flag) || (block->v_flag) ||
170170
(block->w_flag));
171+
// a J<n>= joint target is a destination too: G53.7 moves under the
172+
// G0 or G1 in force like G53.4 and G53.5 do
173+
for (int n = 0; n < EMCMOT_MAX_JOINTS; n++)
174+
axis_flag = axis_flag || block->joint_flag[n];
171175
polar_flag = (block->radius_flag) || (block->theta_flag);
172176
ijk_flag = ((block->i_flag) || (block->j_flag) ||
173177
(block->k_flag));
@@ -181,6 +185,7 @@ int Interp::enhance_block(block_pointer block, //!< pointer to a block to be c
181185
if (block->g_modes[GM_WORK_PLANE] == G_68_2 || block->g_modes[GM_WORK_PLANE] == G_68_3
182186
|| block->g_modes[GM_WORK_PLANE] == G_68_4) {
183187
CHKS(polar_flag, _("Polar coordinates cannot define a tilted work plane"));
188+
CHKS(mode_zero_covets_axes, NCE_CANNOT_USE_TWO_G_CODES_THAT_BOTH_USE_AXIS_VALUES);
184189
mode_zero_covets_axes = 1;
185190
}
186191
// G43.1 and G43.2 take the axis words as offsets: no other G-code in the

‎src/emc/rs274ngc/interp_internal.hh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ struct block_struct
524524

525525
bool dollar_flag{};
526526

527-
bool joint_flag[EMCMOT_MAX_JOINTS]{}; // J<n>=<value> words, for G53.5
527+
bool joint_flag[EMCMOT_MAX_JOINTS]{}; // J<n>=<value> words, for G53.7
528528
double joint_value[EMCMOT_MAX_JOINTS]{};
529529

530530
double radius{};

‎src/emc/rs274ngc/interp_workplane.cc‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,6 @@ int Interp::work_plane_build(block_pointer block, setup_pointer s,
371371
*complete = 0;
372372
CHKS((block->p_flag && (fabs(block->p_number - p) > 1e-9 || p < 0 || p > 3)),
373373
_("P word with G68.2 must be 0, 1, 2 or 3"));
374-
CHKS((block->a_flag || block->b_flag || block->c_flag ||
375-
block->u_flag || block->v_flag || block->w_flag),
376-
_("G68.2 takes no A, B, C, U, V or W: the plane is placed by X, Y and Z"));
377374

378375
if (p == 0 || p == 1) {
379376
// three angles. P0: each about an axis of the frame as rotated so
@@ -524,7 +521,7 @@ int Interp::work_plane_build(block_pointer block, setup_pointer s,
524521
return INTERP_OK;
525522
}
526523

527-
// G68.2, G68.4 and G69 from convert_g
524+
// G68.2, G68.3, G68.4 and G69 from convert_g
528525
int Interp::convert_work_plane(int g_code, block_pointer block, setup_pointer s)
529526
{
530527
double origin[3], rotation[3][3];
@@ -535,6 +532,10 @@ int Interp::convert_work_plane(int g_code, block_pointer block, setup_pointer s)
535532
_("Cannot cancel a tilted work plane with cutter radius compensation on"));
536533
return work_plane_cancel(s, true);
537534
}
535+
// every form, G68.3 included, places the plane by X, Y and Z alone
536+
CHKS((block->a_flag || block->b_flag || block->c_flag ||
537+
block->u_flag || block->v_flag || block->w_flag),
538+
_("G68.2, G68.3 and G68.4 take no A, B, C, U, V or W: the plane is placed by X, Y and Z"));
538539
if (g_code == G_68_3) {
539540
CHKS((s->g68_seq_code != 0), _("G68.3 cannot interrupt a G68.2 sequence"));
540541
return convert_work_plane_from_tool(block, s);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
;G12.1 requires a whole-number, non-negative P word
2+
G12.1 P-0.4
3+
M2

‎tests/interp/g68-words/expected‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ p3-q1-r: ok
1111
p3-4deg: ok
1212
p3-6deg: G68.2 P3: the X and Z directions are 5 degrees or more off square
1313
p3-zero: G68.2 P3: the X direction is a zero vector
14-
p1-a: G68.2 takes no A, B, C, U, V or W: the plane is placed by X, Y and Z
15-
g684-b: G68.2 takes no A, B, C, U, V or W: the plane is placed by X, Y and Z
14+
p1-a: G68.2, G68.3 and G68.4 take no A, B, C, U, V or W: the plane is placed by X, Y and Z
15+
g684-b: G68.2, G68.3 and G68.4 take no A, B, C, U, V or W: the plane is placed by X, Y and Z
1616
g684-none: G68.4 needs an active tilted work plane to build on
1717
g52-a: G52 in a tilted work plane takes only X, Y and Z
1818
g92-plane: Cannot change G92 offsets while a tilted work plane (G68.2) is active
@@ -23,3 +23,7 @@ g921-comp: Cannot change axis offsets with cutter radius comp
2323
g682-g52: Cancel the G52 in the tilted work plane (G52 X0 Y0 Z0) before G68.2 or G68.4
2424
g684-g52: Cancel the G52 in the tilted work plane (G52 X0 Y0 Z0) before G68.2 or G68.4
2525
g682-g52-0: ok
26+
g683-a: G68.2, G68.3 and G68.4 take no A, B, C, U, V or W: the plane is placed by X, Y and Z
27+
g682-g52-line: Cannot use two g codes that both use axis values
28+
g682-g28-line: Cannot use two g codes that both use axis values
29+
g531-polar: Cannot use axis words with G53.1, G53.2 or G53.6

‎tests/interp/g68-words/test.sh‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,8 @@ case_ g921-comp $'G41.1 D2\nG92.1'
3131
case_ g682-g52 $'G68.2 X1 J30\nG52 X1\nG68.2 X2 J30'
3232
case_ g684-g52 $'G68.2 X1 J30\nG52 X1\nG68.4 I10'
3333
case_ g682-g52-0 $'G68.2 X1 J30\nG52 X1\nG52 X0\nG68.2 X2 J30'
34+
case_ g683-a $'G68.3 A10'
35+
case_ g682-g52-line $'G68.2 I0 J30 K0 G52 X10'
36+
case_ g682-g28-line $'G68.2 I0 J30 K0 G28 X10'
37+
case_ g531-polar $'G68.2 X1 J30\nG0 X0\nG53.1 @2 ^45'
3438
rm -f case.ngc

‎tests/twp-native-ptp/test-ui.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
for j in (0, 1, 3, 4, 5):
3939
if abs(after[j] - before[j]) > 1e-6:
4040
error("G53.7 J2=-5 moved joint %d from %.9f to %.9f" % (j, before[j], after[j]))
41+
# like G53.4 and G53.5 it moves under the G0 in force, no G0 on the line
42+
after = mdi("G53.7 J2=-3")
43+
if abs(after[2] + 3) > 1e-6:
44+
error("G53.7 J2=-3 under the G0 in force left joint 2 at %.6f" % after[2])
4145
after = mdi("G53.7 G0 J2=0 J[2+2]=0")
4246
if abs(after[2]) > 1e-6 or abs(after[SECONDARY]) > 1e-6:
4347
error("G53.7 J2=0 J4=0 did not put joints 2 and 4 at zero")

0 commit comments

Comments
 (0)