Please obtain a detailed description of usage from the appropriate appendices concerning IEC operators.
Operators in CODESYS:
| 
                                  in ST  | 
                              
                                  in AWL  | 
                              
                                  Mod. AWL  | 
                              
                                  Description  | 
                           
|---|---|---|---|
| 
                                  '  | 
                              
                                  
  | 
                              
                                  
  | 
                              
                                  String delimiters (e.g. 'string1')  | 
                           
| 
                                  .. [ ]  | 
                              
                                  
  | 
                              
                                  
  | 
                              
                                  Size of Array range (e.g. ARRAY[0..3] OF INT)  | 
                           
| 
                                  :  | 
                              
                                  
  | 
                              
                                  
  | 
                              
                                  Delimiter between Operand and Type in a declaration (e.g. var1 : INT;)  | 
                           
| 
                                  ;  | 
                              
                                  
  | 
                              
                                  
  | 
                              
                                  Termination of instruction (e.g. a:=var1;)  | 
                           
| 
                                  ^  | 
                              
                                  
  | 
                              
                                  
  | 
                              
                                  Dereferenced Pointer (e.g. pointer1^)  | 
                           
| 
                                  
  | 
                              
                                  LD var1  | 
                              
                                  N  | 
                              
                                  Load value of var1 in buffer  | 
                           
| 
                                  :=  | 
                              
                                  ST var1  | 
                              
                                  N  | 
                              
                                  Store actual result to var1  | 
                           
| 
                                  
  | 
                              
                                  S boolvar  | 
                              
                                  
  | 
                              
                                  Set boolean operand boolvar exactly then to TRUE, when the actual result is TRUE  | 
                           
| 
                                  
  | 
                              
                                  R boolvar  | 
                              
                                  
  | 
                              
                                  Set boolean operand boolvar exactly then to FALSE, when the actual result is TRUE 
  | 
                           
| 
                                  in ST  | 
                              
                                  in AWL  | 
                              
                                  Mod. AWL  | 
                              
                                  Description  | 
                           
|---|---|---|---|
| 
                                  
  | 
                              
                                  JMP label  | 
                              
                                  CN  | 
                              
                                  Jump to label  | 
                           
| 
                                  <Program name>  | 
                              
                                  CAL prog1  | 
                              
                                  CN  | 
                              
                                  Call program prog1  | 
                           
| 
                                  <Instance name>  | 
                              
                                  CAL inst1  | 
                              
                                  CN  | 
                              
                                  Call function block instance inst1  | 
                           
| 
                                  <Fctname>(vx, vy,..)  | 
                              
                                  <Fctname> vx, vy  | 
                              
                                  CN  | 
                              
                                  Call function fctname and transmit variables vx, vy  | 
                           
| 
                                  RETURN  | 
                              
                                  RET  | 
                              
                                  CN  | 
                              
                                  Leave POU and go back to caller  | 
                           
| 
                                  
  | 
                              
                                  (  | 
                              
                                  
  | 
                              
                                  The value following the bracket is handled as operand, the operation before the bracket is not executed before the expression in the brackets.  | 
                           
| 
                                  
  | 
                              
                                  )  | 
                              
                                  
  | 
                              
                                  Now execute the operation which has been set back  | 
                           
