Table of contents
S7-200 SMART
8 System Manual, V2.3, 07/2017, A5E03822230-AF
7.5 Convert ................................................................................................................................. 236
7.5.1 Standard conversion instructions ......................................................................................... 236
7.5.2 ASCII character array conversion ........................................................................................ 240
7.5.3 Number value to ASCII string conversion ............................................................................ 245
7.5.4 ASCII sub-string to number value conversion ..................................................................... 249
7.5.5 Encode and decode ............................................................................................................. 252
7.6 Counters ............................................................................................................................... 253
7.6.1 Counter instructions ............................................................................................................. 253
7.6.2 High-speed counter instructions .......................................................................................... 257
7.6.3 High-speed counter summary .............................................................................................. 260
7.6.4 Noise reduction for high-speed inputs ................................................................................. 261
7.6.5 High-speed counter programming ....................................................................................... 264
7.6.6 Example initialization sequences for high-speed counters .................................................. 277
7.7 Pulse output ......................................................................................................................... 285
7.7.1 Pulse output instruction (PLS) ............................................................................................. 285
7.7.2 Pulse train output (PTO) ...................................................................................................... 287
7.7.3 Pulse width modulation (PWM) ............................................................................................ 289
7.7.4 Using SM locations to configure and control the PTO/PWM operation ............................... 290
7.7.5 Calculating the profile table values ...................................................................................... 294
7.8 Math ..................................................................................................................................... 297
7.8.1 Add, subtract, multiply, and divide ....................................................................................... 297
7.8.2 Multiply integer to double integer and divide integer with remainder................................... 300
7.8.3 Trigonometry, natural logarithm/exponential, and square root ............................................ 302
7.8.4 Increment and decrement .................................................................................................... 305
7.9 PID ....................................................................................................................................... 307
7.9.1 Using the PID wizard ........................................................................................................... 308
7.9.2 PID algorithm ....................................................................................................................... 313
7.9.3 Converting and normalizing the loop inputs ......................................................................... 317
7.9.4 Converting the loop output to a scaled integer value........................................................... 318
7.9.5 Forward- or reverse-acting loops ......................................................................................... 319
7.10 Interrupt ................................................................................................................................ 322
7.10.1 Interrupt instructions ............................................................................................................ 322
7.10.2 Interrupt routine overview and CPU model event support ................................................... 324
7.10.3 Interrupt programming guidelines ........................................................................................ 326
7.10.4 Types of interrupt events that the S7-200 SMART CPU supports ...................................... 328
7.10.5
Interrupt priority, queuing, and example program ................................................................ 330
7.11 Logical operations ................................................................................................................ 335
7.11.1 Invert .................................................................................................................................... 335
7.11.2 AND, OR, and exclusive OR ................................................................................................ 336
7.12 Move .................................................................................................................................... 338
7.12.1 Move byte, word, double word, or real ................................................................................. 338
7.12.2 Block move ........................................................................................................................... 339
7.12.3 Swap bytes ........................................................................................................................... 340
7.12.4 Move byte immediate (read and write) ................................................................................ 341
7.13 Program control.................................................................................................................... 342
7.13.1 FOR-NEXT loop ................................................................................................................... 342
7.13.2 JMP (jump to label) .............................................................................................................. 344
7.13.3 SCR (sequence control relay) .............................................................................................. 345