Application Solutions
MultiFlex PCI 1000 Series User's Manual
139
While a background task executes a
Wait
command, that task no longer receives any processor time. For
tasks that perform monitoring functions in an endless loop, the command throughput of the controller can
be improved by executing a
Wait
command at the end of the loop until the task needs to run again.
A common way for a background task to be terminated, is when the command sequence of the task
finishes execution. This will occur at the end of the macro or if a
B
rea
K
(
BK
) command is executed.
When a task is terminated, the resources it required are made available to run other background tasks.
;Multitasking example – this background task will terminate itself if the
;motor error status bit for axis #1 is set. This sequence is similar to
the ;previous example except that the task is self terminating, so
register #100
is not required.
GT0,LU”STATUS”,1RL@0,IC0,JR-3,NO,AL1,AR200,BK
;loop
on
axis
#1
status
bit
0,
if
set;
set
;bit
#1
of
register
200,
task
self
terminates
;(no
commands
left
to
execute)
Alternatively, the
E
scape
T
ask (
Ten
) command can be used to force a background task to terminate.
When a task is generated by the
GT
command, a value known as the
Task ID
is placed into the
accumulator. This value should immediately be copied into a user register. The parameter to this
command must be the value that was placed in accumulator (register 0) of the parent task, when the
Generate Task command was issued.
;Multitasking example – Terminating a background task with the Escape
Task command.
GT100,AR@150
;call
macro
#100
as
a
background
task,
copy
;
task
ID
into
user
register
150
ET@150
;to
terminate
background
task
issue
escape
;
task
command
with
parameter
n
=
Task
ID
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com