From 2aaa6bcf63660fa3f413c35ef84733672413d693 Mon Sep 17 00:00:00 2001 From: Luca Toniolo <10792599+grandixximo@users.noreply.github.com> Date: Mon, 9 Nov 2026 17:16:31 +1100 Subject: [PATCH] motion: read the 64-bit axis jog-counts without truncating axis.L.jog-counts is a SINT pin, but the wheel jog read it with hal_get_si32() while the previous count and the delta are 64-bit. When the counts crossed 2^31 the delta came out near -2^32 for one cycle: the target fell outside the limits and the jog was dropped, or with jog-vel-mode the axis ran back by its stopping distance. The joint wheel jog already reads its counts with hal_get_sint(). The jogwheel-axis test now jogs across 2^31. --- src/emc/motion/axis.c | 2 +- tests/motion/jogwheel-axis/test-ui.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/emc/motion/axis.c b/src/emc/motion/axis.c index f6dd8d4aef0..4aa4a26ba13 100644 --- a/src/emc/motion/axis.c +++ b/src/emc/motion/axis.c @@ -447,7 +447,7 @@ void axis_handle_jogwheels(bool motion_teleop_flag, bool motion_enable_flag, boo aaccel_limit = ajog_accel_fraction * axis->acc_limit; } - new_ajog_counts = hal_get_si32(axis_data->ajog_counts); + new_ajog_counts = hal_get_sint(axis_data->ajog_counts); delta = new_ajog_counts - axis->old_ajog_counts; axis->old_ajog_counts = new_ajog_counts; if ( first_pass ) { continue; } diff --git a/tests/motion/jogwheel-axis/test-ui.py b/tests/motion/jogwheel-axis/test-ui.py index 052a8e2a6f8..dc3adba12bb 100755 --- a/tests/motion/jogwheel-axis/test-ui.py +++ b/tests/motion/jogwheel-axis/test-ui.py @@ -53,6 +53,23 @@ def jog_axis(axis_letter, counts=1, scale=0.001): sys.exit(1) +def preset_counts(axis_letter, counts): + # with jog-enable off motion takes the new counts without moving + h['axis-%c-jog-enable' % axis_letter] = 0 + h['axis-%c-jog-counts' % axis_letter] = counts + + timeout = 5.0 + start_time = time.time() + s.poll() + start_beat = s.heartbeat + while s.heartbeat - start_beat < 2: + if time.time() - start_time > timeout: + print("motion heartbeat did not advance") + sys.exit(1) + time.sleep(0.010) + s.poll() + + # # set up pins # shell out to halcmd to make nets to halui and motion @@ -115,5 +132,9 @@ def jog_axis(axis_letter, counts=1, scale=0.001): jog_axis('y', counts=10, scale=-0.025) jog_axis('z', counts=-100, scale=0.100) +# counts crossing 2^31 jog by the count difference +preset_counts('x', 2**31 - 2) +jog_axis('x', counts=4, scale=0.001) + sys.exit(0)