Skip to content

Commit d69b15c

Browse files
committed
motion: wheeljogging *.jog-accel-fraction hal pins
new motion hal pins: axis.L.jog-accel-fraction joint.N.jog-accel-fraction Hal pins specify reduced acceleration for wheel jogging to reduce impulsive motion when jog count changes occur at low frequency. The pins specify a fraction (between 0 and 1) of the corresponding ini setting for [*]MAX_ACCELERATION. Values less than zero or more than 1 are ignored. When jog-counts are increased/decreased slowly, the use of full acceleration can cause disconcerting motion or shaking on machines with high acceleration capabilities. This feature may be used with or without auxiliary lowpass filtering of the *.jog-counts inputs. Note: Lowpass filtering of jog-counts smooths motion when jog-counts changes are sustained but is less effective for single event or low frequency count changes because the leading/trailing accel occurs at the ini setting for max_acceleration.
1 parent c8f6b32 commit d69b15c

File tree

5 files changed

+50
-5
lines changed

5 files changed

+50
-5
lines changed

docs/man/man9/motion.9

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ When TRUE (and in manual mode), any change to "jog-counts" will result in motion
4040
\fBaxis.\fIL\fB.jog-scale\fR IN FLOAT
4141
Sets the distance moved for each count on "jog-counts", in machine units.
4242

43+
.TP
44+
\fBaxis.\fIL\fB.jog-accel-fraction\fR IN FLOAT
45+
Sets acceleration for wheel jogging to a fraction of the ini max_acceleration for
46+
the axis. Values greater than 1 or less than zero are ignored.
47+
4348
.TP
4449
\fBaxis.\fIL\fB.jog-vel-mode\fR IN BIT
4550
When FALSE (the default), the jogwheel operates in position mode. The axis will move exactly jog-scale units for each count, regardless of how long that might take. When TRUE, the wheel operates in velocity mode - motion stops when the wheel stops, even if that means the commanded motion is not completed.
@@ -109,6 +114,11 @@ When TRUE (and in manual mode), any change to "jog-counts" will result in motion
109114
\fBjoint.\fIN\fB.jog-scale\fR IN FLOAT
110115
Sets the distance moved for each count on "jog-counts", in machine units.
111116

117+
.TP
118+
\fBjoint.\fIN\fB.jog-accel-fraction\fR IN FLOAT
119+
Sets acceleration for wheel jogging to a fraction of the ini max_acceleration for
120+
the joint. Values greater than 1 or less than zero are ignored.
121+
112122
.TP
113123
\fBjoint.\fIN\fB.jog-vel-mode\fR IN BIT
114124
When FALSE (the default), the jogwheel operates in position mode. The joint will move exactly jog-scale units for each count, regardless of how long that might take. When TRUE, the wheel operates in velocity mode - motion stops when the wheel stops, even if that means the commanded motion is not completed.

docs/src/getting-started/updating-linuxcnc.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,15 @@ with a minimal number of ini file settings.
10451045
Commits to unreleased branches may make changes that affect testers
10461046
and early-adopters of the unreleased software.
10471047

1048+
=== Motion pins
1049+
1050+
New pins (see the motion man page for more info):
1051+
1052+
---
1053+
axis.L.jog-accel-fraction
1054+
joint.N.jog-accel-fraction
1055+
---
1056+
10481057
=== Hal pins
10491058

10501059
Name changes:

src/emc/motion/control.c

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,7 @@ static void handle_jjogwheels(void)
855855
static int first_pass = 1; /* used to set initial conditions */
856856

857857
for (joint_num = 0; joint_num < emcmotConfig->numJoints; joint_num++) {
858+
double jaccel_limit;
858859
/* point to joint data */
859860
joint_data = &(emcmot_hal_data->joint[joint_num]);
860861
joint = &joints[joint_num];
@@ -863,6 +864,13 @@ static void handle_jjogwheels(void)
863864
continue;
864865
}
865866

867+
// disallow accel bogus fractions
868+
if ( (*(joint_data->jjog_accel_fraction) > 1)
869+
|| (*(joint_data->jjog_accel_fraction) < 0) ) {
870+
jaccel_limit = joint->acc_limit;
871+
} else {
872+
jaccel_limit = (*(joint_data->jjog_accel_fraction)) * joint->acc_limit;
873+
}
866874

