Pré-visualização | Página 38 de 50
slightest difference in point-to-point input filter delay can cause the FRD instruction to overflow due to the conversion of a non–BCD digit. 3333 333 FRD FROM BCD Source Dest FRD FROM BCD Source S:13 00000000 Dest Output Instruction SLC 5/02 and higher Processors and MicroLogix 1000 controllers Output Instruction Fixed and SLC 5/01 Processors Data Handling Instructions 4–7 ]/[ S:1 15 EQU EQUAL Source A N7:1 0 Source B I:0.0 0 MOV MOVE Source I:0.0 0 Dest N7:1 0 FRD FROM BCD Source I:0.0 0 Dest N7:2 0 In the above example, the two rungs cause the processor to verify that the value at I:0.0 remains the same for two consecutive scans before it executes the FRD. This prevents the FRD from converting a non-BCD value during an input value change. Note To convert numbers larger than 9999 BCD, the source must be the Math Register (S:13). You must reset the Minor Error bit (S:5.0) to prevent an error. Changes to the Math Register, S:13 and S:14 Used as the source for converting the entire number range of a register. Example 1 The BCD value 9760 at source N7:3 is converted and stored in N10:0. The maximum source value is 9999, BCD. The source value is displayed in BCD format. 9 7 6 0 9 7 6 0 N7:3 4–digit BCD 1001 0111 0110 0000 N10:0 Decimal 0010 0110 0010 0000 FRD FROM BCD Source N7:3 9760 Dest N10:0 9760 3 3333 PrefaceInstruction Set Reference Manual 4–8 Example 2 The BCD value 32760 in the math register is converted and stored in N7:0. The maximum source value is 32767, BCD. 0 0 0 3 2 7 6 0 3 2 7 6 0 0 01515 5–digit BCDS:14 S:13 0000 0000 0000 0011 0010 0111 0110 0000 N7:0 Decimal 0111 1111 1111 1000 FRD FROM BCD Source S:13 00032760 Dest N7:0 32760 S:13 and S:14 are displayed in BCD format. You should convert BCD values to integer before you manipulate them in your ladder program. If you do not convert the values, the processor manipulates them as integers and their value is lost. Note If the math register (S:13 and S:14) is used as the source for the FRD instruction and the BCD value does not exceed 4 digits, be sure to clear word S:14 before executing the FRD instruction. If S:14 is not cleared and a value is contained in this word from another math instruction located elsewhere in the program, an incorrect decimal value will be placed in the destination word. 3333 333 Data Handling Instructions 4–9 Clearing S:14 before executing the FRD instruction is shown below: CLR CLEAR Dest S:14 0 FRD FROM BCD Source S:13 00001234 Dest N7:0 1234 S:13 and S:14 are displayed in BCD format. MOV MOVE Source N7:2 4660 Dest S:13 4660 ] [ I:1 0 0001 0010 0011 0100 0000 0100 1101 0010 When the input condition is set (1), a BCD value (transferred from a 4-digit thumbwheel switch for example) is moved from word N7:2 into the math register. Status word S:14 is then cleared to make certain that unwanted data is not present when the FRD instruction is executed. PrefaceInstruction Set Reference Manual 4–10 Radian to Degrees (DEG) Use this instruction to convert radians (source) to degrees and store the result in the destination. The following formula applies: Source � 180/Π where Π = 3.141592 Use this instruction with SLC 5/03 (OS302), SLC 5/04 (OS401), and SLC 5/05 processors. Entering Parameters • Source is the integer and/or floating point values. • Destination is the address of the word where the data is to be stored. Updates to Arithmetic Status Bits With this Bit: The Processor: Carry (C) always resets. Overflow (V) sets if overflow generated or an unsupported input is detected; otherwise resets Zero (Z) sets if the result is zero; otherwise resets Sign (S) sets if the result is negative; otherwise resets 333 Radians to Degrees Source Dest DEG Output Instruction Data Handling Instructions 4–11 Degrees to Radians (RAD) Use this instruction to convert degrees (source) to radians and store the result in the destination. The following formula applies: Source � Π/180 where Π = 3.141592 Use this instruction with SLC 5/03 (OS302), SLC 5/04 (OS401), and SLC 5/05 processors processors. Entering Parameters • Source is the integer and/or floating point values. • Destination is the address of the word where the data is to be stored. Updates to Arithmetic Status Bits With this Bit: The Processor: Carry (C) always resets. Overflow (V) sets if overflow generated or an unsupported input is detected; otherwise resets Zero (Z) sets if the result is zero; otherwise resets Sign (S) sets if the result is negative; otherwise resets 333 Degress to Radians Source Dest RAD Output Instruction PrefaceInstruction Set Reference Manual 4–12 Decode 4 to 1 of 16 (DCD) When executed, this instruction sets one bit of the destination word. The particular bit that is turned on depends on the value of the first four bits of the source word. See the table below. Use this instruction to multiplex data in applications such as rotary switches, keypads, and bank switching. Source Destination Bit 15–04 03 02 01 00 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 x 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 x 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 x 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 x 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 x 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 x 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 x 0 1 1 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 x 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 x 1 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 x 1 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 x 1 0 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 x 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 x 1 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 x 1 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Entering Parameters • Source is the address that contains the bit decode information. Only the first four bits (0–3) are used by the DCD instruction. The remaining bits may be used for other application specific needs. Change the value of the first four bits of this word to select one bit of the destination word. • Destination is the address of the word where the data is to be stored. Updates to Arithmetic Status Bits Unaffected. 3333 333 DCD DECODE 4 to 1 of 16 Source Dest Output Instruction Data Handling Instructions 4–13 Encode 1 of 16 to 4 (ENC) When the rung is true, this output instruction searches the source from the lowest to the highest bit, and looks for the first set bit. The corresponding bit position is written to the destination as an integer as shown in the table below. Source Destination Bit 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 15–04 03 02 01 00 x x x x x x x x x x x x x x x 1 x 0