Conversation
There was a problem hiding this comment.
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
+3exponent offset. - Makes PNU 11734 (axis zero point offset) write scaling conditional on
AxisTypeduring 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); |
There was a problem hiding this comment.
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.
| 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; |
| 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 |
There was a problem hiding this comment.
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.
| 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; |
There was a problem hiding this comment.
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.
| ScalingConstantActualTorque := PNU_11122 / 16384; // 16#4000 ~~ 16384 | ||
|
|
||
| ScalingConstantRequiredJerk := _exp[TO_INT(PNU_11727)]; | ||
| ScalingConstantRequiredJerk := _exp[TO_INT(PNU_11727)+3]; |
There was a problem hiding this comment.
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.
| ScalingConstantRequiredJerk := _exp[TO_INT(PNU_11727)+3]; | |
| ScalingConstantRequiredJerk := _exp[MAX(-10, MIN(10, TO_INT(PNU_11727) + 3))]; |
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.
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 Configuration:
Checklist: