From 2e33fab974b5a153056cbef282a1233cc38dd9ad Mon Sep 17 00:00:00 2001 From: Nicholas Lentz Date: Mon, 8 Apr 2024 16:12:20 -0700 Subject: [PATCH] Added encoder scaling and offset to the NC configuration list of exposed parameters. --- .../Library/DUTs/ST_AxisParameterSetExposed.TcDUT | 15 +++++++++++++++ .../POUs/Motion/FB_MotionStageNCParams.TcPOU | 2 ++ .../Tests/FB_AxisParameterSetExposed_Test.TcPOU | 14 +++++++++++--- .../_Config/NC/Axes/Axis_AxisParameter_Test.xti | 3 ++- lcls-twincat-motion/_Config/PLC/Library.xti | 2 +- 5 files changed, 31 insertions(+), 5 deletions(-) diff --git a/lcls-twincat-motion/Library/DUTs/ST_AxisParameterSetExposed.TcDUT b/lcls-twincat-motion/Library/DUTs/ST_AxisParameterSetExposed.TcDUT index 6658cf9..d3b3790 100644 --- a/lcls-twincat-motion/Library/DUTs/ST_AxisParameterSetExposed.TcDUT +++ b/lcls-twincat-motion/Library/DUTs/ST_AxisParameterSetExposed.TcDUT @@ -69,6 +69,21 @@ STRUCT field: DESC Maximum commandable position of the axis in EU. '} fEncSoftEndMax : LREAL; // Maximum commandable position of the axis in EU. + + // Encoder Evaluation + {attribute 'pytmc' := ' + pv: EncScaling + io: i + field: DESC Encoder scaling numerator / denominator in EU/COUNT. + '} + fEncScaleFactorInternal : LREAL; // Encoder scaling numerator / denominator in EU/COUNT. + {attribute 'pytmc' := ' + pv: EncOffset + io: i + field: DESC Encoder offset in EU. + '} + fEncOffset : LREAL; // Encoder offset in EU. + END_STRUCT END_TYPE ]]> diff --git a/lcls-twincat-motion/Library/POUs/Motion/FB_MotionStageNCParams.TcPOU b/lcls-twincat-motion/Library/POUs/Motion/FB_MotionStageNCParams.TcPOU index 5e48962..54b18c8 100644 --- a/lcls-twincat-motion/Library/POUs/Motion/FB_MotionStageNCParams.TcPOU +++ b/lcls-twincat-motion/Library/POUs/Motion/FB_MotionStageNCParams.TcPOU @@ -44,6 +44,8 @@ stMotionStage.stAxisParametersExposed.fDecelerationMax := stMotionS stMotionStage.stAxisParametersExposed.fEncSoftEndMax := stMotionStage.stAxisParameters.fEncSoftEndMax; stMotionStage.stAxisParametersExposed.fEncSoftEndMin := stMotionStage.stAxisParameters.fEncSoftEndMin; stMotionStage.stAxisParametersExposed.fVeloMaximum := stMotionStage.stAxisParameters.fVeloMaximum; +stMotionStage.stAxisParametersExposed.fEncOffset := stMotionStage.stAxisParameters.fEncOffset; +stMotionStage.stAxisParametersExposed.fEncScaleFactorInternal := stMotionStage.stAxisParameters.fEncScaleFactorInternal; IF mcReadParams.ErrorID <> 0 THEN nLatchErrId := 0; diff --git a/lcls-twincat-motion/Library/Tests/FB_AxisParameterSetExposed_Test.TcPOU b/lcls-twincat-motion/Library/Tests/FB_AxisParameterSetExposed_Test.TcPOU index d026854..043c70d 100644 --- a/lcls-twincat-motion/Library/Tests/FB_AxisParameterSetExposed_Test.TcPOU +++ b/lcls-twincat-motion/Library/Tests/FB_AxisParameterSetExposed_Test.TcPOU @@ -65,6 +65,8 @@ IF bLocalInit THEN stMotionStage.stAxisParametersExposed.fEncSoftEndMax := 107; stMotionStage.stAxisParametersExposed.fEncSoftEndMin := 108; stMotionStage.stAxisParametersExposed.fVeloMaximum := 109; + stMotionStage.stAxisParametersExposed.fEncOffset := 110; + stMotionStage.stAxisParametersExposed.fEncScaleFactorInternal := 111; bLocalInit := FALSE; @@ -78,7 +80,9 @@ IF bLocalInit THEN stMotionStage.stAxisParametersExposed.fDecelerationMax <> stMotionStage.stAxisParameters.fDecelerationMax AND stMotionStage.stAxisParametersExposed.fEncSoftEndMax <> stMotionStage.stAxisParameters.fEncSoftEndMax AND stMotionStage.stAxisParametersExposed.fEncSoftEndMin <> stMotionStage.stAxisParameters.fEncSoftEndMin AND - stMotionStage.stAxisParametersExposed.fVeloMaximum <> stMotionStage.stAxisParameters.fVeloMaximum; + stMotionStage.stAxisParametersExposed.fVeloMaximum <> stMotionStage.stAxisParameters.fVeloMaximum AND + stMotionStage.stAxisParametersExposed.fEncOffset <> stMotionStage.stAxisParameters.fEncOffset AND + stMotionStage.stAxisParametersExposed.fEncScaleFactorInternal <> stMotionStage.stAxisParameters.fEncScaleFactorInternal; AssertTrue( Condition:=bAllModified, @@ -96,7 +100,9 @@ bReady := stMotionStage.stAxisParameters.fDecelerationMax <> 0 AND stMotionStage.stAxisParameters.fEncSoftEndMax <> 0 AND stMotionStage.stAxisParameters.fEncSoftEndMin <> 0 AND - stMotionStage.stAxisParameters.fVeloMaximum <> 0; + stMotionStage.stAxisParameters.fVeloMaximum <> 0 AND + stMotionStage.stAxisParameters.fEncOffset <> 0 AND + stMotionStage.stAxisParameters.fEncScaleFactorInternal <> 0; IF bReady THEN bDone := @@ -109,7 +115,9 @@ IF bReady THEN stMotionStage.stAxisParametersExposed.fDecelerationMax = stMotionStage.stAxisParameters.fDecelerationMax AND stMotionStage.stAxisParametersExposed.fEncSoftEndMax = stMotionStage.stAxisParameters.fEncSoftEndMax AND stMotionStage.stAxisParametersExposed.fEncSoftEndMin = stMotionStage.stAxisParameters.fEncSoftEndMin AND - stMotionStage.stAxisParametersExposed.fVeloMaximum = stMotionStage.stAxisParameters.fVeloMaximum; + stMotionStage.stAxisParametersExposed.fVeloMaximum = stMotionStage.stAxisParameters.fVeloMaximum AND + stMotionStage.stAxisParametersExposed.fEncOffset = stMotionStage.stAxisParameters.fEncOffset AND + stMotionStage.stAxisParametersExposed.fEncScaleFactorInternal = stMotionStage.stAxisParameters.fEncScaleFactorInternal; END_IF IF bDone OR tonTimer.Q THEN diff --git a/lcls-twincat-motion/_Config/NC/Axes/Axis_AxisParameter_Test.xti b/lcls-twincat-motion/_Config/NC/Axes/Axis_AxisParameter_Test.xti index 414fe35..b1b95f1 100644 --- a/lcls-twincat-motion/_Config/NC/Axes/Axis_AxisParameter_Test.xti +++ b/lcls-twincat-motion/_Config/NC/Axes/Axis_AxisParameter_Test.xti @@ -1433,7 +1433,7 @@ External Setpoint Generation: - + @@ -1496,6 +1496,7 @@ External Setpoint Generation: + Inputs diff --git a/lcls-twincat-motion/_Config/PLC/Library.xti b/lcls-twincat-motion/_Config/PLC/Library.xti index 1ddf84f..c12181b 100644 --- a/lcls-twincat-motion/_Config/PLC/Library.xti +++ b/lcls-twincat-motion/_Config/PLC/Library.xti @@ -983,7 +983,7 @@ External Setpoint Generation: - + Library Instance {08500001-0000-0000-F000-000000000064}