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

The text of a manual · part 6 of 14

Mini-PLC-2 Programmable Controller Programming and Operations Manual, pages 51 to 60

Pages 51 to 60 of 132

The original document is the PDF (13 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 1772-LN2 and Allen-Bradley 1772-LN3

Page 51 read from a scan by OCR; it may hold reading errors

Page 6-1

Section 6 ARITHMETIC INSTRUCTIONS

6.0 GENERAL

The Mini-PLC-2 Processor can be programmed to perform arithmetic operations with two 3- digit BCD values using a set of Arithmetic instructions. These output instructions are:

e ADD -(+)- e SUBTRACT -(-)- e MULTIPLY -(x)-(x)- (1772-LN3 Processor) e DIVIDE -(:)-(:)- (1772-LN3 Processor)

The two 3-digit BCD values to be computed are stored in two GET instruction words. The GET instructions, programmed in the condi- tion area of the ladder diagram rung, should be followed by the Arithmetic instruction. Other condition instructions, if used, should be programmed before the GET instructions.

The Arithmetic instructions are programmed in the output position of the ladder diagram rung. They are assigned either one or two Data Table words to store the computed result, depending on the arithmetic operation performed. The ADD and SUBTRACT instruc- tions use one Data Table word to store the result. The MULTIPLY and DIVIDE use two Data Table words to store the result.

The computed result is stored in BCD format in the lower 12 bits of the Arithmetic instruction word (Figure 6-1). Two of the remaining bits (bits 14 and 16) are used to indicate overflow and underflow conditions.

6.1 ADD INSTRUCTION

The ADD instruction (+) tells the Processor to add the two values stored in the GET words. The sum is then stored at the ADD instruction word address. When the sum exceeds 999, the overflow bit (bit 14) in the ADD instruction word is set ON (Figure 6-2). In the RUN or TEST mode, the overflow condition is dis- played on the Industrial Terminal screen as a “1” preceding the sum.

NOTE: If an overflowed value (4 digits) is used for subsequent comparisons or other arith- metic operations, inaccurate results could occur. The Processor performs arithmetic and data manipulation operations with 3-digit BCD values, only.

6.2 SUBTRACT INSTRUCTION

The SUBTRACT instruction (-) tells the Pro- cessor to subtract the second GET word value from the first GET word value (Figure 6-3).

BCD VALUE

HOLDS ARITHMETIC RESULT rN

/

17 16 15 14 13 12 11 10 oN

07 06 05 04 03 02 01 00

/ A! 1 MOST i SIGNIFICANT DIGIT a

! MIDDLE ! LEAST DIGIT t SIGNIFICANT ' DIGIT

OVERFLOW BIT SET TO 1 WHEN SUM EXCEEDS 999

UNDERFLOW BIT SET TO 1 WHEN DIFFERENCE

IS NEGATIVE NUMBER

FIGURE 6-1, Arithmetic Instruction Word

Page 52 read from a scan by OCR; it may hold reading errors

Page 6-2

MUST BE TRUE TO ALLOW ARITHMETIC OPERATION

RESULT STORED AT THIS ADDRESS

\

111 030 031 r - Gi - Gi 11 520 514

032 + + 1034

OVERFLOW WILL CAUSE A 1TO BE DISPLAYED BUT NOT USED

FIGURE 6-2, ADD Instruction

MUST BE TRUE TO ALLOW ARITHMETIC OPERATION

RESULT STORED AT THIS WORD ADDRESS

111 040 041 - - GE GI 14 100 109

042 { - 009

UNDERFLOW WILL CAUSE NEGATIVE SIGN TO BE DISPLAYED BUT NOT USED

FIGURE 6-3, SUBTRACT Instruction

The difference is then stored at the Data Table word addressed by the SUBTRACT instruction.

If the difference is a negative number, the underflow bit of the SUBTRACT word (bit 16) is set ON. In the RUN or TEST mode, the negative sign will appear on the Industrial Terminal screen preceding the difference.

NOTE: If a negative BCD value is used for subsequent operations, inaccurate results could occur. The Processor only compares, transfers and computes the absolute BCD value.

6.3 MULTIPLY INSTRUCTION (1772-LN3 Processor Module)

The MULTIPLY (X) instruction tells the Pro- cessor to multiply the two BCD values stored at the GET instruction words. The result is then stored in two Data Table words addressed by the MULTIPLY instruction (Figure 6-4).

For ease of programming, two consecutive Data Table words should be chosen to store the product. If the product is less than 6 digits, leading zeros will appear in the product.

6.4 DIVIDE INSTRUCTION (1772-LN3 Processor Module)

The DIVIDE instruction (:) tells the Processor to divide the first GET instruction value by the second GET instruction value. The result is stored in two Data Table words addressed by the DIVIDE instruction (Figure 6-5). Usually two consecutive Data Table words are chosen to store the quotient for ease of programming.

The quotient is rounded off and expressed as a decimal number. The decimal point is auto-

Page 53 read from a scan by OCR; it may hold reading errors

Page 6-3

MUST BE TRUE TO ALLOW ARITHMETIC OPERATION

111 130 131 t - Gr - G! "12 123 061

051 052 { X } - {X 007 503

FIGURE 6-4, MULTIPLY Instruction

MUST BE TRUE TO ALLOW ARITHMETIC OPERATION

111140141 r - GE GI 13 050 025

066 067 {:}-~: 002 « 000

FIGURE 6-5, DIVIDE Instruction matically inserted between the two DIVIDE instruction values by the Industrial Terminal. Leading and trailing zeros in the quotient are also entered automatically by the Industrial Terminal.

Although division by 0 is undefined mathe- matically, the division of a number including zero by 0 will give the result of 999.999. (This differs from the PLC-2/20 and PLC-2/30 where 0+0 = 1.000.)

6.5 PROGRAMMING ARITHMETIC INSTRUCTIONS

Arithmetic instructions are programmed from the Industrial Terminal keyboard with the

Mini-PLC-2 Processor in the PROGRAM mode. When entered, these instructions will be intensified and blinking. The default word address above the instuction will have a reverse-video cursor positioned at the first digit. The instruction will continue to blink until the word address is entered.

Refer to Table 6-1 for a summarized descrip- tion of these instructions.

Page 54 read from a scan by OCR; it may hold reading errors

Page 6-4

TABLE 6-1, Arithmetic Instructions

Note: Arithmetic instructions operate on BCD values in the Data Table. The word address XXX is displayed above the instruction; the BCD value YYY which is the result of the arithmetic operation is displayed beneath it. The BCD value is stored in the lower 12 bits of the word address and can be any value from 000 to 999. KEYTOP syMBOL|, 'NSTRUCTION DISPLAY DESCRIPTION -(+)- ADD XXX The ADD instruction is an output -(+)- instruction. It is always preceded by two YYY GET instructions which store the BCD values to be added. When the sum exceeds 999, bit 14 is set to 1, and a 1 is displayed in front of the result YYY. -(-)- SUBTRACT XXX The SUBTRACT instruction is an output -(-)- instruction. It is always preceded by two YYY GET instructions. The value in the second GET address is subtracted from the value in the first. When the difference is negative, bit 16 is set to 1, and a minus sign is displayed in front of the result YYY. -(X)- MULTIPLY XXX XXX The MULTIPLY instruction is an output (1772-LN3 -(X) - (X)- instruction. It is always preceded by two Processor) YYY YYY GET instructions which store the values to be multiplied. Two word addresses are required to store the 6 digit product. -(+)- DIVIDE XXX XXX The DIVIDE instruction is an output (1772-LN3 -() - (:)- instruction. It is always preceded by two Processor) YYY.YYY GET instructions. The value of the first is divided by the value of the second. Two word addresses are required to store the 6 digit quotient. Its decimal point is placed automatically by the Industrial Terminal.

Page 55 read from a scan by OCR; it may hold reading errors

Page 7-1

Section 7 OUTPUT OVERRIDE AND I/O UPDATE INSTRUCTIONS

7.0 GENERAL

Programming instructions may be needed for certain applications requiring output over- rides or I/O updates. They are:

e MASTER CONTROL RESEST Instruction e ZONE CONTROLLAST STATE Instruction e IMMEDIATE INPUT Instruction e IMMEDIATE OUTPUT Instruction

7.1 OUTPUT OVERRIDE INSTRUCTIONS

The two output instructions that can be used to override a group of outputs are:

¢ MASTER CONTROL RESET -(MCR)- e ZONE CONTROL LAST STATE -(ZCL)-

These instructions are similar to a hardwired Master Control Relay in that they can affect a group of outputs in the User Program. The MCR and ZCL instructions, however, are NOT a substitute for a hard-wired relay, which provides emergency stop capabilities for all 1/O devices.

WARNING: A PC system should not be operated without a hard-wired Master Con- trol Relay and Emergency Stop switches to provide emergency I/O power shutdown. Emergency Stop switches can be moni- tored but should not be controlled by the User Program. These devices should be wired as described in the Mini-PLC-2 As- sembly and Installation Manual (Publica- tion 1772-820). The purpose of these devices is to guard against damage to equipment and/or injury to personnel.

The MCR and ZCL instructions control the zoned outputs differently:

@ MCR, When FALSE, all nonretentive out- puts within the MCR zone are de-energized or turned OFF.

e ZCL - When FALSE, the outputs within the ZCL zone are held in their last state: either ON or OFF.

To override a group of output devices, two MCR or ZCL instructions are required: one to begin the zone and one to end the zone (Figure 7-1). The Start Fence begins the zone and is always programmed with a set of input conditions. The End Fence ends the zone and must be programmed unconditionally.

When the MCR or ZCL Start Fence is TRUE, all outputs within the zone are controlled by their respective rung conditions. When the MCR or ZCL Start Fence is FALSE, the out- puts within the zone are controlled by the MCR or ZCL Start Fence as stated above.

WARNING: MCR or ZCL zones must not be overlapped or nested. Each zone must be separate and complete. Common outputs must not be shared between MCR zones. Overlapping MCR or ZCL zones could re- sult in unpredictable machine operation with possible damage to equipment and/or injury to personnel.

Sharing common outputs in more than one ZCL zone is permitted, provided that only one ZCL zone is enabled at a time. Common outputs can be examined in more than one MCR or ZCL zone.

7.2 1/0 UPDATE INSTRUCTIONS

Two instructions used to accelerate the up- date of I/O data during the execution of the User Program are: , e IMMEDIATE INPUT -[I]- e IMMEDIATE OUTPUT -(IOT)-

These instructions are used to transfer critical 1/O data ahead of the normal scan sequence. The status of inputs is made immediately available to User Program and output deci- sions are accelerated to the output devices.

The IMMEDIATE I/O instructions are usually used where I/O modules interface with I/O devices that operate in a shorter period than the Processor scan time. These may include TTL-logic or fast response input or output devices.

Page 56 read from a scan by OCR; it may hold reading errors

Page 7-2 rtoF4 FS | {ZCL}4 START FENCE rt! ( aN 4 T, { ct! WHEN ZCL ZONE IS A | Df > FALSE ALC OUTEUTS L4{ fiy | 4 4 STATE. ae t4 oF (| 7 r+ F4 Fd | (MCR}4 START FENCE oe { RS | T { } 4 nu WHEN MCR ZONE !S Py py (jo DE-ENERGIZED 4 id |, a“ CR) END TENGE

FIGURE 7-1, MCR and ZCL Zone Programming

Most electromechanical devices have a re- sponse time longer than the Processor scan time. Thus, data to and from these devices need not be updated ahead of the normal I/O scan.

7.2.1 Scan Sequence

The Mini-PLC-2 Processor scan sequence can be divided into 2 parts (Figure 7-2):

e 1/0 Scan ¢ Program Scan

Upon power up, the Processor begins the scan sequence with the I/O scan. During the

I/O scan, data from input modules is trans- ferred to the Input Image Table. Datafrom the Ouput Image Table is transferred to the out- put modules.

After completing the I/O scan, the Processor begins the program scan. Here, all User Pro- gram instructions are generally scanned and executed in the order they were entered.

The I/O scan and program scan are performed one after the other. The time required to complete both scans is typically 23 msec for 900 instructions.

Page 57 read from a scan by OCR; it may hold reading errors

Page 7-3

1/0 SCAN PERFORMS 1/0 UPDATING TYPICALLY END OF 1 MSEC./128 1/0 PROGRAM START OF INSTRUCTION. \ / PROGRAM \ / INSTRUCTION

\

PROGRAM SCAN, INSTRUCTIONS SCANNED SEQUENCTIALLY, AS ENTERED (TYPICALLY 22 MSEC. FOR 900 INSTRUCTIONS)

FIGURE 7-2, Scan Sequence

Typically 23 msec may pass before I/O datais updated in a 1K system. The purpose of IMMEDIATE 1!/O instructions is to interrupt the program scan to update a word of critical input data or to transfer a word of critical data from the Output Image Table to the module in advance of the normal update sequence.

7.2.2 IMMEDIATE INPUT Instruction

The IMMEDIATE INPUT instruction [I] up- dates one word of the Input Image Table data in advance of the normal scan sequence (Figure 7-3). The Image Table word repre- sents one Module Group in the I/O Chassis.

The IMMEDIATE INPUT instruction is pro- grammed in the condition area of the ladder- diagram rung. The IMMEDIATE INPUT instruc- tion can be considered as always TRUE; it is always executed whether or not other rung conditions allow logic continuity.

1/0 SCAN x

PROGRAM SCAN

IMMEDIATE INPUT INSTRUCTION

L~ INTERRUPTS PROGRAM SCAN

EXAMINE BITS IN WORD 112 2 HERE IN PROGRAM RETURNS TO PROGRAM SCAN v He BE word 112 - »| [TTT TT TITITITT ETE I 16 BITS FROMONE, </\ff < MODULE GROUP : WRITTEN INTO. | BAIL SO CUP. INPUT IMAGE ‘NDOT TABLE WORD ( )

FIGURE 7-3, IMMEDIATE INPUT Instruction

Page 58 read from a scan by OCR; it may hold reading errors

Page 7-4

Program the IMMEDIATE INPUT instruction only when necessary. The need depends on both the response time of the input devices and modules being used, and on the position in the program of the rungs examining these inputs. It is best to program the IMMEDIATE INPUT instruction just before input instruc- tions addressed to the applicable Module Group are examined.

7.2.3 IMMEDIATE OUTPUT Instruction

The IMMEDIATE OUTPUT instruction (IOT) updates one Module Group with data from one Output Image Table word ahead of the normal scan sequence (Figure 7-4).

The IMMEDIATE OUTPUT instruction is pro- grammed as an output instruction in the ladcer-diagram rung. This instruction is executed when rung conditions allow logic con- tinuity. Unconditional programming can also be used to cause the Module Group to be updated during each program scan.

Program the IMMEDIATE OUTPUT instruction only when necessary. This depends on the response time of output modules and devices, and on the position of the rungs addressing the applicable Module Group.

The IMMEDIATE OUTPUT instruction should be programmed just after the rungs that con-

1/0 SCAN

PROGRAM SCAN a

CONTROL BITS OF WORD 014 HERE IN PROGRAM

INTERRUPTS PRO

IMMEDIATE OUTPUT INSTRUCTION

GRAM SCAN

TT TTT TT tT Ty

> Y RETURNS TO 7, PROGRAM SCAN GY

\

WORD 014

7

WRITES ALL 16 BITS

FROM ONE OUTPUT IMAGE TABLE WORD TO ONE MODULE GROUP

MODULE GROUP (OUTPUT)

FIGURE 7-4, IMMEDIATE OUTPUT Instruction

Page 59 read from a scan by OCR; it may hold reading errors

Page 7-5 trol the bits in the addressed Output Image Table word.

In PC applications, this instruction only gives a slight advantage when entered near the end of the program scan; since the output data will soon be updated inthe l/O scan. This instruction is best applied when entered near the middle of the User Program.

7.3 PROGRAMMING OUTPUT OVERRIDE AND I/O UPDATE INSTRUCTIONS

Instructions are programmed from the Indus- trial Terminal keyboard with the Processor in

PROGRAM mode. When entered, they will be displayed as intensified and blinking with the reverse-video cursor positioned on the first digit of the default word address. The instruction will continue to blink until the word address is entered.

Refer to Table 7-1 for a summarized descrip- tion of these instructions.

Page 60 read from a scan by OCR; it may hold reading errors

Page 7-6

TABLE 7-1, Output Override and I/O Update Instructions

Note: The MCR and ZCL boundary instructions have no word address.

The word addresses XXX of the IMMEDIATE INPUT and OUTPUT instructions are limited to the Input and Output Image Tables respectively.

KEYTOP SYMBOL

INSTRUCTION NAME

DISPLAY

DESCRIPTION

-(MCR)-

MASTER CONTROL RESET

-(MCR)-

Two MCR instructions are required to control a group of outputs. The first MCR instruction is programmed with input conditions to begin the zone. The second MCR instruction is programmed unconditionally to end the zone.

When the first MCR rung is FALSE, all outputs within the zone, except those forced ON, latched ON, or any other retentive output will be de-energized.

Do not overlap MCR zones, or nest with ZCL zones. Do not share common outputs between MCR zones.

-(ZCL)-

ZONE CONTROL LAST STATE

-(ZCL)-

Two ZCL instructions are required to control a group of outputs. The first ZCL instruction is programmed with input conditions to begin the zone. The second ZCL instruction is programmed unconditionally to end the zone.

When the first ZCL rung is FALSE, outputs in the zone will remain in their last state.

Do not overlap ZCL zones, or nest with MCR zones.

IMMEDIATE INPUT

XXX -[l]-

Processor interrupts program scan to update Input |lmage Table with data from the corresponding module group. It is updated before the normal I/O scan and executed each program scan.

-(lOT)-

IMMEDIATE OUTPUT

XXX -(lOT)-

When rung is TRUE, Processor interrupts program scan to update module group with data from corresponding Output Image Table word address. It is updated before the normal I/O scan and executed each program scan when the rung is TRUE. Can be programmed unconditionally.