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

The text of a manual · part 7 of 14

Mini-PLC-2 Programmable Controller Programming and Operations Manual, pages 61 to 70

Pages 61 to 70 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 61 read from a scan by OCR; it may hold reading errors

Page 8-1

Chapter 8 WRITING THE USER PROGRAM

8.0 GENERAL

The basic tools for writing the User Program include the programming instructions and an understanding of Processor operation as de- scribed in Section 1.4, Hardware/Program interface. Although approaches to and meth- ods of writing programs that control machine operation vary, there are some guidelines that should be followed.

8.1 DEVELOPING THE PROGRAM

The first step in developing the User Program is to establish an operating sequence for input and output devices. The sequence must be evaluated to determine what the devices must do, what the conditions must be and the order in which they must operate.

After evaluating the operating sequence, the action of the different devices should be described in proper sequence with proper conditions for energizing each output device. This description is then used to develop the ladder diagram program. If a process diagram exists, it can be used as an aid in developinga ladder diagram program.

8.2 SAMPLE PROGRAM

The way a ladder diagram program is de- veloped is best described by a simple example.

The application is one of separating good parts from bad parts. Figure 8-1 shows a part moving along a conveyor belt. Each part will trip aseries of limit switches and will be sorted according to its size. The desired part size is 1.0" +0.1".

If a part trips 2LS but not 3LS, the part is greater than or equal to 0.9” and less than or equal to 1.1”. Because it is a good part, a storage bit (3SB) is latched ON. When the part trips 4LS, SOL1 is energized which moves the swingarm actuator, directing the part onto the good part conveyor.

If the part trips both or neither 2LS and 3LS, the part is too large or too small. When either condition occurs, a storage bit (4SB), 4CR is latched ON. Although the part will trip 4LS, it will continue along and trip 5LS, which energizes SOL2. The swingarm actuator will direct the part into the bad part bin. Each time a part enters the bad part bin, a counter is incre-

MOVEMENT OF PART

1LS 2Ls 3LS 4Ls as I SOL 1 SOL 2 PART | ' 7 NN CTR SWINGARM SWINGARM ACTUATOR ACTUATOR 0.9" < PART HEIGHT < 1.1” GOOD PART BAD PART 2LS SET AT 0.9 CONVEYOR BIN 3 LS SET AT 1.1"

SOL3

FIGURE 8-1, Conveyor Belt Example

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

Page 8-2 mented. When the bin is full (count complete), SOL3 is energized, which opens the bottom of the bin long enough to empty it. The counter will then reset automatically. Each time a new part enters the conveyor belt, 1LS is tripped which unlatches the storage bits and begins a new cycle.

The conveyor motor can be started or stopped with pushbutton START or STOP switches. Motor starter, MS1, controls the conveyor motor. A watchdog timer is used to monitor the folow of parts. If parts should become jammed causing a delay between 1LS and 4LS, the timer will time-out and turn OFF the conveyor motor. Another watchdog timer de- tects if a part becomes jammed beneath 4LS or 5LS. A conveyor RUN indicator and a parts JAM indicator allow remote observation of the conveyor operation. Additional documenta- tion (not shown) would include a Power Distri-bution schematic showing a hardwired master control relay and emergency stop switches.

The logic can be written as a PC ladder diagram program (Figure 8-2). Data Table addresses are assigned to the hardwired de- vices. (Table 8-1). The ladder diagram should be developed by analyzing the logic required to operate the machine. A rung by rung description of the logic follows.

Rung 1, This rung provides 3-wire control of the conveyor motor with jam detection for automatic shut down.

Rung 2, The auxiliary contact of the motor starter is monitored to provide a conveyor RUN indication.

Rung 3, 4, 5, 6, The part trips the first limit switch and unlatches storage bits 1 - 4 to begin anew cycle.

Rungs 7, The first limit switch enables a Retentive Timer which is latched by the timer Enable bit. A jam condition is detected if the timer times out.

