Download Introduction

Transcript
Chapter 2
Divide Logic into Tasks, Programs, Routines, and Add-On Instructions
Decide When to Use Tasks,
Programs, and Routines
Comparison
Use these considerations to determine when to use a task, program, or routine.
Task
Program and Equipment
Phase
Quantity available Varies by controller (4, 6, 8,
or 32)
Routine
Add-On Instruction
32 program and equipment Unlimited number of
phases (combined) per task routines per program
(100 for ControlLogix and
SoftLogix controllers)
Function
Determines how and when
code will be executed
Organizes groups of
routines that need to share
a common data area
Use
•
Most code should
reside in a continuous
task
•
•
Use a periodic task for
slower processes or
when time-based
operation is critical
•
Use an event task for
operations that
require
synchronization to a
specific event
•
Configurable
execution order within
a task
•
Isolate individual
batch phases or
discrete machine
operations
•
A high number of
tasks can be difficult
to debug
•
•
May need to disable
output processing on •
some tasks to improve
performance
Data spanning
•
multiple programs
must go into
controller-scoped area •
Listed in the Controller
Organizer in the order
of execution
•
Considerations
•
Tasks can be inhibited
to prevent execution
Contains executable code
(relay ladder, function block
diagram, sequential
function chart, or structured
text)
•
Put major equipment
pieces or plant cells
into isolated programs •
Use programs to
isolate different
programmers or create •
reusable code
•
•
Unlimited number of
Add-On Instructions in a
project
Contains executable code
(relay ladder, function
block diagram, or
structured text)
Isolate machine or cell •
functions in a routine
Use the appropriate
language for the
process
Modularize code into
subroutines that can
be called multiple
times
Subroutines with
multiple calls can be
difficult to debug
Data can be
referenced from
program-scoped and
controller-scoped
areas
Standardize modules
of code
•
Very specific or
focused operations
•
Extensions to the
base instruction set
•
Encapsulate an
instruction from one
language for use in
another language
•
Instance based
monitoring of logic
and data
•
If you have a lot of
parameters or
specialized options,
consider multiple
Add-On Instructions
•
Calling a large
number of Add-On
Instructions impacts
scan time
Calling a large number
•
of routines impacts
scan time
Listed in the Controller
Organizer as Main,
•
Fault, and then
alphabetically
•
•
Must use
cross-reference or
find to locate calls to
an Add-On Instruction
Can edit offline only
Supports only some
data types.
Changes to data
values must be made
for each instance
For more information about equipment phases, see Chapter 11, Develop
Equipment Phases for Batch Control.
20
Publication 1756-RM094C-EN-P - June 2007