Tasks
In LogicLab, you have six tasks to select for your PLC program. In the Project panel, expand the Task list to see them.
- Fast: the program runs cyclically in the fastest PLC period. Fast task period ranges from 0.25 milliseconds to 2 milliseconds. It synchronizes with the EtherCAT cycle time.
- Moderate: the program runs cyclically in a period between Fast and Slow.
- Slow: the program runs cyclically in a slower period than the Fast task. Typically the Slow task period is 5-10 time slower than the Fast task period.
- Background: the program runs cyclically in a long period (usually slower than Slow) at a lower priority than the other tasks. It is paused when another task needs to run. This task can be used to check something periodically without interrupting other programs.
- Boot: the program runs when the KINGSTAR PLC Runtime is started.
- Init: the program runs when KINGSTAR LogicLab restarts the program (click Cold restart in the toolbar). Both retained and non-retained variables are reset. By default, KsMain, KsAxes, and KsCamTables are under Init. They pass the resource configuration to KINGSTAR. Do not edit (not even add a space) or delete them, or the programs may become unstable.
Moderate and Slow's periods can be changed. To change them:
- In the Project panel, expand the Task list.
- Right-click Moderate and select Task configuration.
- In Task configuration, click the Moderate's Set period and choose Yes.
- Click the Moderate's Period and enter the period you want. The suggested value is between Fast and Slow. Because we are adjusting Slow's value in the next step, we set it to 10.
- Do the same thing to Slow. In Slow's Period, enter the value you want. The value must be a multiple of the Fast task. For example, Fast is set to 10 milliseconds, Slow must be 20, 30, 40 or other value that is a multiple of 10. The value can't be the same as Fast's, and it can't be zero.
- When you finish editing, click OK.
NOTE: If you click the Period cell but it doesn't become editable, just click it again.
NOTE: If you set the Set period to No, the period will be reset to its default value.
NOTE: If you set the Set period to No, the period will be reset to its default value.
Overtime check for Fast tasks
KINGSTAR LogicLab has the mechanism "overtime check" that detects a Fast task that is running too long. If the Fast's period is too short to run the tasks, an error message will be displayed in the Output pane, and the PLC program will stop running. The figure below shows the error message. The Fast's period is 1 millisecond (1000 microseconds), but LogicLab takes 94098 microseconds to complete the task.
Overtime check doesn't count the access time of I/O modules. For example, if the Fast's period is 1 millisecond, the tasks take 920 microseconds and the access time of I/O modules is 200 microseconds. Overtime check won't count the latter. If there are customized plugins used with KINGSTAR PLC Runtime (llexec), overtime check won't count the process time of the plugins either.
Fast tasks' period and EtherCAT cycle time
The fast tasks' period must be the same as the EtherCAT cycle time. If they are not equal, the following problem may happen:
- Synchronization logic: to reduce the delays in communication, Fast tasks synchronize with EtherCAT cycle time. Fast tasks are triggered to run every time the EtherCAT cyclic packet returns. If the Fast tasks' period is not equal to the EtherCAT cycle time that triggers the tasks, issues may arise.
- Task's cycle time: the fast tasks may not have stable cycle time.
NOTE: If you have High-Speed license, supported minimum cycle time for PLC is 250 microseconds.