5 Designing Tasks
5-14
NJ-series CPU Unit Software User’s Manual (W501)
Example of User Programming Using the ActEventTask Instruction
Example 1: Executing an Event Task Only Once When the Value of a Variable Changes
In the following example, the upward differentiation option is used for the ActEventTask instruction.
This causes the Task1 event task to be executed only once when the BoolVar BOOL variable
changes to TRUE.
Example 2: Executing an Event Task Repeatedly While the Value of a Variable Matches a Specified
Value
In the following example, the upward differentiation option is not used for the ActEventTask instruc-
tion. This causes the Task1 event task to be executed as long as the BoolVar BOOL variable is
TRUE. After the execution of the event task has started, it is executed to the end even if the value of
BoolVar changes to FALSE during execution.
@ActEventTask
EN ENO
TaskName
'Task1'
BoolVar
Task1
event task
The event task is executed only once.
TRUE
FALSE
BoolVar
High
Low
Execution
priority
Primary
periodic task
Primary period
ActEventTask
instruction is executed.
Interrupted.
ActEventTask
EN ENO
TaskName
'Task1'
BoolVar
Task1
event task
The event task is executed repeatedly
while the BoolVar variable is TRUE.
Task1 is already in execution so any ActEventTask
instructions that specify Task1 are ignored.
High
Low
Execution
priority
Primary
periodic task
Primary period
ActEventTask instruction
is executed.
Interrupted.
TRUE
FALSE
BoolVar
Interrupted.
After the execution of the event
task has started, it is executed
to the end even if the value of
the BoolVar variable changes
to FALSE.