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

The text of a manual · part 25 of 50

Festo Software Tools: Statement list and Ladder diagram for SF 3, FST 200 Manual, pages 241 to 250

Pages 241 to 250 of 496

The original document is the PDF (3.1 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.

Filed in the catalog under the Festo FPC-202

Page 241

FST 200-LDR

5. Programming in ladder diagram

5.4.3 Counters All Festo controllers have integrated counters which can be used to count events (e.g. units). As in the case of timers, counters are assigned three operands. These provide information on the status, current count and preset (quantity to be counted) of the counter. These are the operands: • Znn for the counter status (active or inactive) • ZWnn for the counter word (current count) • ZPnn for the counter preselect (counter preset)

nn represents the address of the counter. 32 counters are available. Two types of counters can be implemented in a ladder diagram program. These are: • incremental counters • decremental counters Incremental counters count up (increment) from the current count. Decremental counters count down (decrement) from the current count.

9610a

5-63

Page 242

FST 200-LDR

5. Programming in ladder diagram

Counter status The counter status operand indicates whether the counter is activated or deactivated. One-bit operands are the type of operand which can be set, reset or interrogated. Znn=0

Counter is deactivated (stopped or expired)

Znn=1

Counter is activated (it expires )

Ensure that you interrogate the counter status in the conditional part of the rung (normally open contact) before incrementing or decrementing a counter in the executive part. Counter preset The counter preset represents the end value for incremental counters and the start value for decremental counters. The operand for the counter preset is a permanent multibit operand. The counter preset of a counter is stored until a new counter preset is defined. The value of the counter preset must lie within the following ranges: 0.................65535 -32768....+32767 $0000..........$FFFF

(decimal without prefix) (decimal with prefix) (hexadecimal)

It is possible to enter a multibit operand (for example IW0) instead of an absolute constant.

5-64

9610a

Page 243

FST 200-LDR

5. Programming in ladder diagram

Counter word The counter word is a non-permanent multibit-operand and indicates the current counter status. Initializing a counter Before using a counter in an LDR program it must be entered as an incremental or decremental counter. During initialization, the start value of the counter is loaded into the counter word. For incremental counters the start value is 0. In order to decrement, the counter preset must be loaded into the counter word. The start value of the counter word is then the same as the counter preset.

Counter preselection: 12345

Up-counter Contents of counter word

Downward counter Contents of counter word

(initial value) 0

12345 (initial value)

(final value) 12345

0 (final value)

As when initializing a timer, a box has to be entered into the rung. In the selection window Box definition (refer to Fig. 5.21), activate the function Counter initialization. The counter box is inserted into the rung.

9610a

5-65

Page 244

FST 200-LDR

5. Programming in ladder diagram

Incremental counter The counter box is sufficient for initialization of incremental counters. Activate the function Enter operand and first enter the counter operand (e.g. C1 for counter 1) followed by the counter preset (e.g. 100). The figure below shows an example for initializing and incrementing a counter.

5-66

9610a

Page 245

FST 200-LDR

5. Programming in ladder diagram

Rung 1: The counter is only initialized by a rising edge at input I0.0 if it is deactivated. The constant 100 is loaded into the counter preset of the counter and the counter word is set to zero. The operand for the counter status (C1) is then 1. Rung 2: If the counter is activated, the value of the counter word is incremented by 1 for every rising edge at I0.1. The operand for the counter status becomes 0 as soon as the value of the counter word has reached the counter preset. The counter is then deactivated and a signal at input I0.1 has no further effect on the counter. Rung 3: Counter C1 can be deactivated at any time by a rising edge at I0.2. The operand for the counter status is then 0. The actual count in the counter word is unchanged. Rung 4: A rising edge at input I0.3 activates counter C1. The operand for the counter status becomes 1 and the counter word is set to 0.

9610a

5-67

Page 246

FST 200-LDR

5. Programming in ladder diagram

Decremental counters In decremental counters, the counter preset is the start value of the counter. For this reason, the counter preset must by loaded into the counter word. To do this, a second box with the assignment has to be entered parallel to the timer box. Insert a parallel coil and then select the function assignment in the Box definition window. Then enter the operand for the counter preset and the counter word (also refer to Section 5.4.1). The following diagram shows an example for initializing and decrementing a decremental counter.

Rung 1: First, counter C2 is activated by the counter box (C2=1) and its counter preset is set to 50. The assignment box loads this value (5) into the counter word. Rung 2: If the counter is activated, each rising edge at I0.1 decrements the counter by 1. When the counter word reaches 0, the counter is deactivated. The counter status is then 0 and a signal at input I0.1 does not affect the counter.

5-68

9610a

Page 247

FST 200-LDR

5. Programming in ladder diagram

5.4.4 Multibit operations in the executive part If you select the function Multibit operation from the Box definition window, the following selection will appear (refer to Fig. 5.22). As the diagram shows, there are multibit operands with two operations and with three operands.

Multi-bit operation with 2 operands

Multi bit operation with 3 operands

Fig. 5.22: Multibit operations When you activate the desired multibit operation, the appropriate box is inserted into the executive part.

9610a

5-69

Page 248

FST 200-LDR

5. Programming in ladder diagram

5.4.5 Multibit operations with two operands In the case of multibit operations with 2 operands, the operation is carried out and the result is stored in the second operand. The same operand can be specified as the first and second operand. Activate the function Enter operand. An input field is displayed in the box allowing you to enter the first operand. Press the Enter key to complete the entry. A second input field is then displayed. Enter the second operand into which the result of the operation is to be stored. Press the Enter key to complete the entry. This completes definition of the multibit operation. The following diagram shows an example for a multibit operation with two operands.

The box in the executive part of the rung shows the operation SHR (Shift right). A rising edge at input I0.2 causes the value of operand IW1 to be shifted one bit to the right and stored in operand CP1.

5-70

9610a

Page 249

FST 200-LDR

5. Programming in ladder diagram

5.4.6 Multibit operations with three operands In the case of multibit operations with three operands, the operation is carried out on the first two operands. The result of this operation is stored in the third operand. The same operand can be specified as the first, second and third operand. Activate the function Enter operand. An input field is displayed above the operation symbol. Enter the operand and conclude by pressing the Enter key. An input field appears to the right of the operation symbol. Enter the second operand. Press the Enter key to conclude. An input field for the third operand is then displayed. Enter the third operand in which the result of the operation is to be stored. Press the Enter key to conclude the operand entry for multibit operation. The following diagram shows an example of a multibit operation with three operands.

The addition operation ("+") is shown. Operands CP0 and 50 are added. The result is stored to the third operand CP1.

9610a

5-71

Page 250

FST 200-LDR

5. Programming in ladder diagram

5.4.7 Arithmetic/logic The function Arithmetic/logic is a multibit operation (refer to Section 5.4.4). In contrast to the function multibit operations, the arithmetic and logic functions allow: • logical operations with more than three operands to interconnect • various operations within an arithmetic/logic box whereby arithmetic and logic functions can also be combined. In contrast to the function multibit operation, here operations are not entered via the menu system. The operations and operands are entered manually in a window. A maximum of 16 lines are provided for entries. Activate the function Arithmetic/logic in the Box definition window (see Section 5.4). This opens the window in which you enter the multibit operations (refer to Fig. 5.23).

5-72

9610a