Skip to content
Open
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions Base Project.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Global
Debug|TwinCAT OS (ARMV7-M) = Debug|TwinCAT OS (ARMV7-M)
Debug|TwinCAT OS (ARMV8-A) = Debug|TwinCAT OS (ARMV8-A)
Debug|TwinCAT OS (x64) = Debug|TwinCAT OS (x64)
Debug|TwinCAT OS (x64-E) = Debug|TwinCAT OS (x64-E)
Debug|TwinCAT RT (x64) = Debug|TwinCAT RT (x64)
Debug|TwinCAT RT (x86) = Debug|TwinCAT RT (x86)
Release|TwinCAT CE7 (ARMV7) = Release|TwinCAT CE7 (ARMV7)
Expand All @@ -21,6 +22,7 @@ Global
Release|TwinCAT OS (ARMV7-M) = Release|TwinCAT OS (ARMV7-M)
Release|TwinCAT OS (ARMV8-A) = Release|TwinCAT OS (ARMV8-A)
Release|TwinCAT OS (x64) = Release|TwinCAT OS (x64)
Release|TwinCAT OS (x64-E) = Release|TwinCAT OS (x64-E)
Release|TwinCAT RT (x64) = Release|TwinCAT RT (x64)
Release|TwinCAT RT (x86) = Release|TwinCAT RT (x86)
EndGlobalSection
Expand All @@ -37,6 +39,8 @@ Global
{E3FDD453-7143-4CBE-AF2D-E7E762464CFC}.Debug|TwinCAT OS (ARMV8-A).Build.0 = Debug|TwinCAT OS (ARMV8-A)
{E3FDD453-7143-4CBE-AF2D-E7E762464CFC}.Debug|TwinCAT OS (x64).ActiveCfg = Debug|TwinCAT OS (x64)
{E3FDD453-7143-4CBE-AF2D-E7E762464CFC}.Debug|TwinCAT OS (x64).Build.0 = Debug|TwinCAT OS (x64)
{E3FDD453-7143-4CBE-AF2D-E7E762464CFC}.Debug|TwinCAT OS (x64-E).ActiveCfg = Debug|TwinCAT OS (x64-E)
{E3FDD453-7143-4CBE-AF2D-E7E762464CFC}.Debug|TwinCAT OS (x64-E).Build.0 = Debug|TwinCAT OS (x64-E)
{E3FDD453-7143-4CBE-AF2D-E7E762464CFC}.Debug|TwinCAT RT (x64).ActiveCfg = Debug|TwinCAT RT (x64)
{E3FDD453-7143-4CBE-AF2D-E7E762464CFC}.Debug|TwinCAT RT (x64).Build.0 = Debug|TwinCAT RT (x64)
{E3FDD453-7143-4CBE-AF2D-E7E762464CFC}.Debug|TwinCAT RT (x86).ActiveCfg = Debug|TwinCAT RT (x86)
Expand All @@ -53,6 +57,8 @@ Global
{E3FDD453-7143-4CBE-AF2D-E7E762464CFC}.Release|TwinCAT OS (ARMV8-A).Build.0 = Release|TwinCAT OS (ARMV8-A)
{E3FDD453-7143-4CBE-AF2D-E7E762464CFC}.Release|TwinCAT OS (x64).ActiveCfg = Release|TwinCAT OS (x64)
{E3FDD453-7143-4CBE-AF2D-E7E762464CFC}.Release|TwinCAT OS (x64).Build.0 = Release|TwinCAT OS (x64)
{E3FDD453-7143-4CBE-AF2D-E7E762464CFC}.Release|TwinCAT OS (x64-E).ActiveCfg = Release|TwinCAT OS (x64-E)
{E3FDD453-7143-4CBE-AF2D-E7E762464CFC}.Release|TwinCAT OS (x64-E).Build.0 = Release|TwinCAT OS (x64-E)
{E3FDD453-7143-4CBE-AF2D-E7E762464CFC}.Release|TwinCAT RT (x64).ActiveCfg = Release|TwinCAT RT (x64)
{E3FDD453-7143-4CBE-AF2D-E7E762464CFC}.Release|TwinCAT RT (x64).Build.0 = Release|TwinCAT RT (x64)
{E3FDD453-7143-4CBE-AF2D-E7E762464CFC}.Release|TwinCAT RT (x86).ActiveCfg = Release|TwinCAT RT (x86)
Expand All @@ -69,6 +75,8 @@ Global
{DD3A0B29-8E7C-4E32-989D-B0222C998777}.Debug|TwinCAT OS (ARMV8-A).Build.0 = Debug|TwinCAT OS (ARMV8-A)
{DD3A0B29-8E7C-4E32-989D-B0222C998777}.Debug|TwinCAT OS (x64).ActiveCfg = Debug|TwinCAT OS (x64)
{DD3A0B29-8E7C-4E32-989D-B0222C998777}.Debug|TwinCAT OS (x64).Build.0 = Debug|TwinCAT OS (x64)
{DD3A0B29-8E7C-4E32-989D-B0222C998777}.Debug|TwinCAT OS (x64-E).ActiveCfg = Debug|TwinCAT OS (x64-E)
{DD3A0B29-8E7C-4E32-989D-B0222C998777}.Debug|TwinCAT OS (x64-E).Build.0 = Debug|TwinCAT OS (x64-E)
{DD3A0B29-8E7C-4E32-989D-B0222C998777}.Debug|TwinCAT RT (x64).ActiveCfg = Debug|TwinCAT RT (x64)
{DD3A0B29-8E7C-4E32-989D-B0222C998777}.Debug|TwinCAT RT (x64).Build.0 = Debug|TwinCAT RT (x64)
{DD3A0B29-8E7C-4E32-989D-B0222C998777}.Debug|TwinCAT RT (x86).ActiveCfg = Debug|TwinCAT RT (x86)
Expand All @@ -85,6 +93,8 @@ Global
{DD3A0B29-8E7C-4E32-989D-B0222C998777}.Release|TwinCAT OS (ARMV8-A).Build.0 = Release|TwinCAT OS (ARMV8-A)
{DD3A0B29-8E7C-4E32-989D-B0222C998777}.Release|TwinCAT OS (x64).ActiveCfg = Release|TwinCAT OS (x64)
{DD3A0B29-8E7C-4E32-989D-B0222C998777}.Release|TwinCAT OS (x64).Build.0 = Release|TwinCAT OS (x64)
{DD3A0B29-8E7C-4E32-989D-B0222C998777}.Release|TwinCAT OS (x64-E).ActiveCfg = Release|TwinCAT OS (x64-E)
{DD3A0B29-8E7C-4E32-989D-B0222C998777}.Release|TwinCAT OS (x64-E).Build.0 = Release|TwinCAT OS (x64-E)
{DD3A0B29-8E7C-4E32-989D-B0222C998777}.Release|TwinCAT RT (x64).ActiveCfg = Release|TwinCAT RT (x64)
{DD3A0B29-8E7C-4E32-989D-B0222C998777}.Release|TwinCAT RT (x64).Build.0 = Release|TwinCAT RT (x64)
{DD3A0B29-8E7C-4E32-989D-B0222C998777}.Release|TwinCAT RT (x86).ActiveCfg = Release|TwinCAT RT (x86)
Expand Down
4 changes: 2 additions & 2 deletions Base Project/Base Project.tsproj
Original file line number Diff line number Diff line change
Expand Up @@ -35782,7 +35782,7 @@ External Setpoint Generation:
</System>
<Motion>
<NC>
<SafTask Priority="8" CycleTime="20000" AmsPort="501" Affinity="#x00000080" IoAtBegin="true" AmsNetId="169.254.15.111.1.1" SafTaskInfo="256">
<SafTask Priority="8" CycleTime="20000" AmsPort="501" Affinity="#x00000080" IoAtBegin="true" SafTaskInfo="256">
<Name>NC SAF</Name>
<Vars VarGrpType="1" InsertType="1">
<Name>Inputs</Name>
Expand Down Expand Up @@ -36083,7 +36083,7 @@ External Setpoint Generation:
</Motion>
<Plc>
<Project GUID="{DD3A0B29-8E7C-4E32-989D-B0222C998777}" Name="PLC1" PrjFilePath="PLC1\PLC1.plcproj" TmcFilePath="PLC1\PLC1.tmc" ReloadTmc="true" AmsPort="851" FileArchiveSettings="#x000e" SymbolicMapping="true">
<Instance Id="#x08502000" TcSmClass="TComPlcObjDef" KeepUnrestoredLinks="2" TmcHash="{A7604CCE-606B-473D-2C90-D3645B0AE4EF}" TmcPath="PLC1\PLC1.tmc">
<Instance Id="#x08502000" TcSmClass="TComPlcObjDef" KeepUnrestoredLinks="2" TmcHash="{EAF32191-5142-E46E-A9D4-232736F396E2}" TmcPath="PLC1\PLC1.tmc">
<Name>PLC1 Instance</Name>
<CLSID ClassFactory="TcPlc30">{08500001-0000-0000-F000-000000000064}</CLSID>
<Vars VarGrpType="2" AreaNo="1">
Expand Down
9 changes: 6 additions & 3 deletions Base Project/PLC1/GVLs/Param.TcGVL
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
<GVL Name="Param" Id="{673621fc-c806-000b-08ea-fd34161e1bd8}" ParameterList="True">
<Declaration><![CDATA[{attribute 'qualified_only'}
VAR_GLOBAL CONSTANT
// The following should be set to a value **equal to or greater than** the number of movers needed
MAX_MOVERS : USINT := 100; // Movers
MAX_POSITIONTRIGGERS : USINT := 100;
// The following should be set to a value **equal to or greater than** the number of objects needed
MAX_MOVERS : USINT := 100; // Movers
MAX_POSITIONTRIGGERS : USINT := 100; // Position triggers
MAX_STATIONS : USINT := 100; // Stations
MAX_ZONES : USINT := 100; // Zones

// The following should be set to a value **equal to or greater than** the number of objectives needed
// it's also possible to declare additional stations, zones and position triggers in MAIN
NUM_MOVERLISTS : USINT := 10; // Mover Lists
NUM_POSITIONTRIGGERS : USINT := 10; // Position Triggers
NUM_STATIONS : USINT := 10; // Stations
Expand Down
88 changes: 61 additions & 27 deletions Base Project/PLC1/XTS (Do Not Edit)/Administrative/Mediator.TcPOU
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ VAR_INPUT
MoverArray : ARRAY [1..Param.MAX_MOVERS] OF POINTER TO Mover;

MoverListArray : ARRAY [0..Param.NUM_MOVERLISTS-1] OF POINTER TO MoverList;
PositionTriggerArray : ARRAY [0..Param.NUM_POSITIONTRIGGERS-1] OF POINTER TO PositionTrigger;
StationArray : ARRAY [0..Param.NUM_STATIONS-1] OF POINTER TO Station;
ZoneArray : ARRAY [0..Param.NUM_ZONES-1] OF POINTER TO Zone;
PositionTriggerArray : ARRAY [0..Param.MAX_POSITIONTRIGGERS-1] OF POINTER TO PositionTrigger;
StationArray : ARRAY [0..Param.MAX_STATIONS-1] OF POINTER TO Station;
ZoneArray : ARRAY [0..Param.MAX_ZONES-1] OF POINTER TO Zone;
TrackArray : ARRAY [0..Param.NUM_TRACKS] OF POINTER TO Track; // track 0 is a special absolute case, this makes the array 1 larger than normal

GROUP_REF : AXES_GROUP_REF;
Expand Down Expand Up @@ -79,8 +79,8 @@ END_VAR

VAR
duplicateFound : BOOL;
i : UDINT;
emptyIDX : UDINT;
i : DINT;
emptyIDX : DINT := -1;;
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[
Expand All @@ -100,12 +100,18 @@ IF __ISVALIDREF( Mover ) THEN
END_IF
ELSE
// track the first empty index
IF (emptyIDX = 0) THEN
IF (emptyIDX = -1) THEN
emptyIDX := i;
END_IF;
END_IF
END_FOR

// if no empty index is available set a message and return
IF emptyIDX = -1 THEN
ADSLOGSTR( ADSLOG_MSGTYPE_WARN, 'AddMover System Array is full. %s not added. Check Params.MAX_MOVERS' , Mover.InstancePath);
RETURN;
END_IF;

IF duplicateFound = FALSE THEN

THIS^.MoverArray[emptyIDX] := ADR( Mover ); // new mover into empty array element
Expand Down Expand Up @@ -141,8 +147,8 @@ END_VAR

VAR
duplicateFound : BOOL;
i : UDINT;
emptyIDX : UDINT;
i : DINT;
emptyIDX : DINT := -1;
END_VAR
]]></Declaration>
<Implementation>
Expand All @@ -162,12 +168,18 @@ IF __ISVALIDREF( MoverList ) THEN
END_IF
ELSE
// track the first empty index
IF (emptyIDX = 0) THEN
IF (emptyIDX = -1) THEN
emptyIDX := i;
END_IF;
END_IF
END_FOR

// if no empty index is available set a message and return
IF emptyIDX = -1 THEN
ADSLOGSTR( ADSLOG_MSGTYPE_WARN, 'MoverList System Array is full. %s not added. Check Params.MAX_MOVERLISTS' , MoverList.InstancePath);
RETURN;
END_IF;

IF duplicateFound = FALSE THEN
THIS^.MoverListArray[emptyIDX] := ADR( MoverList );
END_IF
Expand All @@ -187,8 +199,8 @@ END_VAR

VAR
duplicateFound : BOOL;
i : UDINT;
emptyIDX : UDINT;
i : DINT;
emptyIDX : DINT := -1;
END_VAR
]]></Declaration>
<Implementation>
Expand All @@ -208,12 +220,18 @@ IF __ISVALIDREF( PositionTrigger ) THEN
END_IF
ELSE
// track the first empty index
IF (emptyIDX = 0) THEN
IF (emptyIDX = -1) THEN
emptyIDX := i;
END_IF;
END_IF
END_FOR