Rung 8, Limit switch 4 (or the START pushbutton) resets the timer. If reset priorto5 seconds, no jam has occurred between 1LS and 4LS. Ajam beneath 4LS orto the right of it is not detected by this rung.

Rung 9, A part passing 2LS latches SB1 if the height = 0.9 inch. SB1 remains unlatched if the height < 0.9 inch.

Rung 10, A part passing 3LS latches SB2 if the height > 1.1 inch. SB2 remains unlatched if the height < 1.1 inch.

Rung 11, A part within tolerance latches SB3.

Rung 12, A part out of tolerance latches SB4.

Rung 13, A good part at 4LS actuates SOL1 with swingarm actuator to direct the part to the good part conveyor.

Rung 14, A bad part at 5LS actuates SOL2 with swingarm actuator to direct the part to the bad part bin.

Rung 15, SOL2 increments the Up-counter, one count for each bad part.

TABLE 8-1, Data Table Addresses for Hardwired

Devices

Input Device Address STOP Pushbutton 112/00 START Pushbutton 112/01 Motor Starter Auxiliary 112/02 Limit Switch (1LS) 112/03 Limit Switch (2LS) 112/04 Limit Switch (3LS) 112/05 Limit Switch (4LS) 112/06 Limit Switch (5LS) 112/07 Output Device Motor Starter (MS1) 014/00 Conveyor RUN Indicator 014/01 Good Part Solenoid (SOL1) 014/02 Bad Part Solenoid (SOL2) 014/03 Bin Dump Solenoid (SOL3) 014/04 JAM Detect Indicator 014/05 Internal Functions Storage Bit 1 (SB1) 012/01 Storage Bit 2 (SB2) 012/02 Storage Bit 3 (SB3) 012/03 Storage Bit 4 (SB4) 012/04 Storage Bit 5 (SB5) 012/05 Retentive Timer, Watchdog 050 Timer, Bin Dump 051 Timer, Watchdog 052 Counter 060

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

Page 8-3

Rung #

10

11

