Tasks
A task decides when programs run. Every project has the continuous task, which runs once on every scan. A project file can also hold periodic tasks, which run on a slower beat.
The continuous task
The continuous task runs every scheduled program once per scan. A new project has one program, MainProgram, and it runs in this task. You do not set anything up.
Programs and routines
- Programs run one after another, in the order they are listed in Project Explorer.
- Inside a program, the main routine runs first. Its rungs run from the top down.
- Another routine runs only when a rung calls it with Call routine. It runs where the call sits, then the calling routine carries on.
- A program that is not scheduled never runs by itself.
See Rung order for why the order of rungs matters.
Periodic tasks
A periodic task runs its programs every so many milliseconds instead of every scan. Use one for work that can be slower, such as a once-a-second report.
- The period must be a whole multiple of the project's scan time, and at most 60000 ms.
- A task has an optional phase, which delays its first run by whole scans so two tasks do not land on the same scan.
- A project holds at most 16 tasks.
- When several tasks are due on the same scan, the one with the shortest period runs first.
- Each scheduled program belongs to exactly one task, and a program appears once.
- A task cannot hold an unscheduled program.
The editor does not have a screen for periodic tasks. They come from a project file that already holds them, which a teacher or another tool can supply. A project without tasks runs everything in the continuous task.
Good to know
- A project that breaks one of these rules is refused when it runs, with a message that names the task.
- Use a scan time that is a whole fraction of your fastest period, so every period is an exact multiple.