Common Data Types in TIA Portal

TIA Portalsupports a wide variety of data types used to represent values, signals, states, timers, characters, and structured data. Below are the most frequently used types when programming OBs, FCs, FBs, and DBs.

BOOL

  • Represents a binary value: TRUE or FALSE.
  • Typically used for digitalsignals, flags, and conditions.

INT / UINT

  • INT: 16-bit signed integer → Range: -32,768 to +32,767
  • UINT: 16-bit unsigned integer → Range: 0 to 65,535
  • Used for counters, timers, small numeric values.

DINT / UDINT

  • DINT: 32-bit signed integer → Range: -2,147,483,648 to +2,147,483,647
  • UDINT: 32-bit unsigned → Range: 0 to 4,294,967,295
  • Used when larger numerical range is needed (e.g., encoder values, runtime logs).

REAL / LREAL

  • REAL: 32-bit floating point number (approx. 7 decimal digits precision)
  • LREAL: 64-bit floating point number (higher precision, approx. 15-17 digits)
  • Used for analog signals, scaling, calculations with decimals.

BYTE

  • 8-bit data type. Can be used for grouping 8 BOOLs or storing raw values.
  • Often used for communication buffers or binary flags.

CHAR

  • Stores a single ASCII character (1 byte).

STRING / WSTRING

  • STRING: A series of ASCII characters (up to 254 characters).
  • WSTRING: Wide-character string (for Unicode/UTF-16 support), typically used in multilingual or HMI applications.

TIME

  • Stores time values (e.g., T#5s, T#1h30m10s).
  • Used for timers, delays, or timestamping.

ARRAY [x..y] OF <type>

  • Collection of elements of the same type, indexed by position.
  • Example: ARRAY [1..5] OF INT stores 5 integer values.
  • Commonly used for sensor arrays, batch data, or buffer management.

Variable Interface Types(Declaration Sections)

Each block type (FC, FB, OB) in TIA Portal allows you to declare variables in different interface sections, each serving a specific purpose in terms of data flow and memory usage.

Input (IN)

  • Read-only from inside the block.
  • Values are passed from the calling block to the function or function block.
  • Cannot be modified inside the block.

Example: A temperature setpoint passed into a heating control FB.

Output (OUT)

  • Write-only from inside the block.
  • Used to send data back to the caller.
  • Must be assigned a value within the block to be meaningful.

Example: An error flag that indicates fault status to the calling OB.

InOut

  • Allows the block to both read and modify the same variable.
  • Changes are reflected back to the caller.
  • Used with caution — potential for unexpected side effects.

Example: A cumulative runtime counter that is updated in each scan.

Temp

  • Temporary variables, stored in the local stack of the block.
  • Exist only during block execution and are not retained.
  • Cannot be accessed outside the block.
  • Ideal for intermediate calculations orstate tracking that doesn’t need to persist.

Example: A temporary result in a math formula inside an FC.

Summary Table

Data TypeDescriptionTypical Use
BOOLTRUE / FALSEDigital I/O, flags
INT , DINTSigned integersCounters, value
REAL , LREALFloating pointAnalog values, scaling
BYTE8 bitsGrouped bits, comms
CHAR ,STRING, WSTRINGText dataHMI, logging
TIME Time formatTimers, delays
ARRAY [x,y] OF …Indexed listBuffers,sensor groups
Variable TypeDirectionScopePersistence
InputINFrom caller → blockRead-only
OutputOUTFrom block → callerWrite-only
InOutBothSharedRead/Write
TempInternalLocal OnlyLost after execution

Example of Variables Declaration


If you found this helpful, please consider supporting with a small donation. Thank you!

Posted in

One response to “How to Declare Variables in TIA Portal”

Leave a Reply

Discover more from PLC Steps - Your Guide to Industrial Automation

Subscribe now to keep reading and get access to the full archive.

Continue reading