The text of a manual · part 25 of 59
Mini-PLC-2/02, 2/16, 2/17 Processor (cat. no. 1772-LZ, LZP, LX, LXP, LW, LWP) User Manual: 15 - EAF Log, Trig, and FIFO Instructions, pages 194 to 202
Pages 194 to 202 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.4 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-LW /LWD, Allen-Bradley 1772-LWP, Allen-Bradley 1772-LX / LXP and Allen-Bradley 1772-LZP
Page 194
Chapter
15
EAF Logarithmic, Trigonometric, and FIFO Instructions
Chapter Objectives
This chapter describes the Logarithmic, Trigonometric, and FIFO Load, and FIFO Unload EAF instructions. Table 15.A EAF Function Numbers If you want to perform an operation of this type
Use this function number
The Mini-PLC-2/02, Mini-PLC-2/16 and Mini-PLC-2/17 can perform these functions FIFO Load FIFO Unload Log10 Sin x Cos x
(28) (29) (30) (35) (36)
The Mini-PLC-2/17 can perform these additional functions. Loge
One Operand EAFs
(31)
When a processor executes an EAF, it uses the data table format shown in Figure 15.1. The Operand represents the number you manipulate.
15-1
Page 195
Chapter 15 EAF Logarithmic, Trigonometric and FIFO Instructions
Figure 15.1 EAF One Operand Word and Digit Format in the Data Table 17
16
15
14 13
S Operand
Result
X
S
0
10 7
43
0 Data Address b
Digit 1 MSD
Digit 2
Digit 3
Digit 4
Digit 5
Digit 6 d
Digit 7
Digit 8
Digit 9 g
Digit 10
Digit 11
Digit 12 LSD k
Result Address r
O/U r+1 r+2 r+3 10363-I
The Operand and the Result words have the format xxx xxx . xxx xxx. You can enter them from the keyboard of your 1770-T3 terminal or through ladder diagram instructions. If you select a data address (inside the EAF) other than 010 for the Operand, you can locate the data anywhere in your data table. However, you must select four consecutive data table addresses (Figure 15.2). If you choose to enter the default address (010) as the Data Address inside the EAF instruction, the processor seeks its data from the Get instructions in the Operand rung. Address 010 will not be altered or used by this instruction. The Get instruction must be located in the rung immediately before the EAF instruction. You may select up to four data table addresses (Figure 15.2). You can locate the Result word anywhere in your program. However, you must select four consecutive addresses for the result. If you select an address of 060 for the Result, the EAF automatically reserves the next three higher addresses. To enter the number ABC use only one Get or one data table word. Important: If there is only one Get, the value is placed immediately to the left of the decimal point. ––––[G]––– +/– ABC
15-2 xxx ABC . xxx xxx
Page 196
Chapter 15 EAF Logarithmic, Trigonometric and FIFO Instructions
To enter the number ABC DEF use two Gets or two data table words. ––––[G]–––[G]––– +/– ABC DEF
ABC DEF . xxx xxx
To enter the number ABC DEF . GHI use three Gets or three data table words. ––––[G]–––[G]–––[G]––– +/– ABC DEF GHI
ABC DEF . GHI xxx
To enter the number ABC DEF . GHI JKL use four Gets or four data table words. ––––[G]–––[G]–––[G]–––[G]––– ABC DEF . GHI JKL +/– ABC DEF GHI JKL The numbers have a fixed decimal point that is implied but not displayed. The Result word can be placed in any legal location in the data table. However, you must select four consecutive address locations. The Result word format is similar to the Operand format except that there are three status bits. Bits 14-17 of the result word are reserved for status bits: This Bit: 14
Stores this: overflow/underflow 1 you entered a number that is out of range 0 result is in range Log10 and Loge 1 you tried to find the log of zero and the result indicates zero; or you tried to fin the log of a negative number and the result indicates 999 999 . 999 999 0 result is in range
15 zero indicator 1 zero result 0 non-zero result
16 sign bit 1 negative (-) 0 positive (+)
17 not used
15-3
Page 197
Chapter 15 EAF Logarithmic, Trigonometric and FIFO Instructions
Data Table Format After Address Entry Be careful not to select operand (data) and result addresses so that they overlap. Figure 15.2 EAF Word Format in the Data Table After Address Entry 17
16 S
15
Operand
X
Result
S
0
14 13 10 7 43 Digit 1 Digit 2 Digit 3 MSD
0 Data Address 040
Digit 4
Digit 5
Digit 6
041
Digit 7
Digit 8
Digit 9
042
Digit 10
Digit 11
Digit 12 LSD
043 Result Address 060
O/U
061 062 063 10364-I
Entry and Display of Input and Result Values Figure 15.3 shows one method for displaying operand (data) values and the result values of an EAF, not using the default address (010) as the Data Address inside the EAF instruction. The first branch contains the Result. The second branch contains the Operand. Addresses of the Operand do not have to be consecutive (if the Data Address in the instruction is 010). Figure 15.3 EAF Operand and Result Rung 060 G 000 040 G 000
15-4
061 G 012 041 G 144
062 G 000 042 G 000
063 G 000 043 G 000
EXECUTE AUX FUNCTION FUNCTION NUMBER: 05 DATA ADDR: 040 RESULT ADDR: 060
Page 198
Chapter 15 EAF Logarithmic, Trigonometric and FIFO Instructions
Keystrokes Enter an EAF input and result rung (like Figure 15.3) by performing the following steps. 1.
Press
2.
Enter the result branch with its four Gets. Press operand with its four Gets.
3.
Enter the values for the Operand.
4.
Complete the parallel branches.
5.
Press [Shift] [EAF].
6.
Enter the appropriate function number (Table 15.A).
7.
Enter the data and result addresses.
. and enter the
ATTENTION: Do not enter data in hexadecimal. Enter all data in BCD. Failure to observe this warning could cause unwanted machine motion and may injure personnel.
Log to Base 10 or Log to Base e
The EAF log instruction is a feature of the Mini-PLC-2/17 processor only. Word formats for log10 or the loge are the same. The only difference between the two EAFs is their function number: log10 is 30 and the loge is 31. log10 xxx xxx . xxx xxx = 000 00y . yyy yyy loge xxx xxx . xxx xxx = 000 0yy . yyy yyy Enter an EAF rung like that in Figure 15.4 Figure 15.4 EAF Log to Base 10 Function, Operand and Result Rung 060 G 000 040 G 000
061 G 002 041 G 648
062 G 811 042 G 000
063 G 572 043 G 000
EXECUTE AUX FUNCTION FUNCTION NUMBER: 30 DATA ADDR: 040 RESULT ADDR: 060
15-5
Page 199
Chapter 15 EAF Logarithmic, Trigonometric and FIFO Instructions
Enter the value for the operand. Entry of operand (base 10) = 648 produces the result 2.811572. Figure 15.5 shows how the result is stored in the data table. Figure 15.5 EAF Log to Base 10 Format in the Data Table After Execution
Operand
17
16
X
S
X
S
15 0
0
14 13 O/U
O/U
Result
Sine and Cosine
10 7
43
Data 0 Address 040
0
0
0
6
4
8
0
0
0
0
0
0
043
041 042
0
0
0
Result Address 060
0
0
2
061
8
1
1
062
5
7
2
063
10365-I
This EAF trigonometric function finds the sine (or cosine) of an angle. The angle operand (data) is in degrees. Word formats for sine and cosine are the same. The only difference between the two EAFs is their function numbers: sine is 35 and cosine is 36. Both functions operate based on 6-digit operands. sine +/–xxx xxx . xxx xxx = +/–yyy yyy . yyy yyy Enter an EAF rung like that shown in Figure 15.6 Figure 15.6 EAF Sine Function, Operand and Result Rung 060 G 000 040 G 000
061 G 002 041 G 060
062 G 866 042 G 000
063 G 025 043 G 000
EXECUTE AUX FUNCTION FUNCTION NUMBER: 35 DATA ADDR: 040 RESULT ADDR: 060
Enter the value of the angle in degrees (operand rung). Enter the angle from the keyboard of your 1770-T3 terminal or through ladder diagram instructions. Entry of the angle 060 in word 041 produces the result
15-6
Page 200
Chapter 15 EAF Logarithmic, Trigonometric and FIFO Instructions
0.866025 for the sine function and and 0.500 for the cosine function. Figure 15.7 shows how it is stored in the data table. Figure 15.7 EAF Sine Function Format After Execution 17
FIFO Load and FIFO Unload
15 14 13
0
Operand
Result
16
X
S
O
10 7
43
Data 0 Address 040
0
0
0
0
6
0
0
0
0
0
0
0
043
041 042
0
0
0
Result Address 060
0
0
0
061
8
6
6
062
0
2
5
063
10366-I
The FIFO Load and FIFO Unload are output instructions that can be used together to construct an asynchronous word shift register. Length of the FIFO can be a maximum 999 words long. Upon a false-to-true transition of the FIFO Load rung, the contents of the Input Word is transferred into the File as long as the input word is non-zero. Upon a false-to-true transition of the FIFO Unload rung, the word at the top of the file (highest file address) is transferred out of the File to an Output Word. Important: Only non-zero values can be loaded. Use the full and empty flags in your ladder program to assure that the data being loaded/unloaded to/from the file is not lost or invalid.
15-7
Page 201
Chapter 15 EAF Logarithmic, Trigonometric and FIFO Instructions
Bits 14-17 of the result word are reserved for status bits: This Bit: 14
Stores this: file empty indicator 1 file is empty 0 file has data You cannot unload data from an empty file. If the FIFO file is empty, there is no data to unload. Use this bit to condition a FIFO Unload.
15 file full indicator 1 file is full 0 file has data You cannot load data after the FIFO file is full. If you attempt to load any data it will be lost. As soon as you unload the first word, the bit resets (0). Use this bit to condition a FIFO Load. Data transfers with a false to true (0 to 1) transition of the EAF rung. You can monitor this transition with bits 16 or 17.
16 unload enabled 1 FIFO is enabled 0 FIFO is not enabled
17 load enabled 1 FIFO is enabled 0 FIFO is not enabled
Important: The FIFO Load and FIFO Unload instructions must have the same File Address, Result Address and File Length. Data is loaded into and unloaded from the same addressed file. You can enter a ladder diagram for executing FIFO Loads and FIFO Unloads by entering a ladder diagram like that in Figure 15.8. This figure identifies all words and certain bits used in FIFO Load and FIFO Unload. Rungs 2, 3, 4 and 6 are included as display rungs and are not necessary for proper FIFO operation.
15-8
Page 202
Chapter 15 EAF Logarithmic, Trigonometric and FIFO Instructions
Figure 15.8 FIFO Load and FIFO Unload Ladder Diagram File Full Bit FIFO Load Conditioning Bit
File Address
130 00
15
060 G 000
030 G 040
031 G 005
032 G 060
050 G 000 040 G 000 FIFO Unload Conditioning Bit
050
Input Word Address Current Data Being Loaded
Input Word Address (
File Length Result Word Address (Number of Words Currently in File)
042 G 000
130
050
01
14
061 G 000
043 G 000
044 G 000
The File
Output Word Address Current Data Being Unloaded
FIle Enpty Bit
File Address
070 ) 00
070 ) 00 070 ( ) 00
( 041 G 000
033 G 040
EXECUTE AUX FUNCTION FUNCTION NUMBER:28 DATA ADDR: 030 RESULT ADDR: 050
034 G 005
035 G 061
EXECUTE AUX FUNCTION FUNCTION NUMBER:29 033 DATA ADDR: 050 RESULT ADDR:
Output Word Address
(
070 ) 00
File Length
Important: Read chapter 19 and become familiar with the concepts introduced in this chapter before attempting FIFO instructions. Figure 15.9 shows data (111) in the Input Word 060 ready to be loaded into the File. Toggle the precondition bit 13000 from false to true (0 to 1). Each time data is entered into the file, it is placed in the highest available address in the file. Observe that transferring data from the Input Word to the File does not destroy the data in the Input Word. Also, the Result Word (050) increments by 1 each time a transfer is performed. The Result Word indicates the number of words in your file at any given time. You can monitor the Result Word for this information.
15-9