Project 06/2005
Danaher
Motion
56 Rev
E
M-SS-005-03l
In this case, both Explorer and Word have their own contexts. They share
one computer, but run as if the other were not present. There is inter-task
communication. If you double-click on a document in the file manager, it
launches Word to edit the file you clicked.
With MC-BASIC, you can use different tasks to control different operational
modes: one for power up, one for set-up, one for normal operation, and
another for when problems occur. Like Windows, each task can run
independently of the others, and you can prescribe interactions between
tasks.
Multi-tasking is used when you want multiple processes to run largely
independent of each other. For example, if you are using the MC to interface
to the operator, you will usually use a separate task to execute the interface
code. Another example is when two parts of a machine are largely
independent of each other. There is usually some control required between
tasks as one task may start or stop another.
If a machine is simple to control, you should try to keep the entire program in
one task (in addition to Config.Prg). If you do need to use multi-tasking, you
should keep a highly structured architecture. Kollmorgen recommends that
you limit use of the main task for axis and group set up, machine
initialization, and controlling the other tasks. Normal machine operation
should be programmed in other tasks. For example, Main.Prg might be
limited to setting up axes, and then starting Pump.Prg,
Conveyor.Prg
,
and
Operator.Prg.
Do not split control of an axis or group across tasks. You can put control for
multiple axes in one task. Ideally, you should use multiple tasks for machines
where different sections operate more or less independently. You can also
use tasks to implement different operational modes.
Multi-tasking is a powerful tool, but it carries a cost. It is easy to make errors
that are difficult to find. When multiple tasks are running concurrently,
complex interaction is difficult to understand and recreate. Limit the use of
tasks to situations where they are needed.
Do not create a task as a substitute for an event handler. Events and tasks
are not the same. MC-BASIC supports event handlers to respond to realtime
events. Events are similar to interrupts in microprocessor systems. They
normally run at higher priorities than the programs that contain them. They
are ideal for quick responses to realtime events. Add the event handler to an
existing task to respond to an event.
Do not use tasks in place of subroutines. Remember that when you start a
task, the original task continues to run. When you call a subroutine, you
expect the calling program to suspend execution until the subroutine is
complete. The behavior of tasks where the two routines continue to execute
can cause complex problems.
Knowing when to use multi-tasking and when to avoid it requires some
experience. If you are new to multi-tasking, you may want to start slow until
you are familiar with how it affects program structure. When you start a new
project, BASIC Moves creates the main task as part of opening a new
project. After that process is complete, you can add a new task to your
project by selecting File, New. You can also press the new task button on the
BASIC Moves tool bar.