// if no empty index is available set a message and return
IF emptyIDX = -1 THEN
ADSLOGSTR( ADSLOG_MSGTYPE_WARN, 'AddPositionTrigger System Array is full. %s not added. Check Params.MAX_POSITIONTRIGGERS' , PositionTrigger.InstancePath);
RETURN;
END_IF;

IF duplicateFound = FALSE THEN
THIS^.PositionTriggerArray[emptyIDX] := ADR( PositionTrigger );

Expand All @@ -238,8 +256,8 @@ END_VAR

VAR
duplicateFound : BOOL;
i : UDINT;
emptyIDX : UDINT;
i : DINT;
emptyIDX : DINT := -1;
END_VAR
]]></Declaration>
<Implementation>
Expand All @@ -259,12 +277,18 @@ IF __ISVALIDREF( Station ) THEN
END_IF
ELSE
// track the first empty index
IF (emptyIDX = 0) THEN
IF (emptyIDX = -1) THEN
emptyIDX := i;
END_IF;
END_IF
END_FOR

// if no empty index is available set a message and return
IF emptyIDX = -1 THEN
ADSLOGSTR( ADSLOG_MSGTYPE_WARN, 'AddStation System Array is full. %s not added. Check Params.MAX_STATIONS' , Station.InstancePath);
RETURN;
END_IF;

