UD70
Issue code: 70nu2
DPL programming 4-7
4.6 Tasks and real-time programming
Real-time programming runs with reference to a clock to enable the user to
specify the actual times instructions are executed, not just the order in
which they are executed. When real-time programming, a task Structure
(or philosophy) has to be maintained.
UD70 programs contain sections called tasks, where a task enables a priority
to be given to a sub-routine. Seven levels of priority are defined by these
tasks in the following order:
•
INITIAL task
•
BACKGROUND task
•
CLOCK task
•
ENCODER task
•
SPEED task
•
EVENT task
•
ERROR task
Each task is specified by its name in the program. The contents of each task
must be placed in braces { }{ }.
Example
CLOCK{
instructions
}
INITIAL task
The INITIAL task is used typically to initialize program variables and Drive
parameters in the DPL program. The task runs only when the UD70 is reset
or at the moment AC power is applied.
The
INITIAL task has total priority over all other tasks when running; the
other tasks are prevented from running. This is significant when the CLOCK,
EVENT
or ENCODER tasks are to manipulate data which have initial values.
Example
INITIAL{
// This is the only place to reliably initialize ‘timer’
timer% = 0
}
CLOCK{
//This task is set at 5ms
//The value of timer must be initialized before CLOCK is run
timer% = timer% + 1
IF timer% > 200 THEN
//200, 5ms intervals = 1 second
PRINT “1 Second expired”
timer% = 0
ENDIF
}