STOP START Mst 1120112 050 052 014 L4 (| 1k 4

00} 01 1515 00 Ms1 STARTER 014 112) AUXILIARY th CONVEYOR 00 02 RUN STARTER INDICATOR 112 AUXILIARY 014 Hb { ) - 02 1 iLS SBI 112 012 Hb (UJ - 03 01 1LS SB2 112 012 (U) - 03 02 1LS SB3 112 012 mee (U) - | 03 03 1LS SB4 112 012 Hb (UJ - 03 04 1LS WATCHDOG 112 050 rt (RTO) - 03 01 PR 050 050 AC 000 t4 7 4LS 112 050 H | (RTR) - 06 PR 050 AC 000 START 112 Hj 01 2LS SBI 112 012 H |, {L} - 04 01 3LS SB2 112 012 Hob by 05 02 SB1 SB2 SB3 012 012 012 rH E4/ {L)- - 01 02

FIGURE 8-2, Ladder Diagram Progam

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

Page 8-4

$B1 SB2 SB4 012 «012 012 2H KY by 4L) - 01 02 04 SB1 SB2 012 012 H/-4 01 02 4LS SB3 GOOD PARTS SOL1 112 «012 014 13 4 L4 | { 06 = =§=03 02 5LS SB4 BAD PARTS SOL2 112 = 012 014 14H E44 | 4) 07 (04 03 SOL2 BAD PARTS 014 060 1 HY Fb (CTU) - 03 PR 020 AC 000 $B5 060 012 16H | 4L) - 15 05 SB5 BIN DUMP 012 051 17 WH |} (TON), 05 0.1 PR 060 AC 000 $B5 BAD PARTS 012 060 18 b (CTR) 05 PR 020 AC 000 SB5 BIN DUMP SOL3 012 014 19 4 + { J - 05 04 SB5 051 012 20 4 | (UJ - 15 05 4LS WATCH DOG 112 052 21 +4 | (TON) - 06 0.1 PR 050 5LS AC 000 112 t+ 07 JAM DETECT: INDICATOR 050 014 22 1H { 15 05 052 || 15

FIGURE 8-2, Ladder Diagram Program (cont.)

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

Page 8-5

Rung 16, When AC = PR = 20, the Count Complete bit latches SB5.

Rung 17, SB5 starts a timer to maintain a6 second bin dump.

Rung 18, SB5 resets the bad part counter.

Rung 19, SB5 actuates SOL3 to dump the bad part bin by gravity feed.

Rung 20, The Timed-out bit of timer 051, unlatches SB5 which in turn resets the timer.

Rung 21, 4LS or 5LS enables the watchdog times 052,. If 4LS or 5LS is held closed bya jam, this timer will time out.

Rung 22, Timed-out bits are monitored to provide a JAM indication to the operator.

8.3 DEVELOPING THE DATA TABLE

The factory configured Data Table shown in Section 1, Figure 1-5, should be used as a guide when developing the Data Table. Deter- mining the number of words needed and assigning addresses is a procedure that re- quires care and attention to detail.

The Data Table should be roughed-out in advance but formally developed as the User Program is being written. Each Data Table word and bit address and its function should be logged as it is assigned.

8.3.1 Data Table Documentation Forms

The Data Table documentation forms pre- sented at the end of this section can be reproduced or revised as needed. They in- clude two general types:

1) Data Table Map to describe the Data Table as a whole. Publication 5045.

2) Data Table Bit and Word Assignment Sheets to log and describe the function of assigned addresses. Publication 5046 and 5047.

An example showing how each form is used accompanies the description.

DATA TABLE MAP (128-WORD)

This form can be used to log the bit status of a word and to describe the function of groups of related words within a 128-word Data Table section.

The lower two digits of the 3-digit word addresses are pre-numbered in the left-hand column. The bit numbers, 00-17, complete the 5-digit bit address. The starting word address can be written once for the entire 64 word column.

For example, Figure 8-3 shows a completed portion of the Data Table Map. The left-hand column represents the addresses 200/00 through 277/17 because a “2” is written in the Starting word address blank at the top of the column.

STARTING WORD ADDRESS

= 00 BIT NUMBER 17 10] 07 00} DESCRIPTION e_ 00 | 01 36r TT. l], 37 4010 J /iol/iol/|/jol A Zlol/| /|/|/| AKA 062 41lola| slat siolol/| lol slololol7 (Binary) 42lol/lol/|/| slo} zlololz[olz| olzlo 43|/lol/lal/|o| Zlolgl7[o| 7lol lola 44 ¢ | 45 ( & 4el § tll FFA 063 a7 r) 4 & Cree) 50 5s1C] mr

FIGURE 8-3, Example of a Data Table Map

DATA TABLE WORD ASSIGNMENTS (64 WORD)

This form can be used to write functional descriptions of word addresses used in the Data Table for word storage, timers and counters, etc.

The form is divided into two 32-word columns. The words can be numbered con- secutively through the entire 64 words. Or, the right-hand column can be numbered 100, greater than the left-hand column to con- veniently track Accumulated and Preset values. In either case, the lowest digit of the 3-digit word address is pre-numbered, 0-7.

For example, a portion of the Data Table Word Assignment Sheet is shown in Figure 8-4. It

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

Page 8-6 illustrates timer and counter functional descriptions for Accumulated values starting at word address 030, and Preset values starting at 130,. An “03” and “13” were written into the left-hand and right-hand word address boxes, respectively.

DATA TABLE BIT ASSIGNMENTS

This form can be used to log the function of input, output and storage bits.

Similar to the Word Assignment Sheet, the Bit Assignment Sheet is divided into two 2-word columns. The words can be numbered con- secutively. Or, the right-hand column can be numbered 100, greater than the left-hand column for the convenient logging of input, output and/or storage bits having the same module group number. The bit numbers are pre-numbered, 00-17.