IF duplicateFound = FALSE THEN
THIS^.StationArray[emptyIDX] := ADR( Station );
END_IF
Expand Down Expand Up @@ -324,8 +348,8 @@ END_VAR

VAR
duplicateFound : BOOL;
i : UDINT;
emptyIDX : UDINT;
i : DINT;
emptyIDX : DINT := -1;
END_VAR
]]></Declaration>
<Implementation>
Expand All @@ -345,12 +369,18 @@ IF __ISVALIDREF( Zone ) THEN
END_IF
ELSE
// track the first empty index
IF (emptyIDX = 0) THEN
IF (emptyIDX = -1) THEN
emptyIDX := i;
END_IF;
END_IF
END_FOR

// if no empty index is available set a message and return
IF emptyIDX = -1 THEN
ADSLOGSTR( ADSLOG_MSGTYPE_WARN, 'AddZone System Array is full. %s not added. Check Params.MAX_ZONES' , Zone.InstancePath);
RETURN;
END_IF;

IF duplicateFound = FALSE THEN
THIS^.ZoneArray[emptyIDX] := ADR( Zone );

Expand Down Expand Up @@ -528,13 +558,13 @@ FOR i := 1 TO Param.MAX_MOVERS DO
END_IF
END_FOR

FOR i := 0 TO Param.NUM_STATIONS - 1 DO
FOR i := 0 TO Param.MAX_STATIONS - 1 DO
IF StationArray[i] <> 0 THEN
StationArray[i]^.Cyclic();
END_IF
END_FOR

