Programming instructions
89
13.7 Increment and Decrement Instructions
INC – Increment
DINC – 32-Bit Increment
DEC – Decrement
DDEC – 32-Bit Decrement
The increment and decrement instructions simply add or subtract 1 from the data
in a 16-bit data register. These instructions execute nearly twice as fast as ADD
or SUB instructions, and are not subjected to the limitations of a counter. These
commands can be coded to operate on 32-bit numbers as DINC/DINCP and
DDEC/DDECP.
Since this operation occurs every scan, INCP/DECP are almost always used for
most applications.
When X11 is on, register D1 is increased by one every program scan.
When X11 is on, register D1 is decreased by one every program scan.
13.8 EXERCISE
INC and DEC
Please find Project #3 in the appendix. This project is intended to demonstrate
the difference between INC/DEC and INCP/DECP.
13.9 Arithmetic Instructions
The arithmetic instructions must be placed in the end of the rung. When X1
conducts the addition instruction is performed.
When X1 conducts, the integer constant 30 (K30) is added to the existing value
of D0 and the result placed in D10 every PLC scan.
Math Function 16-Bit Data 32-Bit Data Floating Point
Addition ADD DADD DEADD
Subtraction SUB DSUB DESUB
Multiplication MUL DMUL DEMUL
Division DIV DDIV DEDIV
Square Root SQR DSQR DESQR