Example "Configuring the stator area and boundary"

Using this guide you will be able to create a TwinCAT project that contains a Planar environment and you will configure its stator surface and boundary.

Creating a Planar environment

1. Create a Planar environment, see Configuration.

Creating a PLC

See preliminary steps Creating a PLC.
1. Create an "MC_PlanarEnvironment" via MAIN.
Example "Configuring the stator area and boundary" 1:
This represents the environment in the MC configuration.
2. Create a state variable for a state machine as shown below.
PROGRAM MAIN
VAR
    environment : MC_PlanarEnvironment;
    state : UDINT;
END_VAR
3. Then program a sequence in MAIN.
This program code adds four stators to the environment. The lower left corner of the square stators (side length 240 mm) is specified in each case. CreateBoundary() then calculates the outer boundary of the stator surface.
The stators (red) and boundary elements (blue) are shown schematically in the following illustration.
Example "Configuring the stator area and boundary" 2:
CASE state OF
  0:
    environment.AddStator(0,0.0,0.0);
    environment.AddStator(0,240.0,0.0);
    environment.AddStator(0,0.0,240.0);
    environment.AddStator(0,240.0,240.0);
    environment.CreateBoundary(0);
    state := 1;
END_CASE

Sending the command

4. To send the command, you must call the environment cyclically with its update method after the END_CASE:
environment.Update();

When creating the PLC, a symbol of the "PLC environment" is created, which can then be linked to the Planar environment in the MC project.

5. To build, use the path PLC > Untitled1 > Untitled1 Project > Build.
Example "Configuring the stator area and boundary" 3:
The Planar environment can then be linked in the "MC Project".
Example "Configuring the stator area and boundary" 4:
Example "Configuring the stator area and boundary" 5:

Activating and starting the project

1. Activate the configuration via the button in the menu bar Example "Configuring the stator area and boundary" 6:.
2. Set the TwinCAT system to the "Run" state via the Example "Configuring the stator area and boundary" 7: button.
3. Log in the PLC via the button in the menu bar Example "Configuring the stator area and boundary" 8:.
4. Start the PLC via the Play button in the menu bar.

The environment is in the desired state at the end of the state machine (state = 1).

Example "Configuring the stator area and boundary" 9: