Skip to content

Commit 60972df

Browse files
authored
Merge pull request #4680 from grandixximo/g282-homing-runs
task: count a G28.2 homing run that ends between two status reads
2 parents f5120ac + 92c9fac commit 60972df

7 files changed

Lines changed: 22 additions & 0 deletions

File tree

‎src/emc/motion/control.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2276,6 +2276,9 @@ static void update_status(void)
22762276
}
22772277

22782278
emcmotStatus->jogging_active = hal_get_bool(emcmot_hal_data->jog_is_active);
2279+
if (get_homing_is_active() && !emcmotStatus->homing_active) {
2280+
emcmotStatus->homing_runs++;
2281+
}
22792282
emcmotStatus->homing_active = get_homing_is_active();
22802283

22812284
/*! \todo FIXME - the rest of this function is stuff that was apparently

‎src/emc/motion/motion.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,9 @@ Suggestion: Split this in to an Error and a Status flag register..
687687
Aggregate: stays true across the gap between
688688
HOME_SEQUENCE groups, when every joint's per-joint
689689
.homing flag is momentarily false. */
690+
unsigned int homing_runs; /* counts homing_active going true, so a run
691+
that starts and ends between two status reads
692+
still shows */
690693

691694
int switchkins_seq; /* echoes the config counter once acted on */
692695
int switchkins_type; /* switchkins type now in force */

‎src/emc/nml_intf/emc.cc‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,6 +1843,7 @@ void EMC_MOTION_STAT::update(CMS * cms)
18431843
cms->update(numExtraJoints);
18441844
cms->update(jogging_active);
18451845
cms->update(homing_active);
1846+
cms->update(homing_runs);
18461847
cms->update(heartbeat);
18471848
}
18481849

‎src/emc/nml_intf/emc_nml.hh‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,10 @@ class EMC_MOTION_STAT:public EMC_MOTION_STAT_MSG {
11901190
// groups, where every joint momentarily reads .homing == false while the
11911191
// machine is still homing (see the race note in motion/homing.c).
11921192
bool homing_active;
1193+
// counts homing_active going true; a homing run shorter than the gap
1194+
// between two status reads leaves this changed even if homing_active
1195+
// never read true
1196+
unsigned int homing_runs;
11931197
uint64_t heartbeat; // motion controller's heartbeat counter
11941198

11951199
};

‎src/emc/nml_intf/emcops.cc‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ EMC_MOTION_STAT::EMC_MOTION_STAT()
127127
numExtraJoints(0),
128128
jogging_active(0),
129129
homing_active(false),
130+
homing_runs(0),
130131
heartbeat(0)
131132
{
132133
}

‎src/emc/task/emctaskmain.cc‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ static int homingWaitJoint = -1; // joint (-1 = all) we're waiting on
418418
static bool homingWaiting = false; // true while EMC_TASK_EXEC::WAITING_FOR_HOMING is active
419419
static bool homingStarted = false; // true once we've observed .homing go true at least once
420420
static double homingIssueTime = 0.0; // etime() when issued, for the start-timeout below
421+
static unsigned int homingRunsAtIssue = 0; // motion's homing_runs before the home was issued
421422
// Some motion-side guards (e.g. "must be in joint mode to home",
422423
// motion.homing-inhibit, already-homing) reject with reportError() and a
423424
// bare return, without setting commandStatus to a failure -- so a rejected
@@ -1744,6 +1745,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd)
17441745
homingWaitJoint = target_joint;
17451746
homingStarted = false;
17461747
homingIssueTime = etime();
1748+
homingRunsAtIssue = emcStatus->motion.homing_runs;
17471749
homingWaiting = true;
17481750
retval = emcJointHome(target_joint);
17491751
if (retval != 0) {
@@ -2926,6 +2928,13 @@ static int emcTaskExecute(void)
29262928
homingStarted = true;
29272929
break; // still running; no timeout once started (see HOMING_START_TIMEOUT comment)
29282930
}
2931+
// A short run (homing in place takes a few servo cycles) can start
2932+
// and end between two of task's status reads. On a re-home the
2933+
// joints read homed before and after it, so only motion's run
2934+
// counter shows that it happened.
2935+
if (emcStatus->motion.homing_runs != homingRunsAtIssue) {
2936+
homingStarted = true;
2937+
}
29292938
if (!homingStarted) {
29302939
// Never observed homing go active: motion silently rejected
29312940
// it (a guard like "must be in joint mode", or

‎src/emc/task/taskintf.cc‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2163,6 +2163,7 @@ int emcMotionUpdate(EMC_MOTION_STAT * stat)
21632163

21642164
stat->jogging_active = emcmotStatus.jogging_active;
21652165
stat->homing_active = emcmotStatus.homing_active;
2166+
stat->homing_runs = emcmotStatus.homing_runs;
21662167
stat->numExtraJoints = emcmotStatus.numExtraJoints;
21672168

21682169
// set the status flag

0 commit comments

Comments
 (0)