Skip to content

Commit cfd70bf

Browse files
committed
motion: modify jog-inhibit. Add jog-stop and jog-stop-immediate
jog-inhibit now solely inhibits a jog from starting if True. jog-stop will abort an active jog following associated acceleration values if True. jog-stop-immediate will abort an active jog immediately (this may result in joint following errors) if True.
1 parent b9d1e53 commit cfd70bf

7 files changed

Lines changed: 77 additions & 77 deletions

File tree

docs/man/man9/motion.9

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,19 @@ TRUE if all active joints is homed.
212212
\fBmotion.jog\-inhibit\fR IN BIT
213213
If this bit is TRUE, jogging of any joint or axis is disallowed and an error
214214
is reported.
215+
216+
.TP
217+
\fBmotion.jog\-stop\fR IN BIT
218+
If any jog is active when the pin state changes to TRUE then that jog will be
219+
stopped following the associated acceleration values.
220+
221+
.TP
222+
\fBmotion.jog\-stop\-immediate\fR IN BIT
215223
If any jog is active when the pin state changes to TRUE then that jog will be
216-
stopped.
224+
stopped immediately.
217225

218226
.TP
219-
\fBmotion.jog\-is-active\fR OUT BIT
227+
\fBmotion.jog\-is\-active\fR OUT BIT
220228
TRUE if any joint or axis is jogging.
221229

222230
.TP

src/emc/motion/axis.c

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -317,64 +317,43 @@ void axis_jog_abs(int axis_num, double offset, double vel)
317317
axis->teleop_tp.enable = 1;
318318
}
319319

