1 / 33

ECT 464

ECT 464. Lecture 25 Siemens Instructions 4. Today’s Quote: No one ever said on their deathbed: I wish I would have spent more time at work! I hated all the things I had toiled for under the sun, because I must leave them to the one who comes after me. Ecclesiastes 2:18. Math Instructions.

Download Presentation

ECT 464

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ECT 464 Lecture 25 Siemens Instructions 4

  2. Today’s Quote: No one ever said on their deathbed: I wish I would have spent more time at work! I hated all the things I had toiled for under the sun, because I must leave them to the one who comes after me. Ecclesiastes 2:18

  3. Math Instructions

  4. Add/Subtract Ladder Logic and FBD IN1 + IN2 = OUT IN1 - IN2 = OUT STL IN1 + OUT = OUT OUT - IN1 = OUT The Add Integer (+I) or Subtract Integer (-I) instructions add or subtract two 16-bit integers to produce a 16-bit result. The Add Double Integer (+D) or Subtract Double Integer (-D) instructions add or subtract two 32-bit integers to produce a 32-bit result. The Add Real (+R) and Subtract Real (-R) instructions add or subtract two 32-bit real numbers to produce a 32-bit real number result.

  5. Multiply/Divide Ladder Logic and FBD IN1 * IN2 = OUT IN1 / IN2 = OUT STL IN1 * OUT = OUT OUT / IN1 = OUT The Multiply Integer (*I) or Divide Integer (/I) instructions multiply or divide two 16-bit integers to produce a 16-bit result. (For division, no remainder is kept.) The Multiply Double Integer (*D) or Divide Double Integer (/D) instructions multiply or divide two 32-bit integers to produce a 32-bit result. (For division, no remainder is kept.) The Multiply Real (*R) or Divide Real (/R) instructions multiply or divide two 32-bit real numbers to produce a 32-bit real number result.

  6. Example 1

  7. Example 2

  8. Multiply and Divide

  9. Multiply and Divide Multiply Integer to Double Integer IN1 * IN2 = OUT LAD and FBD IN1 * OUT = OUT STL The Multiply Integer to Double Integer instruction (MUL) multiplies two 16-bit integers and produces a 32-bit product. In the STL MUL instruction, the least-significant word (16 bits) of the 32-bit OUT is used as one of the factors. Divide Integer with Remainder IN1 / IN2 = OUT LAD and FBD OUT / IN1 = OUT STL The Divide Integer with Remainder instruction (DIV) divides two 16-bit integers and produces a 32-bit result consisting of a 16-bit remainder (the most-significant word) and a 16-bit quotient (the least-significant word). In STL, the least-significant word (16 bits) of the 32-bit OUT is used as the dividend.

  10. Multiply and Divide Example

  11. Numeric Functions

  12. Numeric Functions Sine, Cosine, and Tangent The Sine (SIN), Cosine (COS), and Tangent (TAN) instructions evaluate the trigonometric function of the angle value IN and place the result in OUT. The input angle value is in radians. SIN (IN) = OUT COS (IN) = OUT TAN (IN) = OUT Natural Logarithm and Natural Exponential The Natural Logarithm instruction (LN) performs the natural logarithm of the value in IN and places the result in OUT. The Natural Exponential instruction (EXP) performs the exponential operation of e raised to the power of the value in IN and places the result in OUT. LN (IN) = OUT EXP (IN)= OUT Square Root The Square Root instruction (SQRT) takes the square root of a real number (IN) and produces a real number result OUT. SQRT (IN)= OUT

  13. Increment and Decrement Increment IN + 1 = OUT LAD and FBD OUT + 1 = OUT STL Decrement IN -- 1 = OUT LAD and FBD OUT -- 1 = OUT STL The Increment and Decrement instructions add or subtract 1 to or from the input IN and place the result into the variable OUT. Increment Byte (INCB) and Decrement Byte (DECB) operations are unsigned. Increment Word (INCW) and Decrement Word (DECW) operations are signed. Increment Double Word (INCD) and Decrement Double Word (DECD) operations are signed.

  14. Increment and Decrement

  15. PID

  16. PID The PID Loop instruction (PID) executes a PID loop calculation on the referenced LOOP based on the input and configuration information in Table (TBL). The PID loop instruction (Proportional, Integral, Derivative Loop) is provided to perform the PID calculation. The top of the logic stack (TOS) must be ON (power flow) to enable the PID calculation. The instruction has two operands: a TABLE address which is the starting address of the loop table and a LOOP number which is a constant from 0 to 7. Eight PID instructions can be used in a program. The loop table stores nine parameters used for controlling and monitoring the loop operation and includes the current and previous value of the process variable, the setpoint, output, gain, sample time, integral time (reset), derivative time (rate), and the integral sum (bias). To perform the PID calculation at the desired sample rate, the PID instruction must be executed either from within a timed interrupt routine or from within the main program at a rate controlled by a timer. The sample time must be supplied as an input to the PID instruction via the loop table. Auto-Tune capability has been incorporated into the PID instruction. The PID Tuning Control Panel only works with PID loops created by the PID wizard..

  17. Logical Instructions

  18. Logical Instructions Invert Byte, Word, and Double Word The Invert Byte (INVB), Invert Word (INVW), and Invert Double Word (INVD) instructions form the one’s complement of the input IN and load the result into the memory location OUT.

  19. Logical Instructions

  20. Logical Instructions AND Byte, AND Word, and AND Double Word The AND Byte (ANDB), AND Word (ANDW), and AND Double Word (ANDD) instructions AND the corresponding bits of two input values IN1 and IN2 and load the result in a memory location OUT. OR Byte, OR Word and OR Double Word The OR Byte (ORB), OR Word instruction (ORW), and OR Double Word (ORD) instructions OR the corresponding bits of two input values IN1 and IN2 and load the result in a memory location OUT. Exclusive OR Byte, Exclusive OR Word, and Exclusive OR Double Word The Exclusive OR Byte (XROB), Exclusive OR Word (XORW), and Exclusive OR Double Word (XORD) instruction XOR the corresponding bits of two input values IN1 and IN2 and load the result in a memory location OUT.

  21. Logical Instructions

  22. Move Instructions

  23. Move Instructions Move Byte, Word, Double Word, or Real The Move Byte (MOVB),Move Word (MOVW),Move Double Word (MOVD), and Move Real (MOVR) instructions move a value from a memory location IN to a new memory location OUT without changing the original value. Use the Move Double Word instruction to create a pointer. For the IEC Move instruction, the input and output data types can vary, but must be of the same size.

  24. Move Instructions

  25. Move Instructions The Move Byte Immediate instructions allow you to immediately move a byte between the physical I/O and a memory location. The Move Byte Immediate Read (BIR) instruction reads physical input (IN) and writes the result to the memory address (OUT), but the process-image register is not updated. The Move Byte Immediate Write instruction (BIW) reads the data from the memory address (IN) and writes to physical output (OUT), and the corresponding process image location.

  26. Move Instructions

  27. Move Instructions Block Move Byte, Word, or Double Word The Block Move Byte (BMB), Block Move Word (BMW), and Block Move Double Word (BMD) instructions move a specified amount of data to a new memory location by moving the number of bytes, words, or double words N starting at the input address IN to a new block starting at the output address OUT. N has a range of 1 to 255.

  28. Program Control Instructions

  29. Program Control Instructions Conditional End The Conditional End instruction (END) terminates the current scan based upon the condition of the preceding logic. You can use the Conditional End instruction in the main program, but you cannot use it in either subroutines or interrupt routines. Stop The Stop instruction (STOP) terminates the execution of your program by causing a transition of the S7-200 CPU from RUN to STOP mode. If the Stop instruction is executed in an interrupt routine, the interrupt routine is terminated immediately, and all pending interrupts are ignored. Remaining actions in the current scan cycle are completed, including execution of the main user program, and the transition from RUN to STOP mode is made at the end of the current scan. Watchdog Reset The Watchdog Reset instruction (WDR) retriggers the system watchdog timer of the S7-200 CPU to extend the time that the scan is allowed to take without getting a watchdog error.

  30. Program Control Instructions

  31. Loop Instructions

  32. Loop Instructions Use the For (FOR) and Next (NEXT) instructions to delineate a loop that is repeated for the specified count. Each For instruction requires a Next instruction. You can nest For--Next loops (place a For--Next loop within a For--Next loop) to a depth of eight. The For instruction executes the instructions between the For and the Next instructions. You specify the index value or current loop count INDX, the starting value INIT, and the ending value FINAL. The Next instruction marks the end of the FOR loop.

  33. Loop Instructions

More Related