Execution and Synchronization Manager (ESM)

PLCnext Technology also features task handling. The ESM performs task handling, monitoring and chronological sequencing of programs from different programming languages. Each processor core of a controller is managed by one ESM. One ESM is therefore assigned to one processor core. If a controller has more than one processor core, then there are also several ESMs (example: controller AXC F 2152: 2 processor cores and 2 ESMs).

The ESM offers the following advantages:

  • Configuration and monitoring of cyclic tasks and idle tasks.
  • The execution times of the tasks are available as system variables and can be used for diagnostics.
  • System balancing.
  • Multicore systems are supported.

The ESM can also be used to execute programs and program parts in real time that were created in different programming environments. These can include high-level languages such as C++, IEC 61131-3 code, and model-based tools such as MATLAB® Simulink®. Program parts that were created using different programming languages can also be combined and processed within a task. The ESM controls the processes and also executes the high-level language programs deterministically in the defined order. To ensure data consistency between the tasks at all times, all data is synchronized with the GDS whenever a task is called up (see also in GDS).

PLCnext_ESM.png

Task configuration using PLCnext Engineer

You can use the PLCnext Engineer software to easily create and configure tasks. Here, you can proceed as in a conventional IEC 61131-3 program. The IEC 61131-3 program, or the program created in a different programming environment and then imported into PLCnext Engineer, can be instantiated in a task. It does not matter whether the programs were created with C++, IEC 61131-3 or MATLAB® Simulink®.

In the PLCnext Engineer Tasks and Events editor, you can instantiate a task and assign it to the desired program instances. A description of this procedure and further information on task handling with PLCnext Engineer is available in the online help, the PLCnext Engineer quick start guide (PLCNEXT ENGINEER, Order No. 1046008), and the AXC F 2152 controller user manual (Order No. 2404267). The documentation for the respective products can be downloaded at phoenixcontact.net/products. You can call the online help from within PLCnext Engineer.

See an example of tasks and program instances in PLCnext Engineer here:

Programminstanzen_des_Main_Tasks.png

Task configuration via configuration files

When a project is downloaded from PLCnext Engineer to the controller, the previous configuration files are overwritten with the new configuration files. Manual configuration describes how you can safely store your manually modified configuration in the controller file system, thus preventing the loss of data.

 

You can also modify the task configuration, the instantiation of programs and the assignment to a processor core (one ESM per processor core) via configuration files in XML format without using PLCnext Engineer. All of the important settings can be configured directly in the configuration file on the controller. To modify the configuration manually, the XML file can be edited using any editor. The ESM can load one or several configuration files and create a joint configuration.

Example of a configuration file:

<?xml version="1.0" encoding="utf-8"?>
<EsmConfigurationDocument xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" schemaVersion="1.0" 
xmlns="http://www.phoenixcontact.com/schema/esmconfig">
   <Tasks>
      <PreDefinedEventTask name="Cold"  eventName="Arp.Plc.Esm.OnColdStart" confirmed="false" priority="0" 
       watchdogTime="100000000" executionTimeThreshold="0" />
      <PreDefinedEventTask name="Warm"  eventName="Arp.Plc.Esm.OnWarmStart" confirmed="false" priority="0" 
       watchdogTime="100000000" executionTimeThreshold="0" />
      <PreDefinedEventTask name="Except"  eventName="Arp.Plc.Esm.OnException" confirmed="false" priority="0" 
       watchdogTime="100000000" executionTimeThreshold="0" />
      <IdleTask name="Idle"  watchdogTime="100000000" executionTimeThreshold="0" />
      <PreDefinedEventTask name="interbus"  eventName="Arp.Io.Interbus.OnCycleEnd" confirmed="true" priority="0" 
       watchdogTime="100000000" executionTimeThreshold="0" />
   </Tasks>
   <EsmTaskRelations>
      <EsmTaskRelation esmName="ESM1" taskName="Cold" />
      <EsmTaskRelation esmName="ESM1" taskName="Warm" />
      <EsmTaskRelation esmName="ESM1" taskName="Execpt" />
      <EsmTaskRelation esmName="ESM1" taskName="Idle" />
      <EsmTaskRelation esmName="ESM1" taskName="interbus" />
   </EsmTaskRelations>
   <Programs>
      <Program name="Main1" programType="Main" componentName="Arp.Plc.Eclr" />
      <Program name="Main2" programType="Main" componentName="Arp.Plc.Eclr" />
      <Program name="Main3" programType="Main" componentName="Arp.Plc.Eclr" />
      <Program name="Main4" programType="Main" componentName="Arp.Plc.Eclr" />
      <Program name="Main5" programType="Main" componentName="Arp.Plc.Eclr" />
   </Programs>
   <TaskProgramRelations>
      <TaskProgramRelation taskName="Cold" programName="Arp.Plc.Eclr/Main1" order="0" />
      <TaskProgramRelation taskName="Warm" programName="Arp.Plc.Eclr/Main2" order="0" />
      <TaskProgramRelation taskName="Execpt" programName="Arp.Plc.Eclr/Main3" order="0" />
      <TaskProgramRelation taskName="Idle" programName="Arp.Plc.Eclr/Main4" order="0" />
      <TaskProgramRelation taskName="interbus" programName="Arp.Plc.Eclr/Main5" order="0" />
   </TaskProgramRelations>
<TaskEvents />
</EsmConfigurationDocument>

To configure tasks for execution in the ESM (Execution and Synchronization Manager) using the *.esm.config configuration file, proceed as follows:

Defining a task

A task is defined between the tags <Tasks> and </Tasks>

Example of defining a task:

<Tasks>
  <CyclicTask name="SquareWave_Cycle"  priority="0" cycleTime="100000000" watchdogTime="100000000" executionTimeThreshold="0" />
  <CyclicTask name="CPP_Cycle"  priority="1" cycleTime="100000000" watchdogTime="100000000" executionTimeThreshold="0" />
  <CyclicTask name="PCWE_Cycle"  priority="2" cycleTime="100000000" watchdogTime="100000000" executionTimeThreshold="0" />
</Tasks>
<Tasks>
  <PreDefinedEventTask name="Cold"  eventName="Arp.Plc.Esm.OnColdStart" confirmed="false" priority="0" 
   watchdogTime="100000000" executionTimeThreshold="0" />
</Tasks>

Definition of the task starts with the task type.

Here, enter the type:

  • CyclicTask
  • IdleTask
  • PreDefinedEventTask - System event task (cold restart, warm restart, hot restart, stop, exception)

Define the tasks using the attributes from the following table:

Attribute Description
name

The name attribute defines the task name.

  • Enter a unique  task name.

It can only be used once per controller.

priority

The priority attribute defines the task priority.

  • Enter a value to specify the task priority.

0: Highest priority

15: Lowest priority

If no priority is indicated for an idle task. It is automatically lower than the lowest priority.

Note:
Within one ESM, each task must be assigned a different priority. Two or more tasks in one ESM having the same priority may lead to unwanted jitter.

cycleTime

The cycleTime attribute defines the duration of the task (for cyclic tasks only).

  • Enter the value in nanoseconds.

The minimum value of the AXC F 2152 controller is 1 ms (1000000 ns). Select a multiple of the minimum value. Depending on the application, the jitter time for a task may increase as the system load increases.

watchdogTime

The watchdog monitors whether the task was executed within the specified time.

  • Enter the value in nanoseconds. Value “0” means that there is no monitoring.

The watchdogTime attribute can be used for cyclic and idle tasks.

EventName

The following values are valid for this attribute.

  • Arp.Plc.Esm.OnColdStart (cold restart)
  • Arp.Plc.Esm.OnWarmStart (warm restart)
  • Arp.Plc.Esm.OnHotStart (hot restart)
  • Arp.Plc.Esm.OnStop (stop)
  • Arp.Plc.Esm.OnException (exception)

 

Assigning a task

Once the task has been defined, it has to be assigned to the desired ESM. Assignment is defined between the tags <EsmTaskRelations> and </EsmTaskRelations>.

Example: Assigning a task to an ESM

<EsmTaskRelations>
   <EsmTaskRelation esmName="ESM1" taskName="SquareWave_Cycle" />
   <EsmTaskRelation esmName="ESM1" taskName="CPP_Cycle" />
   <EsmTaskRelation esmName="ESM1" taskName="PCWE_Cycle" />
</EsmTaskRelations>
  • Assign the task using the attributes from the following table:
Attribute Description
esmName

The esmName attribute defines the name of the ESM the respective task is to be assigned to.

  • Enter the task name.

Example: ESM1 or ESM2 for a controller with dual core processor.

taskname

The taskname attribute defines the task to be assigned.

  • Enter the name of the task to be assigned.

 

Instantiating programs

Once the task is defined and assigned to an ESM, programs can be instantiated. Programs are defined between the tags <Programs> and </Programs>. The definition of a program instance is introduced with tag <Program>. Programs that have been programmed in IEC 61131-3 can only be sent and configured using PLCnext Engineer. The code example originates from a config file generated using PLCnext Engineer.

Instantiating programs (example):

<Programs>
   <Program name="SquareWave" programType="PCWE_SquareWave_P" componentName="Arp.Plc.Eclr" />
   <Program name="CPP_Counter" programType="CPP_Counter_P"  componentName="CPP_Counter.CPP_Counter_C-1" />
   <Program name="CPP_Counter_P1" programType="CPP_Counter_P" componentName="CPP_Counter.CPP_Counter_C-1" />
   <Program name="PCWE_Counter" programType="PCWE_Counter_P" componentName="Arp.Plc.Eclr" />
</Programs>

Instantiate programs using the attributes from the following table:

Attribute Description
name

The name attribute defines the name of the program instance.

  • Enter the name of the program instance.

The name must be unique within the controller.

programType

The programType attribute defines the program type.

  • Enter the program type.
componentName

The componentName attribute defines the name of the component that contains the program.

  • Enter the name of the component as it is defined in the *.acf.config or *.plm.config configuration file. The Arp.Plc.Eclr component is reserved for IEC 61131-3 programs that were instantiated using PLCnext Engineer (see Creating a new C++ project in Eclipse®)

 

Assigning program instances to a task

The program instances have to be assigned to a task. Assignment is made between tags <TaskProgramRelations> and </TaskProgramRelations>.

Assigning program instances to a task:

<TaskProgramRelations>
   <TaskProgramRelation taskName="SquareWave_Cycle" programName="Arp.Plc.Eclr/SquareWave" order="0" />
   <TaskProgramRelation taskName="CPP_Cycle" programName="CPP_Counter.CPP_Counter_C-1/CPP_Counter" order="0" />
   <TaskProgramRelation taskName="CPP_Cycle" programName="CPP_Counter.CPP_Counter_C-1/CPP_Counter_P1" order="1" />
   <TaskProgramRelation taskName="PCWE_Cycle" programName="Arp.Plc.Eclr/PCWE_Counter" order="0" >
</TaskProgramRelations>
  • Assign the program instance to a task using the attributes from the following table.
Attribute Explanation
taskname

The taskname attribute specifies the name of the task the program instance is to be assigned to.

  • Enter the name of the desired task the program instance is to be assigned to.
programName

The programName attribute defines the name of the program instance with the prefixed library and component names. The name is used to select the program instance to be processed in the task.

  • Enter the full name in the program instance to be processed.
order

The order attribute determines the order in which program instances are processed within a task, starting with 0.

  • Enter a number to determine the processing sequence.

The program instance with the digit 0 is processed first. Each number can only be used once for each task.