Standard Functions Reference
IEC 61131-3 defines a comprehensive library of standard functions for type conversion, mathematical operations, string manipulation, and date/time handling essential for industrial automation applications.
🚀 Enhance Your Development Experience
Get syntax highlighting, IntelliSense, and debugging support for Structured Text:
Install VS Code Extension →Type Conversion Functions
Type Conversion Functions
⚠️ Conversion Safety Guidelines
- • Always validate string-to-number conversions for invalid input
- • Check for overflow when converting to smaller data types
- • Real-to-integer conversion truncates (doesn't round)
- • Use exception handling for string conversion errors
- • Consider locale settings for decimal point formatting
Mathematical Functions
Mathematical Functions
Basic Math Functions
- • ABS(x): Absolute value
- • SQRT(x): Square root
- • EXPT(x,y): x raised to power y
- • MOD(x,y): x modulo y
Trigonometric Functions
- • SIN/COS/TAN: Basic trig functions
- • ASIN/ACOS/ATAN: Inverse functions
- • Note: All angles in radians
- • π ≈ 3.14159265359
String Functions
String Manipulation Functions
String Analysis Functions
- • LEN(str): String length
- • FIND(str, sub): Find substring position
- • LEFT(str, n): First n characters
- • RIGHT(str, n): Last n characters
- • MID(str, pos, len): Substring
String Modification Functions
- • CONCAT(str1, str2): Join strings
- • INSERT(str, sub, pos): Insert substring
- • DELETE(str, pos, len): Remove characters
- • REPLACE(str, old, new, n): Replace substring
Date and Time Functions
Date and Time Functions
Date/Time Function Categories
Arithmetic Functions:
- • ADD_TIME: Add time durations
- • SUB_TIME: Subtract time durations
- • ADD_TIME_TO_DATE: Add time to date
- • SUB_DATE: Subtract dates
Combination Functions:
- • CONCAT_DATE_TOD: Combine date and time
- • SPLIT_DT: Split date/time
- • Various extractors: YEAR, MONTH, DAY, etc.
Practical Application Examples
Practical Applications of Standard Functions
🎯 Function Selection Guidelines
- • Type Conversion: Always validate inputs and handle errors gracefully
- • Mathematical: Consider precision requirements and valid input ranges
- • String Functions: Be aware of 1-based indexing and string length limits
- • Date/Time: Understand timezone handling and system clock synchronization
- • Performance: Cache results of expensive calculations when possible
- • Portability: Some advanced functions may be implementation-specific