For example, a portion of the Data Table Bit Assignment Sheet is shown in Figure 8-5. It illustrates logging the input devices associated Module Group 2 and the storage bits of the corresponding storage word 012, (comple- ment of word 112,). Word addresses “012” and “112” have been entered into corresponding word address boxes in the left- and right-hand columns, respectively. The 3-digit word ad- dress is entered once for all 16 bits.

8.3.2 1/0 Assignment Considerations

Once the description of the application is complete, Data Table bit addresses can be assigned to the input and output devices wired to the Controller. The 5-digit bit address directly corresponds to the location of each 1/O device with respect to the Rack number (always 1), Module Group and Terminal num- ber. Bit addresses cannot be assigned arbi- trarily to |/O devices because bit addresses are hardware-related. Review Section 1.4, Hardware/Program Interface, if necessary. Analog modules and other intelligent I/O modules use word addresses rather than 5- digit bit addresses. Refer to the module Users Manual for more information on addressing and wiring.

The installer and programmer should work closely together to determine the best placement of the |/O modules within the I/O chassis. To simplify installation and troubleshooting procedures, it may be desirable to group like modules together. Also, module locations should be assigned to minimize electrical noise radiation from AC lines. It is helpful to document I/O assignments on a form such as Publication 5039 found at the end of this section.

WORD ADDR DESCRIPTION

WORD ADDR DESCRIPTION | o3 Danian cyl koma, AC

13 Maaten tome, TL

Dull hace! ™/ , dwell Line , AC

No. of Darce , AC

| Dull, 7) ltl lark, PR

0 0 ey Ae

5 ‘S| 16. af peacaed, PA . 6|Wo. f ryec? MPard, AC 6| Vo. of i Zo, PR

7

FIGURE 8-4, Example of Data Table Word Assignments

WORD BIT DESCRIPTION WORD BIT DESCRIPTION

Old _|0/0|CRL, run auto (4%) JQ |0|0| LS2 Forseand/ cverLrovel 0|1|CR2, Part preaony LoZLeA_ (oc;) O[1|PRSL Part Ae 7% 01|2|CR3, of. comal Cato.) 0|2| A462 Up-you ene, - - $___|

FIGURE 8-5, Example of Data Table Bit Assignments

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

Page 8-7

This form can be used as follows. The titles of the modules can be written in the spaces immediately below the Module Group labels. The spaces immediately to the left of the LED indicators and the screw terminations can be used to identify the I/O devices and to label the wire numbers connecting the devices to the terminals, respectively.

Recommendations for I/O wiring and module placement can be found in Publication 1772- 820, the Mini-PLC-2 Assembly and Installation Manual.

8.3.3 Timer/Counter Assignment Considerations

Timers and counters require two Data Table word addresses, one for the Accumulated value, the other for the Preset value. The instruction address is the address where the Accumulated value is stored. Timer and counter instructions can be assigned Data Table addresses beginning at word address 030, through 077,. The Preset value is located at the word address 100, greater than the Accumulated value word address. Timer and counter addresses and descriptions should be entered on Data Table Word Assignment Sheets.

If Block Transfer programming is used, the addresses of the pair of GET instructions must be entered into the timer/counter areas of the Data Table starting at word 030,. These instructions also use two Data Table word addresses, one at an address 100, greater than the other. Each Block Transfer rung will decrease by one (1) the number of available equivalent timers and/or counters from the maximum quantity of 40. For more information on Block Transfer, see Section 11.2.

8.3.4 Bit/Word Storage Considerations

Bit/word storage addresses can be located in all areas of the Data Table excluding the Input Image Table and Processor Work areas. Bit and word storage addresses should be chosen carefully to conserve memory. The following recommendations for bit and word storage should be considered:

e Bits 14-17 of atimer or counter Preset word can be used for bit storage, provided data is

NOT transferred to the Preset word by a GET/PUT transfer, or the time base of the timer is NOT .01 second.

¢ Unused Data Table words in the timer/ counter areas can be used for bit/word storage. To conserve memory, use both the Accumulated and corresponding Preset words for storage.

