Pré-visualização | Página 36 de 50
The value in the source must be greater than or equal to –102943.7 and less than or equal to 102943.7. The greatest accuracy is achieved when the source is greater than –2 Pi and less than 2 Pi, where Pi = 3.141592. The resulting value in the destination is either a real number or infinity. Use this instruction with SLC 5/03 (OS302), SLC 5/04 (OS401), and SLC 5/05 processors. Updates to Arithmetic Status Bits With this Bit: The Processor: Carry (C) always resets. Overflow (V) sets if an overflow is 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 SINE Source Dest SIN Output Instruction 333 TANGENT Source Dest TAN Output Instruction PrefaceInstruction Set Reference Manual 3–32 X to the Power of Y (XPY) Use the XPY instruction to raise a value (source A) to a power (source B) and store the result in the destination. If the value in source A is negative, the exponent (source B) should be a whole number. If it is not a whole number, the overflow bit is set and the absolute value of the base is used in the calculation. Use this instruction with SLC 5/03 (OS302), SLC 5/04 (OS401), and SLC 5/05 processors. The XPY instruction uses the following algorithm: XPY = 2 ** (Y * log2 (X)) If any of the intermediate operations in this algorithm produce an overflow, the Arithmetic Overflow Status bit (S:0/1) is set. Updates to Arithmetic Status Bits With this Bit: The Processor: Carry (C) always resets. Overflow (V) sets if an overflow is 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 X TO POWER OF Y Source A Source B Dest XPY Output Instruction Math Instructions 3–33 Math Instructions in the Paper Drilling Machine Application Example This section provides ladder rungs to demonstrate the use of math instructions. The rungs are part of the paper drilling machine application example described in appendix H. You will be adding to the subroutine in file 7 that was started in chapter 1. Adding File 7 Rung 7:1 This rung resets the number of 1/4” increments and the 1/4” thousands when the ”drill change reset” keyswitch is energized. This should occur following each drill bit change. | drill 1/4” | | change Thousands | | reset | | keyswitch | | I:1.0 +CLR–––––––––––––––+ | |––––] [––––––––––––––––––––––––––––––––––––––––––––––+–+CLEAR +–+–| | 8 | |Dest N7:11| | | | | | 0| | | | | +––––––––––––––––––+ | | | | 1/4” | | | | increments | | | | | | | | +CLR–––––––––––––––+ | | | +–+CLEAR +–+ | | |Dest N7:10| | | | 0| | | +––––––––––––––––––+ | Rung 7:6 Keep a running total of how many inches of paper have been drilled with the current drill bit. Every time a hole is drilled, add the thickness (in 1/4”s) to the running total (kept in 1/4”s). The OSR is necessary because the ADD executes every time the rung is true, and the drill body would actuate the DRILL DEPTH limit switch for more than 1 program scan. Integer N7:12 is the integer–converted value of the BCD thumbwheel on inputs I:3/11 – I:3/14. | Drill |Tool Wear 1/4” | | Depth LS | OSR 1 increments | | | | I:1.0 B3:1 +ADD–––––––––––––––+ | |––––] [–––––––[OSR]––––––––––––––––––––––––––––––––––––––+ADD +–| | 4 8 |Source A N7:12| | | | 1| | | |Source B N7:10| | | | 0| | | |Dest N7:10| | | | 0| | | +––––––––––––––––––+ | PrefaceInstruction Set Reference Manual 3–34 Rung 7:7 When the number of 1/4” increments surpasses 1000, find out now many increments we are past 1000 and store in N7:20, add 1 to the total of ’1000 1/4”’ increments, and re–initialize the 1/4” increments accumulator to how many increments were beyond 1000. | 1/4” | | increments | | | | +GEQ–––––––––––––––+ +SUB–––––––––––––––+ | |–+GRTR THAN OR EQUAL+––––––––––––––––––––––––––––––––+–+SUBTRACT +–+–| | |Source A N7:10| | |Source A N7:10| | | | | 0| | | 0| | | | |Source B 1000| | |Source B 1000| | | | | | | | | | | | +––––––––––––––––––+ | |Dest N7:20| | | | | | 0| | | | | +––––––––––––––––––+ | | | | 1/4” | | | | Thousands | | | | +ADD–––––––––––––––+ | | | +–+ADD +–+ | | | |Source A 1| | | | | | | | | | | |Source B N7:11| | | | | | 0| | | | | |Dest N7:11| | | | | | 0| | | | | +––––––––––––––––––+ | | | | | | | | | | | | | | | | 1/4” | | |