Skip to main content

Example - Structured Text

ADD


The ADD instruction adds a WORD value, S1, to a WORD value, S2, and saves the sum in an assigned WORD data register, D.

Structured Text Example

// Move values into data registers
IF mx100 = 1 THEN
MOV (50, dw0);
MOV (10, dw1);
END_IF;

// Add data registers
IF mx00 = 1 THEN
ADD (dw0, dw1, dw2);
END_IF;

When the contact, M10.0, is powered ON, 50 is moved into the WORD data register, D0, and 10 is moved into the WORD data register, D1.


When the contact, M0.0, is powered ON, the WORD data register, D0, is added to the WORD data register, D1, and the sum saved in the WORD data register, D2.

Memory Monitor

ADDP


The ADDP one-shot instruction adds a WORD value, S1, to a WORD value, S2, and saves the sum in an assigned WORD data register, D.
Every time this instruction executes, it energizes the output only once.

Structured Text Example

// Move values into data registers
IF mx100 = 1 THEN
MOV (50, dw0);
MOV (10, dw1);
END_IF;

// Add data registers
IF mx00 = 1 THEN
ADDP (dw0, dw1, dw2);
END_IF;

When the contact, M10.0, is powered ON, 50 is moved into the WORD data register, D0, and 10 is moved into the WORD data register, D1.


When the contact, M0.0, is powered ON, the WORD data register, D0, is added to the WORD data register, D1, and the sum saved in the WORD data register, D2.

Memory Monitor