Skip to content

Commit

Permalink
Merge pull request #85 from Peter-van-Tol/59-module-stepgen-timing-pa…
Browse files Browse the repository at this point in the history
…rameters-issue

59 module stepgen timing parameters issue
  • Loading branch information
Peter-van-Tol committed Feb 18, 2024
2 parents e1e4285 + e5f7765 commit d203fff
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ 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.
* ``stepgen``: Fix check on maximum speed obeys the maximum step frequency (#59).


Version 1.2.3
=============

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <petertgvantol@gmail.com>"]
license = "GPL-3.0-or-later"
Expand Down
6 changes: 3 additions & 3 deletions src/litexcnc/driver/modules/litexcnc_stepgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit d203fff

Please sign in to comment.