Skip to content

acc,dcc,jerk,homing#1121

Open
kuh0005 wants to merge 1 commit intodevfrom
1120-bugfesto-rotary-axis-acc-dcc-jerk-units-scaling
Open

acc,dcc,jerk,homing#1121
kuh0005 wants to merge 1 commit intodevfrom
1120-bugfesto-rotary-axis-acc-dcc-jerk-units-scaling

Conversation

@kuh0005
Copy link
Copy Markdown
Collaborator

@kuh0005 kuh0005 commented Apr 28, 2026

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Third party dependency update
  • Third party dependency addition

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

Test Configuration:

  • simatix-ax version (apax.yml):
  • ix version:
  • PLC Target system:
  • PLC Firmware version:
  • OS System:
  • Other relevant hardware:

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts scaling behavior in AxoCmmtAs for rotary vs. linear axes, focusing on acceleration/deceleration/jerk scaling and homing axis-zero offset writes.

Changes:

  • Updates rotary scaling constants for acceleration, deceleration, and jerk by applying a +3 exponent offset.
  • Makes PNU 11734 (axis zero point offset) write scaling conditional on AxisType during homing.
  • Adds inline markers (//Rotary, //Linear) to separate the scaling branches.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

IF AxisType = eAxoDriveAxisType#Rotary THEN
Parametrization.Inputs.ValueWriteLINT := TO_LINT(Position * -10000.0);
ELSIF AxisType = eAxoDriveAxisType#Linear THEN
Parametrization.Inputs.ValueWriteLINT := TO_LINT(Position * -10000000.0);
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If AxisType is not #Rotary or #Linear here (e.g., #Undefined / #Error), ValueWriteLINT is left unchanged and the write still proceeds, which can accidentally write a stale value to PNU 11734. Add an ELSE that aborts the write and transitions to an error state (with a Messenger message), or set a safe default and explicitly handle unsupported axis types.

Suggested change
Parametrization.Inputs.ValueWriteLINT := TO_LINT(Position * -10000000.0);
Parametrization.Inputs.ValueWriteLINT := TO_LINT(Position * -10000000.0);
ELSE
Parametrization.Inputs.Enable := FALSE;
Messenger.Activate( UINT#1456, eAxoMessageCategory#Error);
MC_HomeErrorID := DINT#1456;
State := UINT#59;

Copilot uses AI. Check for mistakes.
Comment on lines +806 to +809
ScalingConstantRequiredAcceleration := LREAL#16384.0 * _exp[TO_INT(PNU_11726)+3] / PNU_810; // 16#4000 ~~ 16384
ScalingConstantActualAcceleration := LREAL#1.0 / ScalingConstantRequiredAcceleration;

ScalingConstantRequiredDeceleration := LREAL#16384.0 * _exp[TO_INT(PNU_11726)] / PNU_811; // 16#4000 ~~ 16384
ScalingConstantRequiredDeceleration := LREAL#16384.0 * _exp[TO_INT(PNU_11726)+3] / PNU_811; // 16#4000 ~~ 16384
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with nearby expressions (e.g., (TO_INT(PNU_11725) + 3)), consider adding spaces around the + 3 in these _exp[...] indices to improve readability.

Copilot uses AI. Check for mistakes.
Comment on lines +806 to 810
ScalingConstantRequiredAcceleration := LREAL#16384.0 * _exp[TO_INT(PNU_11726)+3] / PNU_810; // 16#4000 ~~ 16384
ScalingConstantActualAcceleration := LREAL#1.0 / ScalingConstantRequiredAcceleration;

ScalingConstantRequiredDeceleration := LREAL#16384.0 * _exp[TO_INT(PNU_11726)] / PNU_811; // 16#4000 ~~ 16384
ScalingConstantRequiredDeceleration := LREAL#16384.0 * _exp[TO_INT(PNU_11726)+3] / PNU_811; // 16#4000 ~~ 16384
ScalingConstantActualDeceleration := LREAL#1.0 / ScalingConstantRequiredDeceleration;
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _exp lookup table is declared as ARRAY[-10..10], but these new indices use TO_INT(PNU_11726) + 3. If the drive ever returns PNU_11726 > 7 (or < -13), this will index out of bounds. Consider clamping/validating the index (and failing fast with a clear Messenger error) or expanding _exp to safely cover the expected parameter range.

Copilot uses AI. Check for mistakes.
ScalingConstantActualTorque := PNU_11122 / 16384; // 16#4000 ~~ 16384

ScalingConstantRequiredJerk := _exp[TO_INT(PNU_11727)];
ScalingConstantRequiredJerk := _exp[TO_INT(PNU_11727)+3];
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same potential out-of-bounds issue as above: _exp[TO_INT(PNU_11727)+3] assumes PNU_11727 stays within a range that keeps the computed index inside -10..10. Please add a guard/clamp (or adjust _exp bounds) so an unexpected drive value can't cause an invalid array access.

Suggested change
ScalingConstantRequiredJerk := _exp[TO_INT(PNU_11727)+3];
ScalingConstantRequiredJerk := _exp[MAX(-10, MIN(10, TO_INT(PNU_11727) + 3))];

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]festo rotary axis acc dcc jerk units scaling

3 participants