The text of a manual · part 48 of 59
Mini-PLC-2/02, -2/16, -2/17 Processor (cat. no. 1772-LZ, LZP, LX, LXP, LW, LWP) User Manual: 25 - Programming Techniques
Pages 391 to 399 of 490, from Mini-PLC-2/02, -2/16, -2/17 Processor (cat. no. 1772-LZ, LZP, LX, LXP, LW, LWP) User Manual
The original document is the PDF (2.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 1772-LX / LXP
Page 391
Chapter
25
Programming Techniques
Chapter Objectives
This chapter describes several programming techniques: one-shot programming re-start cascading timers temperature conversions program control
One-Shot Programming
The one-shot programming technique sets a bit for one program scan only. There are two types of one-shots: leading edge trailing edge Leading Edge One Shot A leading edge one-shot sets a bit for one scan when its input condition has made a false-to-true transition. The false-to-true transition represents the leading edge of the input pulse (Figure 25.1). Figure 25.1 Leading Edge One Shot 112
011
04 253
14
00 112
253 00 011 L 14 011 U 14
04 253
010
00
00
25-1
Page 392
Chapter 25 Programming Technique
When bit 112/04 makes a false-to-true transition, the one-shot bit (bit 253/00) is set on for one scan. The length of time bit 112/04 remains on and does not affect the one-shot bit due to the next two rungs. Bit 011/14 is latched when bit 112/04 is set or bit 011/14 is unlatched when 112/04 is reset. Bit 010/00 is then energized because the one-shot bit (bit 253/00) is set for that scan. During the next scan, either set of conditions prevents bit 253/00 from being set. The one-shot bit is set for another scan only when bit 112/04 makes a true-to-false and then a false-to-true transition. Trailing Edge One Shot A trailing edge one-shot sets a bit for one scan when its input condition has made a true-to-false transition. The true-to-false transition represents the trailing edge of the input pulse. Programming for a trailing edge one-shot is shown in Figure 25.2. Figure 25.2 Trailing Edge One Shot 112 04 112
011
011 L 14 253
00
00 011 U 14
253
010
00
00
04 253
14
When bit 112/04 is set, bit 011/14 is latched. As soon as bit 112/04 makes a true-to-false transition, the one-shot bit (bit 253/00) is set and bit 011/14 is unlatched. Bit 253/00 remains on for only one scan and energizes bit 010/00. The one-shot bit is set for another scan only when the input bit 112/04 makes a false-to-true transition then a true-to-false transition.
25-2
Page 393
Chapter 25 Programming Technique
Restart
You may get into a situation that transfers the contents of the EEPROM into CMOS RAM memory. The data values (timers, counters and storage bits/words) that were present when the EEPROM was burned will also be transferred along with the ladder diagram. You can use either one of two methods to inhibit operation: MCR method - the processor is disabled for one scan before I/O update (Figure 25.3). Figure 25.3 Automatic Restart Using an MCR Instruction 027 MCR 01 USER PROGRAM
MCR 027 U OFF 01
JMP method - the program is jumped over once before I/O update (Figure 25.4). Figure 25.4 Automatic Restart Using JMP Instruction 06 JMP
027 01 USER PROGRAM
06 LBL
027 U OFF 01
25-3
Page 394
Chapter 25 Programming Technique
The switch assembly on the I/O chassis determines how and when EEPROM to CMOS RAM transfer occurs. A transfer takes place if any change of CMOS RAM memory content occurs while the battery was being changed. If a transfer occurs (memory was altered), the data table contains the values programmed into the EEPROM. If transfer did not occur, memory did not change. The data table contains the values that existed at the time system power was removed.
Cascading Timers
Cascading is a programming technique that extends the ranges of timer and/or counter instructions beyond the maximum values that may be accumulated. A 24-hour clock program (Figure 25.5) is an example of cascading timers. Again, we emphasize not to enter these instructions using your online production equipment. Figure 25.5 24-Hour Clock 030
Rung 1
15 030
Rung 2
15 031
Rung 3
15 031
Rung 4
15 032 15
Rung 5
030 TON 1.0 PR 060 AC 005 031 CTU PR 060 AC 000 032 CTU PR 060 AC 000 032 CTR PR 060 AC 000 032 CTR PR 024 AC 000
ATTENTION: Do not use the clock program as a real time clock device. Failure to observe this caution may result in inaccurate program timing.
25-4
Page 395
Chapter 25 Programming Technique
Here is an explanation of each rung:
Temperature Conversions
Rung 1:
Free running timer. The timer done bit (030/15) is set for every 60 seconds or 1 minute intervals.
Rung 2:
When AC = PR (accumulated value equals preset value) of the timer, counter 031 increments. This rung counts the minutes in an hour.
Rung 3:
When AC=PR of counter 031, counter 032 increments. This rung counts the hours in a day.
Rung 4:
When AC=PR of counter 031, 031/15 resets counter 031’s accumulated value.
Rung 5:
When AC = PR of counter 032, 032/15 resets counter 032’s accumulated value.
Do not use the following examples to program online production equipment. These examples are for demonstration purposes only. Application One (oC to oF) This application illustrates the conversion of temperature from degrees Celsius to degrees Fahrenheit (Figure 25.6).
25-5
Page 396
Chapter 25 Programming Technique
Figure 25.6 Converting Temperature Values 200 201 G G 100 009 203 204 G G 900 005 205 207 G G 180 032 210 211 G G 212 190 033 15 033 17
202 203 X X 000 900 205 206 : : 180.000 210 + 212 033 TON 1.0 PR 003 AC 000 011 15 034 CTU PR 999 AC 000
210 220 G = 212 212
011 L 16
110
011 U 16
14
Suppose that you connected a thermocouple to an input module that measures Celsius temperature. A block transfer read transfers the temperature into the processor’s data table. For your ease, you would like to convert the recorded Celsius temperature in the data table to Fahrenheit values for display. This temperature must maintain certain range values for your application. You would like to: monitor the temperature from 87 to 100oC count the times the value falls below 190oF count the times the values stay at 212oF Formula: oF = (9/5) x o(C) + 32 In this example, the value read into the data table at address 200 is 100oC .
25-6
Page 397
Chapter 25 Programming Technique
Here is an explanation of each rung: Rung 1:
The Get instruction at address 201 multiplies the value of 100oC by 9 and stores 900 at address 203.
Rung 2:
The Get instruction at address 204 divides 5 into 900 and stores the quotient, 180, in address 205.
Rung 3:
The Get instruction at address 207 adds 32 to the value 180 which is located at get addresses 205. The sum of 212 is stored at address 210. Thus 100oC = 212oF.
Rung 4:
If the displayed temperature is less than 190oF, the timer initiates timing for three seconds.
Rung 5:
If three seconds have elapsed, an output at address 011/15 will energize a heating device which will bring the temperature back into the desired range.
Rung 6:
Counter 034 counts the number of times the value falls below 190oF. Therefore, when rung 4 is true the counter increments.
Rung 7:
When the temperature equals 212oF latching 011/16 enables an alarm.
Rung 8:
To shut the alarm off, unlatch 011/16. To do this, an operator would press a pushbutton connected to address 011/16.
Application Two (oC to oF Every Five Seconds) This application is similar to application one, but we are only recording the converted temperature reading every five seconds (Figure 25.7).
25-7
Page 398
Chapter 25 Programming Technique
Figure 25.7 Recording Temperature Values Every 5 Seconds 030
030 TON 1.0 PR 005 AC 000 02 JSR
15 030 15 SUBROUTINE AREA 06 200 201 LBL G G 100 009 203 204 G G 900 005 205 207 G G 180 032
202 203 X X 000 900 205 206 : : 180.000 210 + 212 RET
Here is an explanation of each rung: Rung 1:
When rung 1 is true, the timer (this is an example of a free running timer) starts.
Rung 2:
The JSR instruction jumps to the subroutine area label instruction when the timer’s accumulated value reaches 5 seconds.
Rungs 3-5: Converts Celsius temperature to Fahrenheit temperature exactly as in application one. Rung 6:
The Return instruction signals the processor to return to the main program area. ATTENTION: You should make allowances for conditions which could be created by the use of the Jump To Subroutine instruction. The processor does not scan the subroutine program unless initiated by a Jump To Subroutine in the main program. Timers and counters within these rungs cease to function. You should reprogram critical rungs in the main program area.
25-8
Page 399
Chapter 25 Programming Technique
Program Control
This application illustrates the program control instructions, master control reset (MCR) and zone control last state (ZCL) (Figure 25.8). Figure 25.8 Program Control 110
MCR
17 110
011 15
16 Master Control Reset 110
MCR
ZCL
17 110
011
16
15 ZCL Zone Control Last State
Before you program these two instructions, you must think about how you would want outputs to react when you change the process or operation. Using the MCR instruction, rung logic shows: If bit 110/17 is false, then bit 011/15 is energized if 110/16 is set. This is normal operation. If bit 110/17 is true, then bit 011/15 is reset regardless of the state of 110/16. All outputs within an MCR zone are reset when the zone is disabled (start fence is false). Using the ZCL instruction, rung logic shows: If bit 110/17 is false, then bit 011/15 is energized if 110/16 is set. This is normal operation. If address 110/17 is true, then bit 011/15 is left in its last state regardless of the state of 110/16. All outputs within a ZCL zone are left in their last state when the zone is disabled (start fence is false).
25-9