320-
void axis_jog_abort(int axis_num)
320+
bool axis_jog_abort(int axis_num, bool immediate)
321321
{
322+
bool aborted = 0;
322323
emcmot_axis_t *axis = &axis_array[axis_num];
323-
axis->teleop_tp.enable = 0;
324-
}
325-
326-
void axis_jog_abort_all(void)
327-
{
328-
int n;
329-
for (n = 0; n < EMCMOT_MAX_AXIS; n++) {
330-
axis_jog_abort(n);
324+
if (axis->teleop_tp.enable) {
325+
aborted = 1;
331326
}
332-
}
333-
334-
bool axis_jog_immediate_stop_all(void)
335-
{
336-
int n;
337-
bool aborted = false;
338-
339-
for (n = 0; n < EMCMOT_MAX_AXIS; n++) {
340-
emcmot_axis_t *axis = &axis_array[n];
341-
if (axis->teleop_tp.enable) {
342-
aborted = true;
343-
}
344-
axis->teleop_tp.enable = 0;
327+
axis->teleop_tp.enable = 0;
328+
axis->kb_ajog_active = 0;
329+
axis->wheel_ajog_active = 0;
330+
if (immediate) {
345331
axis->teleop_tp.curr_vel = 0.0;
346332
}
347333
return aborted;
348334
}
349335

350-
void axis_jog_inhibit_all(void)
336+
bool axis_jog_abort_all(bool immediate)
351337
{
352338
int n;
353-
emcmot_axis_t *axis;
354-
339+
bool aborted = 0;
355340
for (n = 0; n < EMCMOT_MAX_AXIS; n++) {
356-
axis = &axis_array[n];
357-
if (axis->kb_ajog_active || axis->wheel_ajog_active) {
358-
axis->teleop_tp.enable = 0;
359-
axis->teleop_tp.curr_vel = 0.0;
360-
axis->kb_ajog_active = 0;
361-
axis->wheel_ajog_active = 0;
362-
}
341+
aborted = aborted || axis_jog_abort(n, immediate);
363342
}
343+
return aborted;
364344
}
365345

366346
bool axis_jog_is_active(void)
367347
{
368348
int n;
369349
emcmot_axis_t *axis;
370-
371350
for (n = 0; n < EMCMOT_MAX_AXIS; n++) {
372351
axis = &axis_array[n];
373352
if (axis->kb_ajog_active || axis->wheel_ajog_active) {
374-
return true;
353+
return 1;
375354
}
376355
}
377-
return false;
356+
return 0;
378357
}
379358

380359
void axis_handle_jogwheels(bool motion_teleop_flag, bool motion_enable_flag, bool homing_is_active)

src/emc/motion/axis.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ void axis_check_constraints(double pos[], int failing_axes[]);
2020
void axis_jog_cont(int axis_num, double vel, long servo_period);
2121
void axis_jog_incr(int axis_num, double offset, double vel, long servo_period);
2222
void axis_jog_abs(int axis_num, double offset, double vel);
23-
void axis_jog_abort_all(void);
24-
void axis_jog_abort(int axis_num);
25-
bool axis_jog_immediate_stop_all(void);
26-
void axis_jog_inhibit_all(void);
23+
bool axis_jog_abort_all(bool immediate);
24+
bool axis_jog_abort(int axis_num, bool immediate);
2725
bool axis_jog_is_active(void);
2826

2927
void axis_output_to_hal(double *pcmd_p[]);

src/emc/motion/command.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ void emcmotCommandHandler(void *arg, long servo_period)
503503
rtapi_print_msg(RTAPI_MSG_DBG, " %d", joint_num);
504504
/* check for coord or free space motion active */
505505
if (GET_MOTION_TELEOP_FLAG()) {
506-
axis_jog_abort_all();
506+
axis_jog_abort_all(0);
507507
} else if (GET_MOTION_COORD_FLAG()) {
508508
tpAbort(&emcmotInternal->coord_tp);
509509
} else {
@@ -538,7 +538,7 @@ void emcmotCommandHandler(void *arg, long servo_period)
538538
if (GET_MOTION_TELEOP_FLAG()) {
539539
/* tell teleop planner to stop */
540540
if ((emcmotCommand->axis >= 0) && (emcmotCommand->axis < EMCMOT_MAX_AXIS)) {
541-
axis_jog_abort(emcmotCommand->axis);
541+
axis_jog_abort(emcmotCommand->axis, 0);
542542
}
543543
} else if (GET_MOTION_COORD_FLAG()) {
544544
/* do nothing in coord mode */
@@ -557,7 +557,7 @@ void emcmotCommandHandler(void *arg, long servo_period)
557557
break;
558558

559559
case EMCMOT_FREE:
560-
axis_jog_abort_all();
560+
axis_jog_abort_all(0);
561561
/* change the mode to free mode motion (joint mode) */
562562
/* can be done at any time */
563563
/* this code doesn't actually make the transition, it merely
@@ -820,7 +820,7 @@ void emcmotCommandHandler(void *arg, long servo_period)
820820
joint->kb_jjog_active = 1;
821821
/* and let it go */
822822
joint->free_tp.enable = 1;
823-
axis_jog_abort_all();
823+
axis_jog_abort_all(0);
824824
/*! \todo FIXME - should we really be clearing errors here? */
825825
SET_JOINT_ERROR_FLAG(joint, 0);
826826
/* clear joints homed flag(s) if we don't have forward kins.
@@ -897,7 +897,7 @@ void emcmotCommandHandler(void *arg, long servo_period)
897897
joint->kb_jjog_active = 1;
898898
/* and let it go */
899899
joint->free_tp.enable = 1;
900-
axis_jog_abort_all();
900+
axis_jog_abort_all(0);
901901
SET_JOINT_ERROR_FLAG(joint, 0);
902902
/* clear joint homed flag(s) if we don't have forward kins.
903903
Otherwise, a transition into coordinated mode will incorrectly

src/emc/motion/control.c

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ static double *pcmd_p[EMCMOT_MAX_AXIS];
8686
*/
8787
static void process_inputs(void);
8888

89+
/* 'joint_jog_abort_all()' if either jog-stop or jog-stop-immediate
90+
become True while jogging then the jog will abort.
91+
jog-stop will stop the active jog following the associated
92+
acceleration values.
93+
jog-stop-immediate will immediately stop jogging (potentially
94+
causing joint following errors).
95+
*/
96+
static void joint_jog_abort_all(bool immediate);
97+
8998
/* 'do forward kins()' takes the position feedback in joint coords
9099
and applies the forward kinematics to it to generate feedback
91100
in Cartesean coordinates. It has code to handle machines that
@@ -529,24 +538,30 @@ static void process_inputs(void)
529538
}
530539
}
531540
}
532-
// if jog in progress
533-
if (enables & *(emcmot_hal_data->jog_inhibit) && *(emcmot_hal_data->jog_is_active)) {
534-
// stop any joint jog
535-
int jNum;
536-
for (jNum = 0; jNum < NO_OF_KINS_JOINTS; jNum++) {
537-
joint = &joints[jNum];
538-
if (joint->kb_jjog_active || joint->wheel_jjog_active) {
539-
joint->free_tp.enable = 0;
540-
joint->free_tp.curr_vel = 0.0;
541-
joint->kb_jjog_active = 0;
542-
joint->wheel_jjog_active = 0;
543-
}
541+
// if jog in progress stop the jog if requested
542+
if (enables & *(emcmot_hal_data->jog_is_active) && (*(emcmot_hal_data->jog_stop) || *(emcmot_hal_data->jog_stop_immediate))) {
543+
joint_jog_abort_all(*(emcmot_hal_data->jog_stop_immediate));
544+
axis_jog_abort_all(*(emcmot_hal_data->jog_stop_immediate));
545+
if (*(emcmot_hal_data->jog_stop_immediate)) {
546+
reportError("Jog aborted by jog-stop-immediate");
547+
} else {
548+
reportError("Jog aborted by jog-stop");
544549
}
545-
// stop any axis jog
546-
axis_jog_inhibit_all();
550+
}
551+
}
547552

548-
*(emcmot_hal_data->jog_is_active) = 0;
549-
reportError("Jog aborted by jog-inhibit");
553+
static void joint_jog_abort_all(bool immediate)
554+
{
555+
int jNum;
556+
emcmot_joint_t *joint;
557+
for (jNum = 0; jNum < NO_OF_KINS_JOINTS; jNum++) {
558+
joint = &joints[jNum];
559+
joint->free_tp.enable = 0;
560+
joint->kb_jjog_active = 0;
561+
joint->wheel_jjog_active = 0;
562+
if (immediate) {
563+
joint->free_tp.curr_vel = 0.0;
564+
}
550565
}
551566
}
552567

@@ -733,7 +748,7 @@ static void process_probe_inputs(void)
733748
if(!aborted) aborted=2;
734749
}
735750
}
736-
if (axis_jog_immediate_stop_all()) {
751+
if (axis_jog_abort_all(1)) {
737752
aborted = 3;
738753
}
739754

@@ -858,7 +873,7 @@ static void set_operating_mode(void)
858873
we just went into disabled state */
859874
}
860875

861-
axis_jog_immediate_stop_all();
876+
axis_jog_abort_all(1);
862877

863878
SET_MOTION_ENABLE_FLAG(0);
864879
/* don't clear the motion error flag, since that may signify why we
@@ -1301,7 +1316,7 @@ static void get_pos_cmds(long period)
13011316
break;
13021317

13031318
case EMCMOT_MOTION_COORD:
1304-
axis_jog_immediate_stop_all();
1319+
axis_jog_abort_all(1);
13051320

13061321
/* check joint 0 to see if the interpolators are empty */
13071322
coord_cubic_active = 1;
@@ -1512,7 +1527,7 @@ static void get_pos_cmds(long period)
15121527
&& GET_MOTION_TELEOP_FLAG()
15131528
&& emcmotStatus->on_soft_limit ) {
15141529
SET_MOTION_ERROR_FLAG(1);
1515-
axis_jog_immediate_stop_all();
1530+
axis_jog_abort_all(1);
15161531
}
15171532
if (ext_offset_teleop_limit || ext_offset_coord_limit) {
15181533
*(emcmot_hal_data->eoffset_limited) = 1;
@@ -1810,7 +1825,6 @@ static void output_to_hal(void)
18101825
joint_hal_t *joint_data;
18111826
static int old_motion_index[EMCMOT_MAX_SPINDLES] = {0};
18121827
static int old_hal_index[EMCMOT_MAX_SPINDLES] = {0};
1813-
bool activeJog = 0;
18141828

18151829
/* output machine info to HAL for scoping, etc */
18161830
*(emcmot_hal_data->motion_enabled) = GET_MOTION_ENABLE_FLAG();
@@ -2015,17 +2029,12 @@ static void output_to_hal(void)
20152029
+ joint->motor_offset;
20162030
continue;
20172031
}
2018-
// joint jog is in progress
2019-
if (joint->kb_jjog_active || joint->wheel_jjog_active) {
2020-
activeJog = 1;
2021-
}
20222032
} // for joint_num
20232033

20242034
axis_output_to_hal(pcmd_p);
2025-
if (axis_jog_is_active()) {
2026-
activeJog = 1;
2027-
}
2028-
*(emcmot_hal_data->jog_is_active) = activeJog;
2035+
2036+
*(emcmot_hal_data->jog_is_active) = axis_jog_is_active() || joint_jog_is_active();
2037+
20292038
}
20302039

