
8.6.2 High-speed counter instructions....................................................................................... 282
8.6.3 High-speed counter summary .......................................................................................... 285
8.6.4 Noise reduction for high-speed inputs .............................................................................. 286
8.6.5 High-speed counter programming.................................................................................... 287
8.6.6 Example initialization sequences for high-speed counters................................................. 298
8.7 Pulse output .................................................................................................................... 305
8.7.1 Pulse output instruction (PLS) .......................................................................................... 305
8.7.2 Pulse train output (PTO) ................................................................................................... 307
8.7.3 Pulse width modulation (PWM) ........................................................................................ 309
8.7.4 Using SM locations to congure and control the PTO/PWM operation ................................ 310
8.7.5 Calculating the prole table values ................................................................................... 313
8.8 Math ............................................................................................................................... 316
8.8.1 Add, subtract, multiply, and divide ................................................................................... 316
8.8.2 Multiply integer to double integer and divide integer with remainder................................ 320
8.8.3 Trigonometry, natural logarithm/exponential, and square root.......................................... 321
8.8.4 Increment and decrement................................................................................................ 323
8.9 PID .................................................................................................................................. 324
8.9.1 Using the PID wizard ........................................................................................................ 326
8.9.2 PID algorithm................................................................................................................... 331
8.9.3 Converting and normalizing the loop inputs ..................................................................... 334
8.9.4 Converting the loop output to a scaled integer value ........................................................ 335
8.9.5 Forward- or reverse-acting loops ...................................................................................... 335
8.10 Interrupt.......................................................................................................................... 338
8.10.1 Interrupt instructions ....................................................................................................... 338
8.10.2 Interrupt routine overview and CPU model event support ................................................. 339
8.10.3 Interrupt programming guidelines.................................................................................... 341
8.10.4 Types of interrupt events that the S7-200 SMART CPU supports......................................... 342
8.10.5 Interrupt priority, queuing, and example program............................................................. 344
8.11 Logical operations............................................................................................................ 349
8.11.1 Invert .............................................................................................................................. 349
8.11.2 AND, OR, and exclusive OR............................................................................................... 350
8.12 Move............................................................................................................................... 351
8.12.1 Move byte, word, double word, or real ............................................................................. 351
8.12.2 Block move ...................................................................................................................... 352
8.12.3 Swap bytes ...................................................................................................................... 353
8.12.4 Move byte immediate (read and write)............................................................................. 354
8.13 Program control............................................................................................................... 355
8.13.1 FOR-NEXT loop ................................................................................................................ 355
8.13.2 JMP (jump to label).......................................................................................................... 356
8.13.3 SCR (sequence control relay)............................................................................................ 358
8.13.4 END, STOP, and WDR (watchdog timer reset) .................................................................... 365
8.13.5 GET_ERROR (Get non-fatal error code).............................................................................. 366
8.14 Shift and rotate................................................................................................................ 367
8.14.1 Shift and rotate................................................................................................................ 367
8.14.2 Shift register bit............................................................................................................... 370
8.15 String .............................................................................................................................. 372
8.15.1 String (Get length, copy, and concatenate)....................................................................... 372
8.15.2 Copy substring from string ............................................................................................... 374
Table of contents
S7-200 SMART
System Manual, V2.7, 08/2022, A5E03822230-AK 9