Danaher Motion
06/2005
Project
M-SS-005-03 Rev
E
57
3.4.1.
Loading the Program
BASIC Moves automatically loads all tasks in your project when you select
Run Project. You can select Run Project by selecting it from the Debug
menu, by pressing the F5 key, or by pressing the “Load Task”and “Run
Task” buttons on the tool bar. By default, tasks are loaded from the host PC
to the MC at a low priority (Priority = 16).
When you select Run Task, the project’s main task is started at the lowest
priority (Priority = 16). You can change the priority of the main task by
selecting View-> Project Manager->Options and then changing the priority in
the bottom of the window. If you structure your software so that the main
program loads all other tasks, the Run Project button starts your machine.
3.4.2.
Preemptive Multi-tasking & Priority Levels
Because many tasks share one processor, you must carefully design your
system so tasks get processing resources when they need them. You do not
want the operator interface taking all the resources when you need fast
response to a realtime event. The operating system provides system
resources based on two criteria: task priority level and time slice.
When you create a program, you must select the task
priority level
. MC-
BASIC allows you to specify 16 levels of priority. The task with the highest
priority takes all the system resources it can use. In fact, no task of a lower
priority receives any resources until all tasks of higher priority relinquish
them. Most systems have one main task that runs at a medium priority and
perhaps a background task that runs at a low priority, with a few high priority
tasks. At every time slice, the MC re-evaluates which task has the highest
priority and assigns resources to it.
The BASIC Moves terminal window relies on the MC command line task,
which runs at priority 2. If you start a task with priority 1, the terminal will not
be available until the task is complete or idle. Consequently, you will not be
able to communicate with the MC and you may have to power-down the
system to recover the terminal window. You can optionally set the priority of
a task when you start it. For example:
StartTask Aux.Prg Priority=6
The default priority of events is 1 (highest) and the default priority of
programs is 16.
Time Slice
is a method by which the operating system divides up resources
when multiple tasks share the same priority level. The MC provides the first
task with one time slice, the next time slice goes to the second, the next to
the third, and so on. The time slice is currently one millisecond duration. This
method is sometimes called round robin scheduling.
3.4.3.
Inter-Task Communications and Control
Tasks can control one-another. In fact, any task can start, continue, idle, or
kill any other task, regardless of which task has the higher priority. For
detailed information on these commands, refer to the
SERVOSTAR
®
MC
Reference Manual
.