6 Programming
6-8
NJ-series CPU Unit Software User’s Manual (W501)
]
Programs are executed when the task they are assigned to is executed.
Order of Execution
You can set the order of execution of all programs in a task. You specify this order under Task
Settings - Program Assignment Settings in the Sysmac Studio.
Related System-defined Variables
All programs have the following system-defined variables in the local variables.
*1 A CPU Unit with unit version 1.08 or later and Sysmac Studio version 1.09 or higher are required.
*2 To enable or disable the program, use the PrgStart or PrgStop instruction. You can make setting for the Prg-
Start instruction so that it executes the program without changing P_First_Run to TRUE.
A function block consists of a function block definition that is made in advance and instances that are
used in the actual programs. Create function blocks in the following order.
1
Create the function block definition.
Create the algorithm.
2
Placing an Instance of the Function Block Definition in a Program
Call the function block definition from a program or another function block.
You can call the same function block definition from more than one program or function block.
After you place an instance of a function block definition in a program or in another function
block, you can manipulate and execute it as an independent entity.
Program Execution Conditions
Variable
name
Meaning Function
Data
type
Read/write
P_First_RunM
ode
First RUN
Period Flag
This flag is TRUE for only one task period after the
operating mode of the CPU Unit is changed from
PROGRAM mode to RUN mode if execution of the
program is in progress.
This flag remains FALSE if execution of the pro-
gram is not in progress.
Use this flag to perform initial processing when the
CPU Unit begins operation.
BOOL Read
P_First_Run
*1
First Program
Period Flag
This flag is TRUE for one task period after execu-
tion of the program starts.
*2
Use this flag to perform initial processing when exe-
cution of a program starts.
BOOL R
P_PRGER Instruction
Error Flag
This flag changes to and remains TRUE when an
instruction error occurs in the program or in a func-
tion/function block called from the program.
After this flag changes to TRUE, it stays TRUE until
the user program changes it back to FALSE.
BOOL Read/write
P_CY Carry Flag This flag is updated by some instructions. BOOL Read
6-2-5 Details on Function Blocks
Procedure to Create Function Blocks