ADD — Add

Description
Section titled “Description”ADD (Add) writes the sum of Source A and Source B to Dest every scan its rung is true. It is an output instruction with no state and no status bits: the result is simply there in Dest after the scan. Use ADD to total counts, offset a reading, or accumulate a running sum with Dest as one of its own sources. Do not use ADD as a counter; an ungated ADD Total 1 Total adds one every scan, thousands of times a second. Count edges with CTU, or gate the ADD with an ONS.
Operands
Section titled “Operands”| Operand | Type | Format | Valid Range | Required | Description |
|---|---|---|---|---|---|
| Source A | Any numeric tag, member, element or bit, or a literal | Tag, Tag.Member, Tag[n], Tag.bit, or a literal |
Any resolvable numeric reference | Yes | The first value. |
| Source B | Same as Source A | Same | Any resolvable numeric reference | Yes | The value added to Source A. |
| Dest | A writable numeric tag, member or element | Tag, Tag.Member, Tag[n] |
SINT, INT, DINT or REAL; not a literal, not an input pin | Yes | Where the sum is written. |
Literals may be whole numbers (25, -3, 0x1F) or decimals (72.5). A BOOL source reads as 0 or 1. Dest may be the same tag as a source.
Dest type. The sum is computed as a number and stored in Dest’s type. A whole-number Dest truncates a fractional result toward zero (2.5 + 1 into an INT is 3) and wraps silently past its range: an INT holds −32768 to 32767, a DINT ±2,147,483,647. There is no overflow flag and no fault. Use a DINT when a total can grow, and a REAL when the fraction matters.
Scan Behavior
Section titled “Scan Behavior”Prescan
Section titled “Prescan”Nothing. Dest keeps whatever value it powered up with.
Rung-condition-in is false
Section titled “Rung-condition-in is false”The instruction does nothing. Dest holds its last value.
Rung-condition-in is true
Section titled “Rung-condition-in is true”Both sources are read, the sum is computed and written to Dest. This happens on every scan the rung is true, not once.
Postscan
Section titled “Postscan”Nothing.
Example
Section titled “Example”Scenario: Two lanes of a packing line each keep their own count. A supervisor lamp needs the combined total.
Tags:
Sum_Now— Compute the total, BOOLCount_A— Lane A count, INTCount_B— Lane B count, INTTotal— Combined count, INT
Rung 1:
—] [Sum_Now———[ADD Count_A Count_B Total]———Scan 1 — Sum_Now = 0. Count_A reads 40 and Count_B reads 25, but the rung is false: the block does not run and Total holds 0. Each tag operand shows its live value beneath it; the block itself paints neutral, only the rung colours.

Scan 2 — Sum_Now = 1. The rung is true: 40 + 25 is written to Total, which reads 65.

While Sum_Now stays on, Total tracks the two counts every scan. It keeps 65 after Sum_Now goes off.
See Also
Section titled “See Also”- SUB — Subtract
- CPT — Compute (more than one operation in a single instruction)
- CLR — Clear (zero a running sum)
- CTU — Count Up (count events, not scans)
- Compute Instructions — Category index
Running sum. ADD Total Delta Total with Total as both a source and the Dest is fine; the sources are read before Dest is written. Gate it with an ONS so it adds once per event.
Mixed types. An INT plus a REAL is computed as a REAL. What survives depends on Dest: a REAL Dest keeps the fraction, an INT Dest drops it.
The block never colours. Math blocks paint neutral in every mode. The rung wire and the Dest value line tell you whether it ran.
Applies to LadderIDE >=1.2.2 · Last reviewed 2026-09-11 · Screenshots verified 2026-09-11