Skip to content

Commit

Permalink
Added encoder scaling and offset to the NC configuration list of expo…
Browse files Browse the repository at this point in the history
…sed parameters.
  • Loading branch information
NSLentz committed Apr 8, 2024
1 parent 23e72f1 commit 2e33fab
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
15 changes: 15 additions & 0 deletions lcls-twincat-motion/Library/DUTs/ST_AxisParameterSetExposed.TcDUT
Original file line number Diff line number Diff line change
Expand Up @@ -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
]]></Declaration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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 :=
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ External Setpoint Generation:
<OtherSettings AllowMotionCmdToSlave="true"/>
</AxisPara>
<Encoder Name="Enc" EncType="1">
<EncPara>
<EncPara Offset="12">
<SoftEndMinControl Enable="true" Range="4"/>
<SoftEndMaxControl Enable="true" Range="5"/>
</EncPara>
Expand Down Expand Up @@ -1496,6 +1496,7 @@ External Setpoint Generation:
<Drive Name="Drive" DrvType="5">
<DrvPara>
<Analog TorqueSetpointScale="10" ScaleFactorActTorque="0.1"/>
<TimeComp TaskDelayCycles="1"/>
</DrvPara>
<Vars VarGrpType="1">
<Name>Inputs</Name>
Expand Down
2 changes: 1 addition & 1 deletion lcls-twincat-motion/_Config/PLC/Library.xti
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ External Setpoint Generation:
</DataType>
</DataTypes>
<Project GUID="{E61EF94A-CFE8-4DDF-B7C9-5F7AD2CF9D83}" Name="Library" PrjFilePath="..\..\Library\Library.plcproj" TmcFilePath="..\..\Library\Library.tmc" ReloadTmc="true" AmsPort="851" FileArchiveSettings="#x000e">
<Instance Id="#x08502000" TcSmClass="TComPlcObjDef" KeepUnrestoredLinks="2" TmcPath="Library\Library.tmc" TmcHash="{9F81EE59-2E83-1EF8-1B24-7CFFA46FBA87}">
<Instance Id="#x08502000" TcSmClass="TComPlcObjDef" KeepUnrestoredLinks="2" TmcPath="Library\Library.tmc" TmcHash="{BFB542FD-B00A-A7FC-78AF-21772328A255}">
<Name>Library Instance</Name>
<CLSID ClassFactory="TcPlc30">{08500001-0000-0000-F000-000000000064}</CLSID>
<Vars VarGrpType="1">
Expand Down

0 comments on commit 2e33fab

Please sign in to comment.