Skip to main content

Data Types

Every tag has a data type. The type decides what values the tag can hold, how much memory it uses, and which instructions can read or write it.

Summary

TypeUsed For
BOOLContacts, coils, one-shots, timer/counter status bits
DINTCounts, presets, numeric values
REALAnalog values, setpoints, calculations
TIMERLadder timer tags — used by TON, TOF, RTO
COUNTERLadder counter tags — used by CTU, CTD
FBD_TIMERStructured Text timer function block — TONR, TOFR, RTOR
FBD_COUNTERStructured Text counter function block — CTUD

BOOL

A single bit — 0 or 1. The most common type in ladder logic — every contact and coil operates on a BOOL.

Use BOOL for:

  • Pushbuttons, limit switches, and other digital inputs
  • Motors, pilot lights, alarms, and other digital outputs
  • Internal flags — running, fault, ready, enabled
  • Status bits on structured tags (.DN, .EN, .TT, etc.)

Write BOOL values as 0 or 1. Do not use the strings "true" or "false".

DINT

A 32-bit signed integer. Range: -2,147,483,648 to 2,147,483,647.

Use DINT for:

  • Counts and totals
  • Timer and counter presets (in milliseconds / steps)
  • Numeric comparisons
  • Array indices

Example: PartsToday counts pieces produced; CycleTime.PRE sets a timer to 5000 ms.

REAL

A 32-bit floating-point number with decimal precision.

Use REAL for:

  • Temperatures, pressures, flow rates
  • Sensor readings that need decimal values
  • Engineering-unit calculations

Mixing REAL and DINT:

  • DINT / DINT into a DINT destination truncates toward zero (7 / 2 = 3).
  • DINT / DINT into a REAL destination keeps the fraction (7 / 2 = 3.5).
  • Any REAL operand into a DINT destination uses banker rounding (ties-to-even): 2.5 → 2, 3.5 → 4, −1.5 → −2.

Writing REAL literals

A REAL literal must contain a decimal point. Scientific notation needs a digit on both sides of the decimal point, and a leading + sign is not allowed.

  • Accepted: 3.14, -0.5, -.5, 1.0e3, -1.5e1, -2.5e2.
  • Rejected: 1e3 (no decimal), .5e2 (no digit before the decimal), +1.5e0 (unary + not allowed on literals).

To write a positive REAL literal, just omit the sign — 1.5e0, not +1.5e0. This matches the rule used by the current generation of Rockwell tooling.

See Arithmetic and Comparison Operators for the full division and rounding matrix, or the MOVE instruction for type conversion in ladder logic.

Structured types

TIMER, COUNTER, FBD_TIMER, and FBD_COUNTER are structures, not single values. They expose named members (.PRE, .ACC, .DN, …) that your logic reads and writes on a rung.

Each instruction that uses a structured tag documents its members in the instruction reference — see the Ladder Logic and Structured Text instruction pages.