¢ Output Image Table words can be used for storage when the corresponding Input Image Table words are used for input modules (Block Transfer modules excluded). However, when there is a vacant module group or slot in the I/O Chassis, do not use the cor- responding I/O Image Table words for stor- age. Reserve these words for future system expansion.

e¢ Unused Input Image Table words can not be used for storage. They are cleared to zero during each I/O scan.

¢ Word 027, should not be used for storage or control of output devices. Many of the bits are used by the Processor for control functions.

The number of bit/word storage addresses will depend on User Program requirements and is sometimes difficult to estimate in advance.

8.4 Sizing the Data Table

The Data Table is factory configured to 128 words. The Data Table can be reduced in size to 48 words by reducing the number of words available for timers, counters and equivalent word storage in the Accumulated and Preset value areas. If less than 40 equivalent timers/ counters are assigned, the size of the Data Table should be reduced to allow additional memory to be used for User Program instruc- tions. Up to 80 instructions can be added to User Program, two instructions for each equivalent timer/counter not used. See Figure 8-6.

After completing the User Program and logging all addresses on Data Table Assignment Sheets, the highest address assigned will determine the size of the Data Table.

The size of the Data Table also can be com- puted. The computation is made using the

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

Page 8-8

WORD ADDRESS f 030 --.------ 030 Ol CASS 1 ZZ YSED AC WORDS 035 ~_.- ee LALLA La ZL. ACCUMULATED VALUES _ (AC) (077 -------- AREA USABLE TO EXPAND 130 | _INSTRUCTION STORAGE: q iin Whitts FROM FIRST UNUSED Y USED PR WORDS AC-PR PAIR TO END 135 -------- LLLLLL. OF TIMER/COUNTER AREA PRESET VALUES 4 < (PR) [177 --------

FIGURE 8-6, Data Table Adjusted for Additional User Program following formula: ET=T+C+1S/2 where ET = # equivalent timers/counters, T =# timers, C = # counters and IS = # storage words. Any partially assigned or unassigned storage word from the highest assigned AC- PR pair to the beginning of the timer/counter area must be considered as an assigned storage word.

The number of equivalent timers/counters is used to adjust the Data Table in Processor memory before entering the User Program. The Data Table Adjustment procedure is de- scribed in Section 9.1.

8.5 PROGRAM RECOMMENDATIONS

The program recommendations listed below for constructing aladder diagram rung should be considered:

Note: Special considerations are given for MULTIPLY and DIVIDE instructions. The rung size limitations exist because of the Industrial Terminal screen size.

e Only one Output instruction can be pro- grammed in a rung.

© Generally, program only one rung to ener- gize an output device to simplify trouble- shooting and maximize safety.

e Up to 12 Condition instructions in series can be programmed in arung; up to 11 if the output is a MULTIPLY or DIVIDE instruc- tion.

e When the desired number of series Condi- tion instructions exceeds the horizontal limit of the screen (Figure 8-7a), use a storage bit to make two rungs (Figure 8-7b).

e Up to 7 parallel branches can be pro- grammed in a rung.

8.6 CURRENT RECORD

A hard-copy printout and/or a tape recording of Data Table, User Program and messages should be made after the machine operation is working as desired. Before reproducing Pro- cessor memory content, set all Data Table values to start-up conditions. Record a total memory dump that includes the start-up Data Table values.

The Data Table Assignment Sheets, hard- copy printout and/or the tape recording consti-tute the current record of the machine operation. If subsequent changes are required, all back-up records should be kept up to date.

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

Page 8-9

EXCEEDS HORIZONTAL LIMIT

/\ cr ~\

1 2 3 4 5 6 7 8 9 0 1 12 13 OUTPUT

A. EXCEEDS 12 INPUT INSTRUCTIONS IN SERIES

1 2 3 4 5 6 7 STORAGE BIT -4 E+ FH t-ES +: + ( )} - STORAGE

Far 9 10 11 #12 13 OUTPUT oF 4+ FA FS FG FG +E ( J - B. USE OF STORAGE BIT

FIGURE 8-7, Storage Bit Example

Page 70

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