From fa09f88a817823bc53bd688e248cba607b2f80ca Mon Sep 17 00:00:00 2001 From: Peter van Tol Date: Sun, 18 Feb 2024 17:15:19 +0100 Subject: [PATCH 1/5] Fix timing order --- src/litexcnc/driver/modules/litexcnc_stepgen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/litexcnc/driver/modules/litexcnc_stepgen.c b/src/litexcnc/driver/modules/litexcnc_stepgen.c index ced1208..eb9a208 100644 --- a/src/litexcnc/driver/modules/litexcnc_stepgen.c +++ b/src/litexcnc/driver/modules/litexcnc_stepgen.c @@ -210,7 +210,7 @@ int litexcnc_stepgen_config(void *module, uint8_t **data, int period) { dirsetup_cycles = (1 << 13) - 1; } // - convert the timings to the data to be sent to the FPGA - config_data.timings = htobe32((steplen_cycles << 22) + (dirhold_cycles << 12) + (dirsetup_cycles << 0)); + config_data.timings = htobe32((dirsetup_cycles << 20) + (dirhold_cycles << 10) + (steplen_cycles << 0)); // Put the data on the data-stream and advance the pointer memcpy(*data, &config_data, required_config_buffer(stepgen)); From e6678afeb0693b8d3f3b1194b5d688c6103d946e Mon Sep 17 00:00:00 2001 From: Peter van Tol Date: Sun, 18 Feb 2024 17:15:30 +0100 Subject: [PATCH 2/5] Bumpversion --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 66bf786..af66b11 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "litexcnc" -version = "1.2.3" +version = "1.2.4" description = "Generic CNC firmware and driver for FPGA cards which are supported by LiteX" authors = ["Peter van Tol "] license = "GPL-3.0-or-later" From f59da6d705b85e28e35ae2ae0ffb92c6ef287846 Mon Sep 17 00:00:00 2001 From: Peter van Tol Date: Sun, 18 Feb 2024 17:15:54 +0100 Subject: [PATCH 3/5] Update for timings --- CHANGELOG.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6b38e05..6e85f83 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,15 @@ All versions in this changelog have two entries: ``driver`` and ``firmware``. Th have the same version, as communication protocol might change between versions. In the firmware/driver there is a safeguard to prevent miscommunication. +Version 1.2.4 +============= + +Bugfix version to fix timings for stepgen. + +* ``driver``: + + * ``stepgen``: Fix timings (#59). Thanks to *hmnijp* for testing the ``stepgen`` module with a scope. + Version 1.2.3 ============= From bbe73c0a7acf7514747e8d46a341fc45892f2558 Mon Sep 17 00:00:00 2001 From: Peter van Tol Date: Sun, 18 Feb 2024 22:22:58 +0100 Subject: [PATCH 4/5] Fixed checking max velocity --- src/litexcnc/driver/modules/litexcnc_stepgen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/litexcnc/driver/modules/litexcnc_stepgen.c b/src/litexcnc/driver/modules/litexcnc_stepgen.c index eb9a208..bcfbe59 100644 --- a/src/litexcnc/driver/modules/litexcnc_stepgen.c +++ b/src/litexcnc/driver/modules/litexcnc_stepgen.c @@ -303,10 +303,10 @@ int litexcnc_stepgen_prepare_write(void *module, uint8_t **data, int period) { instance->hal.param.max_velocity = 0.0; } else { // Maximum speed is positive and no zero, compare with maximum frequency - if (instance->hal.param.max_velocity > (stepgen->data.max_frequency * fabs(instance->hal.param.position_scale))) { + if (instance->hal.param.max_velocity > (stepgen->data.max_frequency * fabs(instance->data.scale_recip))) { // Limit speed to the maximum. This will lead to joint follow error when the higher speeds are commanded float max_speed_desired = instance->hal.param.max_velocity; - instance->hal.param.max_velocity = stepgen->data.max_frequency * fabs(instance->hal.param.position_scale); + instance->hal.param.max_velocity = stepgen->data.max_frequency * fabs(instance->data.scale_recip); // Maximum speed is too high, complain about it and modify the value if (!instance->memo.error_max_speed_printed) { LITEXCNC_ERR_NO_DEVICE( From e5f776511d4bb5bb7303fd460bdb9c8dcda99800 Mon Sep 17 00:00:00 2001 From: Peter van Tol Date: Sun, 18 Feb 2024 22:24:29 +0100 Subject: [PATCH 5/5] Update with stepgen max speed --- CHANGELOG.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6e85f83..7ace90b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,6 +14,8 @@ Bugfix version to fix timings for stepgen. * ``driver``: * ``stepgen``: Fix timings (#59). Thanks to *hmnijp* for testing the ``stepgen`` module with a scope. + * ``stepgen``: Fix check on maximum speed obeys the maximum step frequency (#59). + Version 1.2.3 =============