| 
                                  AND  | 
                              
                                  AND  | 
                              
                                  N,(  | 
                              
                                  Bitwise AND  | 
                           
| 
                                  OR  | 
                              
                                  OR  | 
                              
                                  N,(  | 
                              
                                  Bitwise OR  | 
                           
| 
                                  XOR  | 
                              
                                  XOR  | 
                              
                                  N,(  | 
                              
                                  Bitwise exclusive OR  | 
                           
| 
                                  NOT  | 
                              
                                  NOT  | 
                              
                                  
  | 
                              
                                  Bitweise NOT  | 
                           
| 
                                  +  | 
                              
                                  ADD  | 
                              
                                  (  | 
                              
                                  Addition  | 
                           
| 
                                  -  | 
                              
                                  SUB  | 
                              
                                  (  | 
                              
                                  Subtraction  | 
                           
| 
                                  *  | 
                              
                                  MUL  | 
                              
                                  (  | 
                              
                                  Multiplication  | 
                           
| 
                                  /  | 
                              
                                  DIV  | 
                              
                                  (  | 
                              
                                  Division  | 
                           
| 
                                  >  | 
                              
                                  GT  | 
                              
                                  (  | 
                              
                                  Greater than  | 
                           
| 
                                  >=  | 
                              
                                  GE  | 
                              
                                  (  | 
                              
                                  Greater or equal  | 
                           
| 
                                  =  | 
                              
                                  EQ  | 
                              
                                  (  | 
                              
                                  Equal  | 
                           
| 
                                  <>  | 
                              
                                  NE  | 
                              
                                  (  | 
                              
                                  Not equal  | 
                           
| 
                                  <=  | 
                              
                                  LE  | 
                              
                                  (  | 
                              
                                  Less or equal  | 
                           
| 
                                  <  | 
                              
                                  LT  | 
                              
                                  (  | 
                              
                                  Less than  | 
                           
| 
                                  MOD(in)  | 
                              
                                  MOD  | 
                              
                                  
  | 
                              
                                  Modulo Division  | 
                           
| 
                                  INDEXOF(in)  | 
                              
                                  INDEXOF  | 
                              
                                  
  | 
                              
                                  Internal index of POU in1; [INT]  | 
                           
| 
                                  SIZEOF(in)  | 
                              
                                  SIZEOF  | 
                              
                                  
  | 
                              
                                  Number of bytes required for the given data type of in  | 
                           
| 
                                  SHL(K,in)  | 
                              
                                  SHL  | 
                              
                                  
  | 
                              
                                  Bitwise left-shift of operator in by K  | 
                           
| 
                                  SHR(K,in)  | 
                              
                                  SHR  | 
                              
                                  
  | 
                              
                                  Bitwise right-shift of operator in by K  | 
                           
| 
                                  ROL(K,in)  | 
                              
                                  ROL  | 
                              
                                  
  | 
                              
                                  Bitwise rotation to the left of operator in by K  | 
                           
| 
                                  ROR(K,in)  | 
                              
                                  ROR  | 
                              
                                  
  | 
                              
                                  Bitwise rotation to the right of operator in by K  | 
                           
| 
                                  SEL(G,in0,in1)  | 
                              
                                  SEL  | 
                              
                                  
  | 
                              
                                  Binary selection between 2 operands in0 (G is FALSE) and in1 (G is TRUE)  | 
                           
| 
                                  MAX(in0,in1)  | 
                              
                                  MAX  | 
                              
                                  
  | 
                              
                                  Returns the greater of 2 values  | 
                           
| 
                                  MIN(in0,in1) 
  | 
                              
                                  MIN  | 
                              
                                  
  | 
                              
                                  Returns the lesser of 2 values in0 and in1  | 
                           
| 
                                  LIMIT(MIN,in,Max)  | 
                              
                                  LIMIT  | 
                              
                                  
  | 
                              
                                  Limits the range of values (in is set back to MIN or MAX in case of exceeding the range) 
  | 
                           
| 
                                  in ST  | 
                              
                                  in AWL  | 
                              
                                  Mod. AWL  | 
                              
                                  Description  | 
                           
|---|---|---|---|
| 
                                  MUX(K,in0,...in_n)  | 
                              
                                  MUX  | 
                              
                                  
  | 
                              
                                  Selecti the Kth value out of a group of values (in0 to In_n)  | 
                           
| 
                                  ADR(in)  | 
                              
                                  ADR  | 
                              
                                  
  | 
                              
                                  Address of the operand in [DWORD]  | 
                           
| 
                                  ADRINST()  | 
                              
                                  ADRINST() 
  | 
                              
                                  
  | 
                              
                                  Address of the function block instance from which you are calling that operator.  | 
                           
| 
                                  BITADR(in)  | 
                              
                                  BITADR  | 
                              
                                  
  | 
                              
                                  Bitoffset of the operand in [DWORD]  | 
                           
| 
                                  BOOL_TO_<type>(in)  | 
                              
                                  BOOL_TO_<type>  | 
                              
                                  
  | 
                              
                                  Type conversion of the boolean operand  | 
                           
| 
                                  <type>_TO_BOOL(in)  | 
                              
                                  <type>_TO_BOOL  | 
                              
                                  
  | 
                              
                                  Type conversion to BOOL  | 
                           
| 
                                  INT_TO_<type>(in)  | 
                              
                                  INT_TO_<type>  | 
                              
                                  
  | 
                              
                                  Type conversion of an INT Operand to another elementary type  | 
                           
| 
                                  REAL_TO_<type>(in)  | 
                              
                                  REAL_TO_<type>  | 
                              
                                  
  | 
                              
                                  Type conversion of an REAL operand to another elementary type  | 
                           
| 
                                  LREAL_TO_<type>(in)  | 
                              
                                  LREAL_TO_<type>  | 
                              
                                  
  | 
                              
                                  Type conversion of a LREAL operand to another elementary type  | 
                           
| 
                                  TIME_TO_<type>(in)  | 
                              
                                  TIME_TO_<type>  | 
                              
                                  
  | 
                              
                                  Type conversion of a TIME operand to another elementary type  | 
                           
| 
                                  TOD_TO_<type>(in)  | 
                              
                                  TOD_TO__<type>  | 
                              
                                  
  | 
                              
                                  Type conversion of a TOD operand to another elementary type  | 
                           
| 
                                  DATE_TO_<type>(in)  | 
                              
                                  DATE_TO_<type>  | 
                              
                                  
  | 
                              
                                  Type conversion of a DATE operand to another elementary type  | 
                           
| 
                                  DT_TO_<type>(in)  | 
                              
                                  DT_TO_<type>  | 
                              
                                  
  | 
                              
                                  Type conversion of a DT operand to another elementary type  | 
                           
| 
                                  STRING_TO_<type>(in)  | 
                              
                                  STRING_TO_<type>  | 
                              
                                  
  | 
                              
                                  Type conversion of a string operand to another elementary type, in must contain valid value of desired type  | 
                           
| 
                                  TRUNC(in)  | 
                              
                                  TRUNC  | 
                              
                                  
  | 
                              
                                  Conversion from REAL to INT  | 
                           
| 
                                  ABS(in)  | 
                              
                                  ABS  | 
                              
                                  
  | 
                              
                                  Absolute value of operand in  | 
                           
| 
                                  SQRT(in)  | 
                              
                                  SQRT  | 
                              
                                  
  | 
                              
                                  Square root of operand in  | 
                           
| 
                                  LN(in)  | 
                              
                                  LN  | 
                              
                                  
  | 
                              
                                  Natural logarithm of operand in  | 
                           
| 
                                  LOG(in)  | 
                              
                                  LOG  | 
                              
                                  
  | 
                              
                                  Logarithm of operand in, base 10  | 
                           
| 
                                  EXP(in)  | 
                              
                                  EXP  | 
                              
                                  
  | 
                              
                                  Exponential function of operand in  | 
                           
| 
                                  SIN(in)  | 
                              
                                  SIN  | 
                              
                                  
  | 
                              
                                  Sine of operand in  | 
                           
| 
                                  COS(in)  | 
                              
                                  COS  | 
                              
                                  
  | 
                              
                                  Cosine of operand in  | 
                           
| 
                                  TAN(in)  | 
                              
                                  TAN  | 
                              
                                  
  | 
                              
                                  Tangent of operand in  | 
                           
| 
                                  ASIN(in)  | 
                              
                                  ASIN  | 
                              
                                  
  | 
                              
                                  Arc sine of operand in  | 
                           
| 
                                  ACOS(in)  | 
                              
                                  ACOS  | 
                              
                                  
  | 
                              
                                  Arc cosine of operand in  | 
                           
| 
                                  ATAN(in)  | 
                              
                                  ATAN  | 
                              
                                  
  | 
                              
                                  Arc tangent of operand in  | 
                           
| 
                                  EXPT(in,expt)  | 
                              
                                  EXPT expt  | 
                              
                                  
  | 
                              
                                  Exponentation of operand in with expt  | 
                           
Elements of the standard library
| 
                                  Structured Text  | 
                              
                                  Description  | 
                           
|---|---|
| 
                                  LEN(in)  | 
                              
                                  String length of operand in  | 
                           
| 
                                  LEFT(str,size)  | 
                              
                                  Left inital string of given size of string str  | 
                           
| 
                                  RIGHT(str,size)  | 
                              
                                  Right initial string of given size of string str  | 
                           
| 
                                  MID(str,size,pos)  | 
                              
                                  Partial string of str of given size at position pos  | 
                           
| 
                                  CONCAT('str1','str2')  | 
                              
                                  Concatenation of two subsequent strings  | 
                           
| 
                                  INSERT('str1','str2',pos)  | 
                              
                                  Insert string str1 in string str2 at position pos  | 
                           
| 
                                  DELETE('str1',len,pos)  | 
                              
                                  Delete partial string (length len), start at position pos of str1  | 
                           
| 
                                  REPLACE('str1','str2',len,pos)  | 
                              
                                  Replace partial string of lenght len by str2, start at position pos of str1  | 
                           
| 
                                  FIND('str1','str2')  | 
                              
                                  Search for partial string str2 in str1  | 
                           
| 
                                  SR  | 
                              
                                  Bistable function block is set dominant  | 
                           
| 
                                  RS  | 
                              
                                  Bistable function block is set back  | 
                           
| 
                                  SEMA  | 
                              
                                  FB: Software Semaphor (interruptable)  | 
                           
| 
                                  R_TRIG  | 
                              
                                  FB: rising edge is detected  | 
                           
| 
                                  F_TRIG  | 
                              
                                  FB: falling edge is detected  | 
                           
| 
                                  CTU  | 
                              
                                  FB: Counts upv  | 
                           
| 
                                  CTD  | 
                              
                                  FB: Count down  | 
                           
| 
                                  CTUD  | 
                              
                                  FB: Up/down counter  | 
                           
| 
                                  TP  | 
                              
                                  FB: trigger  | 
                           
| 
                                  TON  | 
                              
                                  FB: on delay timer  | 
                           
| 
                                  TOF  | 
                              
                                  FB: off delay timer  | 
                           
| 
                                  RTC  | 
                              
                                  FB: real-time clock  | 
                           
Elements of the util library
| 
                                  Element  | 
                              
                                  Description  | 
                           
|---|---|
| 
                                  BCD_TO_INT  | 
                              
                                  Conversion of a byte: BCD to INT format  | 
                           
| 
                                  INT_TO_BCD  | 
                              
                                  Converstion of a byte: INT to BCD format  | 
                           
| 
                                  EXTRACT(in,n)  | 
                              
                                  The n-th bit of DWORD in is returned in BOOL  | 
                           
| 
                                  PACK  | 
                              
                                  Up to 8 bits are packed into a byte  | 
                           
| 
                                  PUTBIT  | 
                              
                                  A bit of a DWORD is set to a certain value  | 
                           
| 
                                  UNPACK  | 
                              
                                  A byte is returned as single bits  | 
                           
| 
                                  DERIVATIVE  | 
                              
                                  Local derivation  | 
                           
| 
                                  INTEGRAL  | 
                              
                                  Integral  | 
                           
| 
                                  LIN_TRAFO  | 
                              
                                  Transformation of REAL values  | 
                           
| 
                                  STATISTICS_INT  | 
                              
                                  Min., max., average values in INT format  | 
                           
| 
                                  STATISTICS_REAL  | 
                              
                                  Min., max., average in REAL format  | 
                           
| 
                                  VARIANCE  | 
                              
                                  Variance  | 
                           
| 
                                  PD  | 
                              
                                  PD controller  | 
                           
| 
                                  PID  | 
                              
                                  PID controller  | 
                           
| 
                                  BLINK  | 
                              
                                  Pulsating signal  | 
                           
| 
                                  FREQ_MEASURE  | 
                              
                                  Measuring frequency of boolean input signal  | 
                           
| 
                                  GEN  | 
                              
                                  Periodic functions  | 
                           
| 
                                  CHARCURVE  | 
                              
                                  Linear functions  | 
                           
| 
                                  RAMP_INT  | 
                              
                                  Limiting ascendance of descendance of the function beeing fed (INT)  | 
                           
| 
                                  RAMP_REAL  | 
                              
                                  Limiting ascendance of descendance of the function beeing fed (REAL)  | 
                           
| 
                                  HYSTERESIS  | 
                              
                                  Hysteresis  | 
                           
| 
                                  LIMITALARM  | 
                              
                                  Watches whether input value exceeds limits of a defined range  |