20312040
static void update_status(void)
@@ -2110,6 +2119,8 @@ static void update_status(void)
21102119
emcmotStatus->misc_error[misc_error] = *(emcmot_hal_data->misc_error[misc_error]);
21112120
}
21122121

2122+
emcmotStatus->jogging_active = *(emcmot_hal_data->jog_is_active);
2123+
21132124
/*! \todo FIXME - the rest of this function is stuff that was apparently
21142125
dropped in the initial move from emcmot.c to control.c. I
21152126
don't know how much is still needed, and how much is baggage.
@@ -2125,8 +2136,6 @@ static void update_status(void)
21252136
emcmotStatus->motionType = tpGetMotionType(&emcmotInternal->coord_tp);
21262137
emcmotStatus->queueFull = tcqFull(&emcmotInternal->coord_tp.queue);
21272138

2128-
emcmotStatus->jogging_active = axis_jog_is_active()
2129-
|| joint_jog_is_active();
21302139
/* check to see if we should pause in order to implement
21312140
single emcmotStatus->stepping */
21322141

src/emc/motion/mot_priv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ typedef struct {
129129
hal_bit_t *feed_inhibit; /* RPI: set TRUE to stop motion (non maskable)*/
130130
hal_bit_t *homing_inhibit; /* RPI: set TRUE to inhibit homing*/
131131
hal_bit_t *jog_inhibit; /* RPI: set TRUE to inhibit jogging*/
132+
hal_bit_t *jog_stop; /* RPI: set TRUE to stop jogging following accel values*/
133+
hal_bit_t *jog_stop_immediate; /* RPI: set TRUE to stop jogging immediately*/
132134
hal_bit_t *jog_is_active; /* RPI: TRUE if active jogging*/
133135
hal_bit_t *tp_reverse; /* Set true if trajectory planner is running in reverse*/
134136
hal_bit_t *motion_enabled; /* RPI: motion enable for all joints */

src/emc/motion/motion.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,8 @@ static int init_hal_io(void)
475475
CALL_CHECK(hal_pin_bit_newf(HAL_IN, &(emcmot_hal_data->feed_inhibit), mot_comp_id, "motion.feed-inhibit"));
476476
CALL_CHECK(hal_pin_bit_newf(HAL_IN, &(emcmot_hal_data->homing_inhibit), mot_comp_id, "motion.homing-inhibit"));
477477
CALL_CHECK(hal_pin_bit_newf(HAL_IN, &(emcmot_hal_data->jog_inhibit), mot_comp_id, "motion.jog-inhibit"));
478+
CALL_CHECK(hal_pin_bit_newf(HAL_IN, &(emcmot_hal_data->jog_stop), mot_comp_id, "motion.jog-stop"));
479+
CALL_CHECK(hal_pin_bit_newf(HAL_IN, &(emcmot_hal_data->jog_stop_immediate), mot_comp_id, "motion.jog-stop-immediate"));
478480
CALL_CHECK(hal_pin_bit_newf(HAL_OUT, &(emcmot_hal_data->tp_reverse), mot_comp_id, "motion.tp-reverse"));
479481
CALL_CHECK(hal_pin_bit_newf(HAL_IN, &(emcmot_hal_data->enable), mot_comp_id, "motion.enable"));
480482
CALL_CHECK(hal_pin_bit_newf(HAL_OUT, &(emcmot_hal_data->is_all_homed), mot_comp_id, "motion.is-all-homed"));
@@ -611,6 +613,8 @@ static int init_hal_io(void)
611613
*(emcmot_hal_data->feed_inhibit) = 0;
612614
*(emcmot_hal_data->homing_inhibit) = 0;
613615
*(emcmot_hal_data->jog_inhibit) = 0;
616+
*(emcmot_hal_data->jog_stop) = 0;
617+
*(emcmot_hal_data->jog_stop_immediate) = 0;
614618
*(emcmot_hal_data->is_all_homed) = 0;
615619

616620
*(emcmot_hal_data->probe_input) = 0;

0 commit comments

Comments
 (0)