FOR i := 0 TO Param.NUM_POSITIONTRIGGERS - 1 DO
FOR i := 0 TO Param.MAX_POSITIONTRIGGERS - 1 DO
IF PositionTriggerArray[i] <> 0 THEN
PositionTriggerArray[i]^.Cyclic();
END_IF
Expand Down Expand Up @@ -855,16 +885,16 @@ IF THIS^.InfoServerIsReady AND internalEnabled AND Param.AUTO_POPULATE_STATIONS

40:
// calculate minimum number of stations that can be set up
nUsableStations := MIN(nInfoServerStations, Param.NUM_STATIONS);
nUsableStations := MIN(nInfoServerStations, Param.MAX_STATIONS);
workingStation := 0;
FOR i := 1 TO nUsableStations DO
workingStation := workingStation + 1;
// in case a sparse Station array is used, only detect stations that have a position value <> 0
WHILE (workingStation < Param.NUM_STATIONS AND_THEN (StationArray[workingStation] = 0 OR_ELSE StationArray[workingStation]^.Position = 0)) DO
WHILE (workingStation < Param.MAX_STATIONS AND_THEN (StationArray[workingStation] = 0 OR_ELSE StationArray[workingStation]^.Position = 0)) DO
workingStation := workingStation + 1;
END_WHILE
// check for valid working station, and exit this for loop iteration if we're outside it
IF workingStation >= Param.NUM_STATIONS THEN
IF workingStation >= Param.MAX_STATIONS THEN
EXIT;
END_IF
// get XTS_Base Station pointer
Expand Down Expand Up @@ -1162,11 +1192,15 @@ END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[// reset statistics at all postion triggers and stations
FOR i := 0 TO Param.NUM_POSITIONTRIGGERS-1 DO
PositionTriggerArray[i]^.ResetStatistics();
FOR i := 0 TO Param.MAX_POSITIONTRIGGERS-1 DO
IF PositionTriggerArray[i] <> 0 THEN
PositionTriggerArray[i]^.ResetStatistics();
END_IF
END_FOR
FOR i := 0 TO Param.NUM_STATIONS-1 DO
StationArray[i]^.ResetStatistics();
FOR i := 0 TO Param.MAX_STATIONS-1 DO
IF StationArray[i] <> 0 THEN
StationArray[i]^.ResetStatistics();
END_IF
END_FOR
]]></ST>
</Implementation>
Expand Down
20 changes: 13 additions & 7 deletions Base Project/PLC1/XTS (Do Not Edit)/Objects/Mover.TcPOU
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4026.12">
<POU Name="Mover" Id="{461a92b9-026e-4cbb-aa50-b18297f25ecc}" SpecialFunc="None">
<Declaration><![CDATA[{attribute 'reflection'}
Expand Down Expand Up @@ -1922,16 +1922,22 @@ FOR i := 0 TO Param.NUM_MOVERLISTS-1 DO
Mediator.MoverListArray[i]^.UnregisterMover( THIS^ );
END_FOR

FOR i := 0 TO Param.NUM_POSITIONTRIGGERS-1 DO
Mediator.PositionTriggerArray[i]^.UnregisterMover( THIS^ );
FOR i := 0 TO Param.MAX_POSITIONTRIGGERS-1 DO
IF Mediator.PositionTriggerArray[i] <> 0 THEN
Mediator.PositionTriggerArray[i]^.UnregisterMover( THIS^ );
END_IF
END_FOR

FOR i := 0 TO Param.NUM_STATIONS-1 DO
Mediator.StationArray[i]^.UnregisterMover( THIS^ );
FOR i := 0 TO Param.MAX_STATIONS-1 DO
IF Mediator.StationArray[i] <> 0 THEN
Mediator.StationArray[i]^.UnregisterMover( THIS^ );
END_IF;
END_FOR

FOR i := 0 TO Param.NUM_ZONES-1 DO
Mediator.ZoneArray[i]^.UnregisterMover( THIS^ );
FOR i := 0 TO Param.MAX_ZONES-1 DO
IF Mediator.ZoneArray[i] <> 0 THEN
Mediator.ZoneArray[i]^.UnregisterMover( THIS^ );
END_IF
END_FOR]]></ST>
</Implementation>
</Method>
Expand Down
33 changes: 33 additions & 0 deletions Documentation/docs/CodeReference/Parameters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

