-
Notifications
You must be signed in to change notification settings - Fork 1.3k
G28.2: home the machine from G-code (all joints, or Pn per joint) #4172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
78c72a6
11397cf
23e346a
c23e83d
0a5b085
a945dca
4135216
fd0f360
2e64c5e
4997c0d
d6d7241
99aa401
99803c4
f9edd58
42bc5ca
4f582cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,6 +73,7 @@ as the 'L number', and so on for any other letter. | |
| |<<gcode:g17-g19.1,G17 - G19.1>> |Plane Select | ||
| |<<gcode:g20-g21,G20 G21>> |Set Units of Measure | ||
| |<<gcode:g28-g28.1,G28 - G28.1>> |Go to Predefined Position | ||
| |<<gcode:g28.2,G28.2>> |Home from G-code | ||
| |<<gcode:g30-g30.1,G30 - G30.1>> |Go to Predefined Position | ||
| |<<gcode:g33,G33>> |Spindle Synchronized Motion | ||
| |<<gcode:g33.1,G33.1>> |Rigid Tapping | ||
|
|
@@ -997,6 +998,48 @@ It is an error if : | |
|
|
||
| * Cutter Compensation is turned on | ||
|
|
||
| [[gcode:g28.2]] | ||
| == G28.2 Home from G-code(((G28.2 Home from G-code))) | ||
|
|
||
| This non-modal code lets a program or MDI line reference the machine | ||
| instead of requiring the operator to use the GUI's *Home All* button. It | ||
| follows the same modal-group-0 pattern as `G28.1`/`G30.1` and takes no axis | ||
| words. | ||
|
|
||
| * 'G28.2' - runs the homing cycle on all joints, in `HOME_SEQUENCE` order | ||
| (the same operation as the GUI *Home All*). | ||
| * 'G28.2 Pn' - runs the homing cycle on joint 'n' only, where 'n' is the | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Worth also stating the positive shared- |
||
| 0-based joint number matching its `[JOINT_n]` INI section (the same | ||
| numbering used by `HOME_SEQUENCE` and by joint jogging). Other joints are | ||
| left as they are. On a synchronized (negative `HOME_SEQUENCE`) joint pair, | ||
| Pn on either joint homes both. | ||
|
|
||
| .G28.2 Example Lines | ||
| [source,ngc] | ||
| ---- | ||
| G28.2 (home all joints, in HOME_SEQUENCE order) | ||
| G28.2 P1 (home joint 1 only) | ||
| ---- | ||
|
|
||
| A queued `G28.2` dips motion into free mode for the duration of the homing | ||
| cycle and restores whatever mode (manual/MDI/auto) was active once it | ||
| finishes, so the mode dip is invisible at the task level. Motion still | ||
| enforces its own safety: the home is honored only when the machine is idle | ||
| (in position with no queued motion) or in joint mode, and a home is refused | ||
| mid-motion. Homing inhibits and per-joint limit handling are unchanged. | ||
|
|
||
| [NOTE] | ||
| There is no G-code unhome. Clearing a joint's reference is done from the | ||
| GUI, halui or linuxcncrsh. | ||
|
|
||
| [NOTE] | ||
| `G28.2` is a LinuxCNC extension; there is no standard Fanuc equivalent. | ||
|
|
||
| It is an error if : | ||
|
|
||
| * Cutter Compensation is turned on | ||
| * 'Pn' names a joint number that does not exist on the machine | ||
|
|
||
| [[gcode:g30-g30.1]] | ||
| == G30, G30.1 Go/Set Predefined Position(((G30 Go/Set Predefined Position))) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1494,9 +1494,12 @@ void emcmotCommandHandler_locked(void *arg, long servo_period) | |
| rtapi_print_msg(RTAPI_MSG_DBG, "JOINT_HOME"); | ||
| rtapi_print_msg(RTAPI_MSG_DBG, " %d", joint_num); | ||
|
|
||
| if (emcmotStatus->motion_state != EMCMOT_MOTION_FREE) { | ||
| /* can't home unless in free mode */ | ||
| reportError(_("must be in joint mode to home")); | ||
| /* Normally homing requires free (joint) mode. Allow it also when | ||
| * motion is otherwise IDLE (in position, nothing queued) so a | ||
| * G-code-triggered home (G28.2) works from MDI / a program. */ | ||
| if (emcmotStatus->motion_state != EMCMOT_MOTION_FREE | ||
| && !(GET_MOTION_INPOS_FLAG() && emcmotStatus->depth == 0)) { | ||
| reportError(_("must be in joint mode (or idle) to home")); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This now accepts an immediate home whenever motion is idle, but |
||
| return; | ||
| } | ||
| if (hal_get_bool(emcmot_hal_data->homing_inhibit)) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3168,6 +3168,63 @@ Called by: convert_modal_0. | |
|
|
||
| */ | ||
|
|
||
| /*! convert_home_cycle | ||
|
|
||
| Handles G28.2 (run the homing cycle) from a G-code line, so machines can | ||
| reference themselves from MDI or a program instead of only from the GUI's | ||
| *Home All* button. The bare form homes all joints, in HOME_SEQUENCE order. | ||
|
|
||
| An optional Pn word homes a single joint by its 0-based joint number | ||
| (matching [JOINT_n] INI section numbering, e.g. P1 -> JOINT_1). This is the | ||
| primitive Sigma1912 asked for in the PR #4172 discussion for re-homing a | ||
| joint that is switched between rotary-axis and spindle use mid-program | ||
| (https://github.com/LinuxCNC/linuxcnc/pull/4172) -- it reuses the existing | ||
| EMC_JOINT_HOME 'joint' field, so it needs no NML change and works | ||
| identically on any kinematics (per grandixximo's review comment on that PR). | ||
| Axis-letter forms (G28.2 X) are deliberately NOT supported: resolving an | ||
| axis letter to a joint needs the kinematics coordinate map and isn't | ||
| trivial even on trivkins (duplicate letters on gantries) -- andypugh's | ||
| review also objected that homing is a joint concept, not an axis one. | ||
|
|
||
| There is deliberately no G-code unhome. A G28.3 was part of the original | ||
| proposal and was dropped during review of PR #4172: neither reviewer could | ||
| name a use for it that a numbered parameter would not serve better, and it | ||
| was the one operation able to leave a running program on an unreferenced | ||
| machine -- the state behind the real-hardware failure Sigma1912 reported. | ||
| The GUI, halui and linuxcncrsh keep their existing unhome. | ||
|
|
||
| On a synchronized (negative HOME_SEQUENCE) joint pair, Pn on either joint | ||
| homes both (motion's existing gantry-homing behavior); on a positive shared | ||
| sequence Pn homes only the named joint -- use the bare form to home both. | ||
|
|
||
| Motion still enforces its own safety (idle / not on limits). The joint | ||
| number is range-checked against the machine's configured joint count in | ||
| task (emcJointHome(), taskintf.cc), which is where that count is known -- | ||
| the interpreter has no joint count in its state. | ||
| */ | ||
| int Interp::convert_home_cycle(block_pointer block, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The interpreter keeps its pre-home current point across the home. Verified: |
||
| setup_pointer settings) | ||
| { | ||
| CHKS((settings->cutter_comp_side != CUTTER_COMP::OFF), | ||
| "Cannot home (G28.2) with cutter radius compensation on"); | ||
|
|
||
| int joint = -1; | ||
| if (block->p_flag) { | ||
| CHKS(((block->p_number < 0.0) || | ||
| (block->p_number != round_to_int(block->p_number))), | ||
| "P value for G28.2 must be a non-negative whole joint number" | ||
| " (omit P to home every joint)"); | ||
| joint = round_to_int(block->p_number); | ||
| } | ||
|
|
||
| if (joint < 0) { | ||
| HOME_CYCLE(); | ||
| } else { | ||
| HOME_CYCLE_JOINT(joint); | ||
| } | ||
| return INTERP_OK; | ||
| } | ||
|
|
||
| int Interp::convert_home(int move, //!< G-code, must be G_28 or G_30 | ||
| block_pointer block, //!< pointer to a block of RS274 instructions | ||
| setup_pointer settings) //!< pointer to machine settings | ||
|
|
@@ -4347,6 +4404,8 @@ int Interp::convert_modal_0(int code, //!< G-code, must be from group 0 | |
| CHP(convert_home(code, block, settings)); | ||
| } else if ((code == G_28_1) || (code == G_30_1)) { | ||
| CHP(convert_savehome(code, block, settings)); | ||
| } else if (code == G_28_2) { | ||
| CHP(convert_home_cycle(block, settings)); | ||
| } else if ((code == G_52) || (code == G_92)) { | ||
| CHP(convert_axis_offsets(code, block, settings)); | ||
| } else if ((code == G_5_3)||(code == G_6_3)) { // jjf | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should the bare form do on a config without
HOME_SEQUENCE?do_home_joint(-1)clearsH[0].homed(homing.c:577) while the sequence machine excludes joints with the unrealizable default sequence, so on a sequence-less config this errors with "did not complete for joint ALL" and leaves joint 0 unhomed and the machine in FREE (verified on sim). That is Home All parity, but 39 in-tree sims and all five test configs in this PR are that class, and onlyPnis tested. Worth stating theHOME_SEQUENCErequirement here, and adding one bare-form test with sequences set?