Skip to content

Element Reference: Bits, Timers, Counters, Compare ​

Last updated

License feature: Ladder Logic

This page and Math, Data and Program Control list every instruction the palette offers and exactly what the engine does with it. "Power in" is whether the rung has power when the scan reaches the element; "power out" is what it passes to the next element.

Instructions that are not listed — ONS, CMP, MEQ, PID, MSG, GSV/SSV — do not exist. Parallel branches are drawn in the editor; see The Ladder Editor.

Contacts ​

All four have one operand, Tag.

MnemonicNamePower out
XICExamine If ClosedPower in AND tag is on
XIOExamine If OpenPower in AND tag is off
OSROne-Shot RisingPower in AND the tag went from off to on since the previous scan
OSFOne-Shot FallingPower in AND the tag went from on to off since the previous scan

OSR and OSF look at the edge of their own tag, not at rung power as in RSLogix. They remember the tag's value every time they are scanned, so an edge that happens while the rung before them is false is used up. Put them first on the rung. In a routine that isn't called every scan, edges between calls are seen late or missed.

Coils ​

One operand, Tag. Power out = power in, so coils can be followed by more elements.

MnemonicNameBehavior
OTEOutput Energize1 when power in, 0 when not
OTLOutput Latch1 on a scan with power in; nothing otherwise
OTUOutput Unlatch0 on a scan with power in; nothing otherwise
RESResetWith power in, clears the timer or counter at its Timer or counter to reset address (accumulator 0, not done)

A device tag is only actually written when its value changes (see Tags and Addresses); internal tags are set on every scan.

Two OTEs on the same tag fight: the last one in the scan wins. Use one OTE per tag, or OTL/OTU pairs.

Timers ​

Settings: Preset (ms) (default 1000) and Address (optional). The timer's done state is its power out. Give it an address such as T4:0 to read T4:0/DN, /TT, /EN and T4:0.ACC from other rungs and to reset it with RES — see Tags and Addresses.

MnemonicNameBehaviorPower out
TONTimer On-DelayAccumulates while power in is true; when the accumulator reaches the preset it is done. Power in false resets it to 0 at onceOn while done
TOFTimer Off-DelayPower in true: done, accumulator 0. When power in goes false it starts timing and stops being done after the presetOn while power in, and for the preset after it goes off
RTORetentive TimerLike TON, but keeps its accumulator when power in goes falseOn once done — forever

Warning: An RTO that has finished stays finished until it is reset: give it an address and reset it with RES.

  • Monitor mode shows ACC:1834 PRE:5000.
  • The Preset is a number on the element; a MOV to T4:0.PRE replaces it at runtime (for example from a recipe), and that value is kept until written again.
  • Accumulators are kept through Stop/Run, Save and restarts.
  • A timer in a routine that isn't called every scan: when it is next called with power in still true, the accumulator jumps by the whole time it wasn't called.

Counters ​

Settings: Preset (default 10) and Address (optional), such as C5:0, to read C5:0/DN and C5:0.ACC elsewhere, preload .ACC or change .PRE, and reset it with RES.

MnemonicNameBehaviorPower out
CTUCount UpAdds 1 each time power in goes from false to true. Done when the count ≥ presetOn while done
CTDCount DownStarts at the preset; subtracts 1 on each false→true of power in. Done when the count ≤ 0. It keeps going negativeOn while done

A CTU that reaches its preset stays done and keeps counting until it is reset with RES (it needs an address). Counts survive Stop/Run, Save and restarts (saved every 10 s).

Compare ​

Operands Source A and Source B (each a device tag, task/program tag or literal). The comparison is only made when power in is true.

MnemonicNamePower out when power in and
EQUEqualA = B
NEQNot EqualA ≠ B
GRTGreater ThanA > B
LESLess ThanA < B
GEQGreater or EqualA ≥ B
LEQLess or EqualA ≤ B

Both sides are converted to numbers (text → 0). EQU and NEQ compare exactly, so a float like 21.499999 is not equal to 21.5 — use GEQ/LEQ for floats.

LIM — Limit Test ​

Operands Low Limit, Test and High Limit (each a device tag, task/program tag or literal; a new LIM starts with literals 0 and 100). Like the other compares, it is only evaluated when power in is true.

LimitsPower out when power in and
Low ≤ HighLow ≤ Test ≤ High — inside the band, both limits included
Low > HighTest ≥ Low or Test ≤ High — outside the band between them, which tests "out of window" with one instruction

For example, Low 20, High 80 is true from 20 to 80; Low 80, High 20 is true at 80 and above or at 20 and below.

See also ​

Scada.Ink Help Center