Example "Connecting Planar tracks to network on Planar parts"

In this example, a network of Planar tracks is created on moving Planar parts.

Starting point

We start with a solution that contains a fully configured XPlanar Processing Unit. Two parts, a coordinate system and a mover are created under the XPlanar Processing Unit. There are 8 tiles under the first part and 2 tiles under the second part.

Example "Connecting Planar tracks to network on Planar parts" 1:

The following geometric situation is set: the two parts are next to each other and part 2 can occupy two positions. This means that there are two different connections between the parts, depending on the part positions.

Example "Connecting Planar tracks to network on Planar parts" 2:

The example is developed on the basis of this configuration. The creation of the initial situation is described in the XPlanar Processing Unit documentation.

Creating Planar tracks and a Planar environment

1. Create a Planar environment, see Configuration.
2. Set the initial parameter XPlanar processing unit OID to the object ID of the XPlanar Processing Unit. This activates the Part feature for all MC Configuration objects (especially for the created Planar mover).
3. Add three Planar tracks via Groups > Add New Item…, see Configuration.
4. Set the initial parameter "PartOID" of the three tracks to the corresponding parts. In this example, the first and second tracks are on part 1 and the third track is on part 2.

Creating a PLC

See preliminary steps under Creating a PLC.
1. Create the desired number of movers ("MC_PlanarMover") and tracks ("MC_PlanarTrack") via MAIN.
Example "Connecting Planar tracks to network on Planar parts" 3:
These represent movers and tracks in the MC Configuration.
2. Create three planar tracks as shown below, a state variable for a state machine and two auxiliary positions for the tracks.
PROGRAM MAIN
VAR
    track_one, track_two, track_three : MC_PlanarTrack;
    state : UDINT;
    pos1, pos2 : PositionXYC;
    part_one_oid : OTCID := 16#01010020;
    part_two_oid : OTCID := 16#01010030;
    start_options : ST_StartFromTrackAdvancedOptions;
    end_options : ST_EndAtTrackAdvancedOptions;
END_VAR
3. Then program a sequence in MAIN.
This program code creates three tracks on the parts. Depending on the active part position, the tracks are connected at different positions. First, track 3 is created on part 2 (state=0). Track 2 is then started at track 3, with part 2 in the upper position (index=2). Track 2 also ends at track 3, but part 2 is in the lower position (index=1). Finally, track 1 is started at track 3, part 2 is in the lower position (index=1), and finished, part 2 is in the upper position (index=2).
CASE state OF
  0:
    pos1.SetValuesXYCReferenceId(0, 360, 0, part_two_oid);
    pos2.SetValuesXYCReferenceId(80, 360, 0, part_two_oid);
    track_three.AppendLine(0, pos1, pos2);
    pos1.SetValuesXYCReferenceId(120, 320, 0, part_two_oid);
    pos2.SetValuesXYCReferenceId(120, 160, 0, part_two_oid);
    track_three.AppendLine(0, pos1, pos2);
    pos1.SetValuesXYCReferenceId(80, 120, 0, part_two_oid);
    pos2.SetValuesXYCReferenceId(0, 120, 0, part_two_oid);
    track_three.AppendLine(0, pos1, pos2);
    state := 1;
  1:
    start_options.thisTrackPartPositionIndex := 1;
    start_options.otherTrackPartPositionIndex := 2;
    track_two.StartFromTrackAdvanced(0, track_three, start_options);
    pos1.SetValuesXYCReferenceId(440, 600, 0, part_one_oid);
    pos2.SetValuesXYCReferenceId(400, 600, 0, part_one_oid);
    track_two.AppendLine(0, pos1, pos2);
    pos1.SetValuesXYCReferenceId(360, 560, 0, part_one_oid);
    pos2.SetValuesXYCReferenceId(360, 400, 0, part_one_oid);
    track_two.AppendLine(0, pos1, pos2);
    pos1.SetValuesXYCReferenceId(400, 360, 0, part_one_oid);
    pos2.SetValuesXYCReferenceId(440, 360, 0, part_one_oid);
    track_two.AppendLine(0, pos1, pos2);
    end_options.thisTrackPartPositionIndex := 1;
    end_options.otherTrackPartPositionIndex := 1;
    track_two.EndAtTrackAdvanced(0, track_three, end_options);
    state := 2;
  2:
    start_options.thisTrackPartPositionIndex := 1;
    start_options.otherTrackPartPositionIndex := 1;
    track_one.StartFromTrackAdvanced(0, track_three, start_options);
    pos1.SetValuesXYCReferenceId(440, 120, 0, part_one_oid);
    pos2.SetValuesXYCReferenceId(160, 120, 0, part_one_oid);
    track_one.AppendLine(0, pos1, pos2);
    pos1.SetValuesXYCReferenceId(120, 160, 0, part_one_oid);
    pos2.SetValuesXYCReferenceId(120, 800, 0, part_one_oid);
    track_one.AppendLine(0, pos1, pos2);
    pos1.SetValuesXYCReferenceId(160, 840, 0, part_one_oid);
    pos2.SetValuesXYCReferenceId(440, 840, 0, part_one_oid);
    track_one.AppendLine(0, pos1, pos2);
    end_options.thisTrackPartPositionIndex := 1;
    end_options.otherTrackPartPositionIndex := 2;
    track_one.EndAtTrackAdvanced(0, track_three, end_options);
    state := 3;
END_CASE

Sending the command

4. To send the commands, you must call the track cyclically with its update method after the END_CASE:
track_one.Update();
track_two.Update();
track_three.Update();

Building the PLC creates symbols of the "PLC mover" and “track”, which can then be linked to the mover and track instance in the MC project.

1. To build, use the path PLC > Untitled1 > Untitled1 Project > Build.
Example "Connecting Planar tracks to network on Planar parts" 4:
The tracks can now be linked via the following dialog boxes.
Example "Connecting Planar tracks to network on Planar parts" 5:
Example "Connecting Planar tracks to network on Planar parts" 6:

Activating and starting the project

1. Activate the configuration via the button in the menu bar Example "Connecting Planar tracks to network on Planar parts" 7:.
2. Set the TwinCAT system to the "Run" state via the button Example "Connecting Planar tracks to network on Planar parts" 8:.
3. Log in the PLC via the button in the menu bar Example "Connecting Planar tracks to network on Planar parts" 9:.
4. Start the PLC via the Play button in the menu bar.

At the end of the state machine (state=3), the three tracks are configured as shown. The start of track 3 is connected to the end of track 2 at position 2 and the end of track 3 is connected to the start of track 1 and position 2 when part 2 is in the lower position. In the upper position, the start of track 3 is connected to the end of track 1 at position 4 and the end of track 3 is connected to the start of track 2 and position 1. Track 2 and track 3 are the same length.

Example "Connecting Planar tracks to network on Planar parts" 10: