Declaring more tasks within PLC-object

How to declare more →tasks within a PLC-object:

  1. Open the PLC-object.

  2. In the opened editor for the PLC-object, search for the existing line with the already existing task.

    Example for lines with task
    TASK DefaultTask(INTERVAL := TIME#500ms, PRIORITY := 38229);
  3. Copy this line onto the clipboard and paste it directly under the line with the already existing task.

    images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/warning.svg The number of tasks per resource is restricted by the target system. See "Properties and restrictions specific to the target system" for information how many tasks are possible for the used PLC.

  4. Correct all pasted lines.

    Example for lines with tasks (after the correction)
    TASK DefaultTask(INTERVAL := TIME#500ms, PRIORITY := 38229);
    { IO } TASK FastTask(INTERVAL := TIME#100ms, PRIORITY := 20000);
    TASK SlowTask(INTERVAL := TIME#800ms, PRIORITY := 40000);

    Required corrections of the pasted lines:

    1. Replace the task name (e.g. DefaultTask) by the value requested for the new task (e.g. SlowTask).

    Optional corrections of the pasted lines:

    1. Replace the cycle time (e.g. TIME#500ms) by the value requested for the new task (e.g. TIME#100ms). Details: see "Entering cycle time within PLC-object".

    2. If you want to access hardware IOs of the target system within the application, you must label one task as IO task: Insert { IO } before TASK. If you do not label any task for accessing the hardware IOs, logi.CAD 3 uses the task that is entered in the first line beginning with TASK.
      Usage scenario 1: If the values of the IOs should not change during the execution of the application, assign the lowest priority of all tasks to the IO task (see next step for information on the priority).
      Usage scenario 2: If the values of the IOs should be transferred as early as possible for the execution of the application, assign the highest priority of all tasks to the IO task.

    3. In addition it is possible to specify one or several IO services for the IO task in the form of { IO := IO-service1, IO-service2, ...}. Condition: The IO service must be defined (e.g. with the specification for IO_IMPORT; see "Errors while editing PLC-object in editor, Correct syntax for PLC-object" for information on this specification). If no IO service is defined for an IO task, logi.CAD 3 uses all IO services not used yet.
      It is also possible to specify one IO task without IO service and several IO tasks with IO services. But observe that an IO service must not be used with several IO tasks.

    4. Replace the priority 38229 by the value requested for the new task (e.g. 40000).
      The priority of the task defines the scheduling priority of the assigned →program. Possible range: 065535, with 0 being the highest priority and 65535 being the lowest priority. Observe that your used →target system might also influence the scheduling of →POUs in the application (see "Properties and restrictions specific to the target system").

      Recommendation on entering the task priorities

      • For a task that has to react quickly to events, enter a higher priority (compared to the other tasks). Example: 10

      • For a task that executes time-intensive calculations or that accesses the file system (such as the loading/saving of →retentive variables by using the LoadRetainData block and/or SaveRetainData block), enter the lowest priority 65535.

  5. Save the PLC-object: menu fileSave

Before you load the application onto the PLC, assign the appropriate program instances to the declared tasks. Details: see "Assigning more program types (= creating new instances)".