User:KempJ/IEC 61131-3

This page will contain assorted parts of the main IEC_61131-3 page as I work on them

Data types
A range of data types, referred to as elementary data types, are defined within IEC 1131-3. These can form the basis of user-defined data types, referred to as derived data types.

Elementary data types
Elementary data types are classified as bit strings, integers, real numbers, times, and dates/times of day.

Bit Strings represent groups of on/off values.

Integers represent whole numbers. The table below lists signed integer types only, the equivalent unsigned types have a U prefixed to the name.

Real numbers represent floating point numbers in IEC 60559 format, which is the same as IEEE 754-2008.

Time values (the TIME data type) represent a duration, for example for use with calculations related to timers.

Date and time of day values represent a specific moment in time. The data types in this category are DATE, TIME_OF_DAY, and DATE_AND_TIME (which is a combination of the previous two).

Strings contain character strings and are typed as literals by surrounding the value with single quotes. Escaped characters are preceded by a dollar sign (see the Escape sequences table to the right). There are two types of string available: STRING and WSTRING for single-byte and multi-byte character strings respectively.


 * Arrays - multiple values stored in the same variable.
 * Sub Ranges - puts limits on value i.e., (4-20) for current

Derived data types
Type derived from one of the above types.
 * TYPE - single type
 * STRUCT - composite of several variables and types.

Data type hierarchy
A series of generic data types form a hierarchy in which the elementary and derived types are placed. These generic data types may be used in the specification of inputs and outputs for standard functions and function blocks. They cannot be used in user-declared POUs. The purpose of these data types is to allow a function to accept a set of related data types if there is no need for a specific type. For example, the SHR function will accept any of the data types below ANY_BIT in the hierarchy for its IN parameter.
 * ANY
 * ANY_DERIVED
 * ANY_ELEMENTARY
 * ANY_MAGNITUDE
 * ANY_NUM
 * ANY_REAL
 * REAL, LREAL
 * ANY_INT
 * SINT, INT, DINT, LINT, USINT, UINT, UDINT, ULINT
 * TIME
 * ANY_BIT
 * BOOL, BYTE, WORD, DWORD, LWORD
 * ANY_STRING
 * STRING, WSTRING
 * ANY_DATE
 * DATE_AND_TIME (DT), DATE, TIME_OF_DAY (TOD)