Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeContact

The text of a manual · part 12 of 55

Hand-Held Terminal (Catalog Number 1747-PT1) User Manual: 5 - Ladder Program Basics

Pages 85 to 98 of 486, from Hand-Held Terminal (Catalog Number 1747-PT1) User Manual

The original document is the PDF (1.5 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.

For the Allen-Bradley 1747-PT1

Page 85

Chapter

5

Ladder Program Basics This chapter discusses the basic operation of ladder programs. For a more simplified introduction to ladder programming, refer to The Getting Started Guide for HHT, catalog number 1747–NM009. This guide is intended for the first time user.

Ladder Programming

The ladder program you enter into the controller’s memory contains bit (relay logic) instructions representing external input and output devices. It also contains other instructions, as described in the section “The Instruction Set,” chapters 15 through 26. As your program is scanned during controller operation, the changing on/off state of the external inputs is applied to your program, energizing and de-energizing external outputs according to the ladder logic you have programmed. To illustrate how ladder programming works, we chose to use bit (relay logic) instructions, since they are the easiest to understand. The three instructions discussed in this section are: Examine if Closed (XIC) ] [

Analogous to the normally open relay contact. For this instruction, we ask the processor to “Examine if (the contact is) Closed.”

]/[

Analogous to the normally closed relay contact. For this instruction, we ask the processor to “Examine if (the contact is) Open.”

Examine if Open (XIO)

Output Energize (OTE) ( )

Analogous to the relay coil. The processor makes this instruction true (analogous to energizing a coil) when there is a path of true XIC and XIO instructions in the rung.

Keep in mind that operation of these instructions is similar but not equivalent to that of relay contacts and coils. In fact, a knowledge of relay control techniques is not a prerequisite for programming the SLC 500 Programmable Controller. These instructions are explained in greater detail in chapter 16, Bit Instructions.

5–1

Page 86

Chapter 5 Ladder Program Basics

A 1–Rung Ladder Program

A ladder program consists of individual rungs, each containing at least one output instruction and one or more input instructions. Variations of this simple rung construction are discussed in later chapters. This ladder rung has two input instructions and an output instruction. An output instruction always appears at the right, next to the right power rail. Input instructions always appear to the left of the output instruction. Input Instructions

Output Instructions

XIC

XIO

OTE

B3

B3

B3

10

11

XIC = Examine if Closed XIO = Examine if Open OTE = Output energize

12 Address B3/10 Address B3/11 Address B3/12

A Simple Rung, Using Relay Logic Instructions

Note that each instruction in the diagram above has an address. As described in the chapter 4, this address identifies a location in the processor’s data files, where the on/off state of the bit is stored. Addresses of the above instructions indicate they are located in the Bit data file (B3), bits 10, 11, and 12: 15 14 13 12 11 10

9

8

7

6

5

4

3

2

1

0

0

0

0

0

0

0

0

0

0

0

0

0

0

1

0

OTE XIO Bit Status

1

Bit Data File 3 – Element 0

XIC

In the preceding diagram, we indicated that bit 10 is logic 1 (on), bit 11 is logic 0 (off), and bit 12 is logic 1 (on). These logic states indicate whether an instruction is true or false, as pointed out in the table below. The status of the instruction is XIC Examine if Closed ] [

XIO Examine if Open ]/[

OTE Output Energize ( )

Logic 0

False

True

False

Logic 1

True

False

True

If the data table bit is

From the diagram and table above, we see that the state of bits 10, 11, and 12 indicate that the XIC, XIO, and OTE instructions of our rung are all true. The true/false state of instructions is the basis of controller operation, as indicated in the following paragraphs.

5–2

Page 87

Chapter 5 Ladder Program Basics

Logical Continuity

During controller operation, the processor determines the on/off state of the bits in the data files, evaluates the rung logic, and changes the state of the outputs according to the logical continuity of rungs. More specifically, input instructions set up the conditions under which the processor will make an output instruction true or false. These conditions are: • When the processor finds a continuous path of true input instructions in a rung, the OTE output instruction will become (or remain) true. We then say that “rung conditions are true.” • When the processor does not find a continuous path of true input instructions in a rung, the OTE output instruction will become (or remain) false. We then say that “rung conditions are false.” The figure below shows the on/off state of output B3/12 as determined by the changing states of the inputs in the rung. Input Instructions

Output Instructions

XIC

XIO

OTE

B3

B3

B3

10

11

Inputs

12

Output

Bit Status

Time

XIC

XIO

OTE

XIC

XIO

OTE t1(initial)

False

True

False

0

0

0 t2

True

True

Goes True

1

0

1 t3

True

False

Goes False

1

1

0 t4

False

False

Remains False

0

1

0

5–3

Page 88

Chapter 5 Ladder Program Basics

Series Logic

In the previous section on logical continuity, you have seen examples of series (And) logic. This means that when all input conditions in the path are true, energize the output. Example – Series Inputs B

A

C

In the above example, if A and B are true, energize C.

Parallel Logic

Another form of logical continuity is Parallel (OR) logic. This means that when one or another path of logic is true, energize the output. Example – Parallel Inputs A

C

B

In the above example, if A or B is true, energize C. Use branching to form parallel logic in your user program. Branches can be established at both input and output portions of a rung. The upper limit on the number of levels which can be programmed in a branch structure is 75. The maximum number of instructions per rung is 127.

5–4

Page 89

Chapter 5 Ladder Program Basics

Input Branching Use an input branch in your application program to allow more than one combination of input conditions to form parallel branches (OR–logic conditions.) If at least one of these parallel branches forms a true logic path, the rung logic is enabled. If none of the parallel branches forms a true logic path, rung logic is not enabled and the output instruction logic will not be true. (Output is not energized.) Example – Parallel Input Branching A

D

B

C

In the above example, either A and B, or C provides a true logical path.

Output Branching You can program parallel outputs on a rung to allow a true logic path to control multiple outputs. When there is a true logic path, all parallel outputs become true. Example – Parallel Output Branching A

C

B MOV E U

In the above example, either A or B provides a true logic path to all three output instructions.

5–5

Page 90

Chapter 5 Ladder Program Basics

With the SLC 5/02 processor, additional input logic instructions (conditions) can be programmed in the output branches to further condition control of the outputs. When there is a true logic path, including extra input conditions on an output branch, that branch becomes true. Example – Parallel Output Branching with Conditions (SLC 5/02 Only) C

A B

D

E

In the above example, either A and D or B and D provide a true logic path to E

Nested Branching With the SLC 5/02 processor, input and output branches can be “nested” to avoid redundant instructions, to speed–up processor scan time, and provide more efficient programming. A “nested” branch is a branch that starts or ends within another branch. You can nest branches up to four levels deep. Example – Nested Input and Output Branches

Important: APS allows all branching combinations to be programmed in a fixed, SLC 5/01, or SLC 5/02 processor. The HHT does not support nested input or output branches or additional conditions on output branches to be programmed in a fixed or SLC 5/01 processor.

5–6

Page 91

Chapter 5 Ladder Program Basics

Nested branches can be converted into non–nested branches by repeating instructions to make parallel equivalents. Example A

B

C

F

D E Nested Branch A

B

C

D

C

F

E Non–nested Equivalent Parallel Branch

5–7

Page 92

Chapter 5 Ladder Program Basics

A 4–Rung Ladder Program

The following 4-rung ladder program uses the same 3 bit addresses as our simple 1-rung diagram. It also uses an external input bit address and an external output bit address. Note that individual bits are addressed repeatedly. For example, B3/11 is addressed with an XIC instruction in rungs 1 and 4, and it is addressed with both an XIC and an OTE instruction in rung 2. During normal controller operation, the processor checks the state of the input data file bits then executes the program instructions individually, rung by rung, from the beginning to the end of the program; as it does, it updates the data file bits and the appropriate output data file bits accordingly. When XIC instruction I:0/1 goes true (because an external momentary push button closes): • Rung 1 is evaluated as false, because XIC instruction B3/11 is false at this time. • Rung 2 is evaluated as true. XIC B3/11 in the branch of this rung goes true to maintain continuity in the rung. • Rung 3 is evaluated as true. • Rung 4 is evaluated as true because XIC B3/11 has gone true. The external device represented by OTE O:0/2 is energized.

5–8

Page 93

Chapter 5 Ladder Program Basics

Application Example Use the following program to achieve the maintained contact action of an On–Off toggle switch using a momentary contact push button. (Press for On; press again for Off.) The first time you press the push button (represented by address I:0/1), instruction B3/11 is latched, energizing output O:0/2. The second time you press the push button, instruction B3/12 unlatches instruction B3/11, de–energizing output O:0/2. Instruction B3/10 prevents interaction between instructions B3/12 and B3/11. 1

2

I:0.0 ] [ 1

B3 ]/[ 10

B3 ] [

I:0.0 ] [ 1

B3 ]/[ 10

B3 ]/[

11

B3 ( ) 12

12

B3 ( ) 11

B3 ] [ 11 3

I:0.0 ] [ 1

B3 ( ) 10

4

B3 ] [

O:0.0 ( ) 2

11 Status Bit Rung

I:0/1

B3/10

B3/11

B3/12

1

] [

]/[

] [

( )

2

] [

]/[

3

] [

( )

4

( )

] [

] [

O:0/2

]/[

( )

As previously indicated, the processor executes instructions individually, rung by rung, from the beginning to the end of the program. This is called a program scan and it is repeated many times a second. The figure on the next page indicates in greater detail what happens during individual scans when an external input device (represented by I:0/1) is operated.

5–9

Page 94

Chapter 5 Ladder Program Basics

When the state of a bit changes during the scan, the effects this may have in earlier rungs of the program are not accounted for until the next scan. To point this out, we have shown successive scans (1000 and 1001, 2000 and 2001, etc.).

XIC I:0/1 1

I:0.0 B3 B3 ] [ ]/[ ] [ 1 10 11

B3 ( ) 12

2

I:0.0 B3 ] [ ]/[ 1 10

B3 ( ) 11

B3 ]/[ 12

Goes True

Instruction Execution T = true at time of execution F = false at time of execution Scan 1000

Scan 1001

T

T

F

F

T

F

T

F

T

T

T

T

T

F

T

T

F

B3 ] [ 11 3

I:0.0 ] [ 1

B3 ( ) 10

4

B3 ] [ 11

O:0.0 ( ) 2

Goes False

T

F

F

F

T

T

F

T

T

T

T

T

T

T

T

Scan 2000

Scan 2001

F

F

T

F

F

T

T

F

F

F

T

T

F

T

T

T

T

The diagram above is the same one that appears on the preceding page. This diagram is also represented below, with each instruction replaced with a T or F, indicating the initial True/False status of the instruction.

F

T

Goes True

F

T

F

F

F

F

T

T

T

T

Scan 3000

Scan 3001

T

T

T

T

T

F

F

F

T

T

F

F

T

F

T

F

T

F

F

F

T

T

T

T

F

F

F

F

F

F

The table at the right indicates how the instructions are executed when XIC instruction I:0/1 changes state. (I:0/1 represents an external momentary contact push button.)

Goes False

Scan 4000

Scan 4001

F

F

F

F

F

T

F

F

F

F

T

F

F

T

T

F

F

5–10

F

F

F

F

F

F

F

F

F

Page 95

Chapter 5 Ladder Program Basics

Operating Cycle (Simplified)

The diagram below shows a simplified operating cycle, consisting of the program scan, discussed in the last section, and the I/O scan. I/O SCAN PROGRAM SCAN

In the I/O scan, data associated with external outputs is transferred from the output data file to the output terminals. (This data was updated during the preceding program scan.) In addition, input terminals are examined, and the associated on/off state of the bits in the input data file are changed accordingly. In the program scan, the updated status of the external input devices is applied to the user program. The processor executes the entire list of instructions in ascending rung order. Status bits are updated according to logical continuity rules as the program scan moves from instruction to instruction through successive ladder rungs. The I/O scan and program scan are separate, independent functions. Thus, any status changes occurring in external input devices during the program scan are not accounted for until the next I/O scan. Similarly, data changes associated with external outputs are not transferred to the output terminals until the next I/O scan. Important: The description here does not account for the processor overhead and communications portions of the operating cycle. These are discussed in appendix D, Estimating Scan Time.

5–11

Page 96

Chapter 5 Ladder Program Basics

The following figures indicate how the operating cycle works for the 4-rung ladder program discussed on pages 5–7 through 5–10. When the Input Goes True Scan before input goes true (scan 999). Input Scan

15 14 13 12 11 10

9

8

7

6

5

4

3

2

1

0

Input Data File

0

0

0

0

0

0

0

0

0

0

0

I:0

0

0

0

0

0

Input Bit De–energized

I:0.0 Program Scan

Ladder Program

Instructions are normal intensity.

O:0.0

1

2

15 14 13 12 11 10

9

8

7

6

5

4

3

2

1

0

Output Data File

0

0

0

0

0

0

0

0

0

0

0

O:0

0

0

0

0

0

Output Bit De–energized

First scan after input goes true (scan 1000). Input Scan

15 14 13 12 11 10

9

8

7

6

5

4

3

2

1

0

Input Data File

0

0

0

0

0

0

0

0

0

1

0

I:0

0

0

0

0

0

Input bit energized

Ladder Program

Instructions Intensified

I:0.0

O:0.0 1 Program Scan

2

15 14 13 12 11 10

9

8

7

6

5

4

3

2

1

0

Output Data File

0

0

0

0

0

0

0

1

0

0

0

O:0

0

0

0

0

0

Output Bit De–energized

Second scan after input goes true (scan 1001). Input Scan

15 14 13 12 11 10

9

8

7

6

5

4

3

2

1

0

Input Data File

0

0

0

0

0

0

0

0

0

1

0

I:0

0

0

0

0

0

Input Bit Energized

I:0.0

Program Scan

Ladder Program

Instructions Intensified

O:0.0

1

2

15 14 13 12 11 10

9

8

7

6

5

4

3

2

1

0

0

0

0

0

0

0

0

0

1

0

0

0

0

0

0

0

Output Bit Energized

5–12

Output Data File O:0

Page 97

Chapter 5 Ladder Program Basics

When the Input Goes False Scan before input goes false (scan 1999). Input Scan

15 14 13 12 11 10

9

8

7

6

5

4

3

2

1

0

Input Data File

0

0

0

0

0

0

0

0

0

1

0

I:0

0

0

0

0

0

Input Bit Energized

I:0.0

Ladder Program

Instructions intensified

O:0.0

1 Program Scan

2

Output Data File

15 14 13 12 11 10

9

8

7

6

5

4

3

2

1

0

0

0

0

0

0

0

0

0

1

0

0

O:0

0

0

0

0

0

Output Bit Energized

First scan after input goes false (scan 2000). Input Scan

15 14 13 12 11 10

9

8

7

6

5

4

3

2

1

0

Input Data File

0

0

0

0

0

0

0

0

0

0

0

I:0

0

0

0

0

0

Input Bit De–energized

I:0.0 Program Scan

Ladder Program

Instructions are normal intensity.

O:0.0

1

2

15 14 13 12 11 10

9

8

7

6

5

4

3

2

1

0

Output Data File

0

0

0

0

0

0

0

1

0

0

0

O:0

0

0

0

0

0

Output Bit Energized

Second scan after input goes false (scan 2001). Input Scan

15 14 13 12 11 10

9

8

7

6

5

4

3

2

1

0

Input Data File

0

0

0

0

0

0

0

0

0

0

0

I:0

0

0

0

0

0

Input Bit De–energized

I:0.0 Program Scan

Ladder Program

Instructions are normal intensity

O:0.0 2

1 15 14 13 12 11 10

9

8

7

6

5

4

3

2

1

0

Output Data File

0

0

0

0

0

0

0

0

0

0

0

O:0

0

0

0

0

0

Output Bit De–energized

5–13

Page 98

This page is a scan with no text; see it in the PDF.