867875
/* get counts from jogwheel */
868876
new_jjog_counts = *(joint_data->jjog_counts);
@@ -951,7 +959,7 @@ static void handle_jjogwheels(void)
951959
if ( *(joint_data->jjog_vel_mode) ) {
952960
double v = joint->vel_limit * emcmotStatus->net_feed_scale;
953961
/* compute stopping distance at max speed */
954-
stop_dist = v * v / ( 2 * joint->acc_limit);
962+
stop_dist = v * v / ( 2 * jaccel_limit);
955963
/* if commanded position leads the actual position by more
956964
than stopping distance, discard excess command */
957965
if ( pos > joint->pos_cmd + stop_dist ) {
@@ -963,7 +971,7 @@ static void handle_jjogwheels(void)
963971
/* set target position and use full velocity and accel */
964972
joint->free_tp.pos_cmd = pos;
965973
joint->free_tp.max_vel = joint->vel_limit;
966-
joint->free_tp.max_acc = joint->acc_limit;
974+
joint->free_tp.max_acc = jaccel_limit;
967975
/* lock out other jog sources */
968976
joint->wheel_jjog_active = 1;
969977
/* and let it go */
@@ -993,8 +1001,18 @@ static void handle_ajogwheels(void)
9931001
if ( emcmotStatus->on_soft_limit ) { return; }
9941002

9951003
for (axis_num = 0; axis_num < EMCMOT_MAX_AXIS; axis_num++) {
1004+
double aaccel_limit;
9961005
axis = &axes[axis_num];
997-
axis_data = &(emcmot_hal_data->axis[axis_num]);
1006+
axis_data = &(emcmot_hal_data->axis[axis_num]);
1007+
1008+
// disallow accel bogus fractions
1009+
if ( (*(axis_data->ajog_accel_fraction) > 1)
1010+
|| (*(axis_data->ajog_accel_fraction) < 0) ) {
1011+
aaccel_limit = axis->acc_limit;
1012+
} else {
1013+
aaccel_limit = *(axis_data->ajog_accel_fraction) * axis->acc_limit;
1014+
}
1015+
9981016
new_ajog_counts = *(axis_data->ajog_counts);
9991017
delta = new_ajog_counts - axis->old_ajog_counts;
10001018
axis->old_ajog_counts = new_ajog_counts;
@@ -1025,7 +1043,7 @@ static void handle_ajogwheels(void)
10251043
if ( *(axis_data->ajog_vel_mode) ) {
10261044
double v = axis->vel_limit;
10271045
/* compute stopping distance at max speed */
1028-
stop_dist = v * v / ( 2 * axis->acc_limit);
1046+
stop_dist = v * v / ( 2 * aaccel_limit);
10291047
/* if commanded position leads the actual position by more
10301048
than stopping distance, discard excess command */
10311049
if ( pos > axis->pos_cmd + stop_dist ) {
@@ -1038,7 +1056,7 @@ static void handle_ajogwheels(void)
10381056
if (pos < axis->min_pos_limit) { break; }
10391057
axis->teleop_tp.pos_cmd = pos;
10401058
axis->teleop_tp.max_vel = axis->vel_limit;
1041-
axis->teleop_tp.max_acc = axis->acc_limit;
1059+
axis->teleop_tp.max_acc = aaccel_limit;
10421060
axis->wheel_ajog_active = 1;
10431061
axis->teleop_tp.enable = 1;
10441062
}

src/emc/motion/mot_priv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ typedef struct {
7474
hal_s32_t *jjog_counts; /* WPI: jogwheel position input */
7575
hal_bit_t *jjog_enable; /* RPI: enable jogwheel */
7676
hal_float_t *jjog_scale; /* RPI: distance to jog on each count */
77+
hal_float_t *jjog_accel_fraction; /* RPI: to limit wheel jog accel */
7778
hal_bit_t *jjog_vel_mode; /* RPI: true for "velocity mode" jogwheel */
7879

7980
} joint_hal_t;
@@ -88,6 +89,7 @@ typedef struct {
8889
hal_s32_t *ajog_counts; /* WPI: jogwheel position input */
8990
hal_bit_t *ajog_enable; /* RPI: enable jogwheel */
9091
hal_float_t *ajog_scale; /* RPI: distance to jog on each count */
92+
hal_float_t *ajog_accel_fraction; /* RPI: to limit wheel jog accel */
9193
hal_bit_t *ajog_vel_mode; /* RPI: true for "velocity mode" jogwheel */
9294
hal_bit_t *kb_ajog_active; /* RPI: executing keyboard jog */
9395
hal_bit_t *wheel_ajog_active;/* RPI: executing handwheel jog */

src/emc/motion/motion.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,9 @@ static int export_joint(int num, joint_hal_t * addr)
554554
if ((retval = hal_pin_bit_newf(HAL_OUT, &(addr->homing), mot_comp_id, "joint.%d.homing", num)) != 0) return retval;
555555
if ((retval = hal_pin_s32_newf(HAL_OUT, &(addr->home_state), mot_comp_id, "joint.%d.home-state", num)) != 0) return retval;
556556

557+
if ((retval = hal_pin_float_newf(HAL_IN,&(addr->jjog_accel_fraction), mot_comp_id,"joint.%d.jog-accel-fraction", num)) != 0) return retval;
558+
*addr->jjog_accel_fraction = 1.0; // fraction of accel for wheel jjogs
559+
557560
if ( unlock_joints_mask & (1 << num) ) {
558561
// these pins may be needed for rotary joints
559562
rtapi_print_msg(RTAPI_MSG_WARN,"motion.c: Creating unlock hal pins for joint %d\n",num);
@@ -579,6 +582,9 @@ static int export_axis(char c, axis_hal_t * addr)
579582
if ((retval = hal_pin_bit_newf(HAL_OUT, &(addr->kb_ajog_active), mot_comp_id,"axis.%c.kb-jog-active", c)) != 0) return retval;
580583
if ((retval = hal_pin_bit_newf(HAL_OUT, &(addr->wheel_ajog_active),mot_comp_id,"axis.%c.wheel-jog-active", c)) != 0) return retval;
581584

585+
if ((retval = hal_pin_float_newf(HAL_IN,&(addr->ajog_accel_fraction), mot_comp_id,"axis.%c.jog-accel-fraction", c)) != 0) return retval;
586+
*addr->ajog_accel_fraction = 1.0; // fraction of accel for wheel ajogs
587+
582588
rtapi_set_msg_level(msg);
583589
return 0;
584590
}

0 commit comments

Comments
 (0)