Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/components.festo.drives/ctrl/src/AxoCmmtAs/AxoCmmtAs.st
Original file line number Diff line number Diff line change
Expand Up @@ -795,29 +795,29 @@ NAMESPACE AXOpen.Components.Festo.Drives
_scalingReadState := UINT#28;
END_IF;
END_IF;

//Rotary
IF _scalingReadState = UINT#27 THEN
ScalingConstantRequiredPosition := _exp[-1*(TO_INT(PNU_11724) )]; // TODO verify scaling with Automation Suite
ScalingConstantActualPosition := LREAL#1.0/ScalingConstantRequiredPosition; // TODO verify scaling with Automation Suite

ScalingConstantRequiredVelocity := _exp[-1*(TO_INT(PNU_11725) )]; // TODO verify scaling with Automation Suite
ScalingConstantActualVelocity := PNU_12345 * _exp[(TO_INT(PNU_11725) + 3)] / LREAL#1073741824.0; // 16#4000 0000 ~~ 1073741824 // TODO verify scaling with Automation Suite

ScalingConstantRequiredAcceleration := LREAL#16384.0 * _exp[TO_INT(PNU_11726)] / PNU_810; // 16#4000 ~~ 16384
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
Comment on lines +806 to +809
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.
ScalingConstantActualDeceleration := LREAL#1.0 / ScalingConstantRequiredDeceleration;
Comment on lines +806 to 810
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.

ScalingConstantRequiredTorque := 1;
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.
ScalingConstantActualJerk := LREAL#1.0 / ScalingConstantRequiredJerk;

_scalingReadState := UINT#29;
END_IF;

//Linear
IF _scalingReadState = UINT#28 THEN
ScalingConstantRequiredPosition := _exp[-1*(TO_INT(PNU_11724) + 3)];
ScalingConstantActualPosition := LREAL#1.0/ScalingConstantRequiredPosition;
Expand Down Expand Up @@ -1722,7 +1722,12 @@ NAMESPACE AXOpen.Components.Festo.Drives
Parametrization.Inputs.Subindex := 0;
Parametrization.Inputs.AxisNo := BYTE#1;
Parametrization.Inputs.HardwareId := _AxisReference^.HWIDs.HW_ModuleAccessPoint;
Parametrization.Inputs.ValueWriteLINT := TO_LINT(Position * -10000000.0);
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.
END_IF;

IF Parametrization.Outputs.Done AND NOT Parametrization.Outputs.Error THEN
State := UINT#48;
END_IF;
Expand Down
Loading