6-1
NJ-series CPU Unit Software User’s Manual (W501)
6
w
This section describes programming, including the programming languages, and the
variables and instructions that are used in programming.
6-1 Overview of Programming Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3
6-2 POUs (Program Organization Units) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-5
6-2-1 What Are POUs? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-5
6-2-2 Overview of the Three Types of POUs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-6
6-2-3 Differences between Programs, Functions, and Function Blocks . . . . . . . . . . 6-7
6-2-4 Details on Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-7
6-2-5 Details on Function Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-8
6-2-6 Details on Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-17
6-2-7 Operation That Applies to Both Functions and Function Blocks . . . . . . . . . . 6-22
6-2-8 POU Restrictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-24
6-3 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-27
6-3-1 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-27
6-3-2 Types of Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-27
6-3-3 Types of User-defined Variables in Respect to POUs . . . . . . . . . . . . . . . . . . 6-28
6-3-4 Attributes of Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-29
6-3-5 Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-30
6-3-6 Derivative Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-39
6-3-7 Array Specifications and Range Specifications for Data Types . . . . . . . . . . . 6-49
6-3-8 Variable Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-54
6-3-9 Changes to Variables for Status Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-62
6-3-10 Function Block Instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-64
6-3-11 Monitoring Variable Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-64
6-3-12 Restrictions on Variable Names and Other Program-related Names . . . . . . 6-65
6-4 Constants (Literals) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-67
6-4-1 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-67
6-4-2 Types of Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-67
6-5 Programming Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-72
6-5-1 Programming Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-72
6-5-2 Ladder Diagram Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-72
6-5-3 Structured Text Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-78
Programming