# Parameters

Paramaters configure the overall size of the XTS application including the number of objects such as stations or zones needed. Parameters can be viewed and adjusted in `GVL\Param`.

!!! Note
Mover appears in parameters but is not addressed in this section as it has additional needs when increasing or decreasing its count. Please see [Project Customization](../GettingStarted/2_FirstSteps.md#project-customization).

## NUM_ Parameters

The provided FB_XTS object includes a set of the objects listed already pre-configured and ready to use.

- `XTS.Mover[]`
- `XTS.PositionTrigger[]`
- `XTS.Station[]`
- `XTS.Zone[]`

The size of these arrays is configured with the corresponding `NUM_` parameter.

In many XTS applications, especially ones that implement simple station-to-station motion, the provided objects are all that is needed for user code. An simple adjustment of the `NUM_` parameter to increase stations, zones or position triggers may be the only parameters that need to be adjusted to fit the application.

## MAX_ Parameters

The mediator can manage additional Position Triggers, Stations and Zones outside of those declared in FB_XTS if needed for an application. This can help with code modularity and allows you to create custom objects (as FBs) that contain their own stations, zones and position triggers as needed.

The `MAX_` parameters define the absolute maximum number of any of these objects that can be declared. The value selected should be high enough to include the number of objects created by the `NUM_` parameter, and any additional objects you will create in user code.

!!! Note
There is no performance penalty for having more MAX_ objects than you actually use. Any objects in the array that have not been configured do not cause additional code to execute. There is a small amount of memory required for extra, unused objects but this often is insignificant in the overall size of the program and memory available on IPCs capable of running XTS.

## MAX_ Parameters Example

An example of declaring additional objects that consume space under the `MAX_` parameter limits is available in [Custom Objects](../Examples/CustomObjects.md)
Loading