LEFT (FUN) ¶ FUNCTION LEFT : STRING(255) Returns a specific number of characters of a string, starting from left LEFT (STR, SIZE) means: Return the first SIZE characters from the left in string STR (* Example declaration *) VarSTRING1 : STRING ; (* Example in ST , result is 'SUS' *) VarSTRING1 := LEFT ( 'SUSI' , 3 ); InOut: Scope Name Type Comment Return LEFT STRING(255) Resulting string Input STR STRING(255) String to be analyzed SIZE INT Number of characters
LEN (FUN) ¶ FUNCTION LEN : INT Returns the number of characters of a string (* Example declaration *) VarINT1 : INT ; (* Example in ST , result is '4 *) VarINT1 := LEN ( 'SUSI' ); InOut: Scope Name Type Comment Return LEN INT Length of string STR Input STR STRING(255) String to be analyzed
MID (FUN) ¶ FUNCTION MID : STRING(255) Returns a specific number of characters of a string, starting from a specific position MID (STR, LEN, POS) means: Retrieve LEN characters from the STR string beginning with the character at position POS . (* Example declaration *) VarSTRING1 : STRING ; (* Example in ST , result is 'US' *) VarSTRING1 := MID ( 'SUSI' , 2 , 2 ); InOut: Scope Name Type Comment Return MID STRING(255) Partial string of STR Input STR STRING(255) String to be analyzed LEN INT Number of characters, counted from the left POS INT Start position for the partial string
REPLACE (FUN) ¶ FUNCTION REPLACE : STRING(255) Replaces a specific number of characters of a string by another string REPLACE(STR1, STR2, L, P) means: Replace L characters from STR1 by STR2 , beginning with the character in the P position. POS = 0 or POS = 1 , are both addressing the first character. Note The current implementation is unfortunately not correct for the case P=0 . The implementation cannot be changed for compatibility reasons. If P=0 is used, the parameter L is internally reduced by one! It is generally recommended to use values in the range specified by IEC 61131-3. The smallest value for P is specified there as 1 . (* Example declaration *) VarSTRING1 : STRING ; (* Example in ST , result is 'SKYSI' *) VarSTRING1 := REPLACE ( 'SUXYSI' , 'K' , 2 , 2 ); InOut: Scope Name Type Comment Return REPLACE STRING(255) Resulting string Input STR1 STRING(255) String of which a part is replaced STR2 STRING(255) String which replaces a part of STR1 L INT Number of characters, counting from left P INT Start position of the characters to be replaced. P = 1 or P = 0 are both addressing the first character
RIGHT (FUN) ¶ FUNCTION RIGHT : STRING(255) Returns a specific number of characters of a string, starting from right RIGHT (STR, SIZE) means: Return the first SIZE characters from the right in string STR (* Example declaration *) VarSTRING1 : STRING ; (* Example in ST , result is 'USI' *) VarSTRING1 := RIGHT ( 'SUSI' , 3 ); InOut: Scope Name Type Comment Return RIGHT STRING(255) Resulting string Input STR STRING(255) String to be analyzed SIZE INT Number of characters
Timer ¶ TOF (FunctionBlock) TON (FunctionBlock) TP (FunctionBlock)
TOF (FB) ¶ FUNCTION_BLOCK TOF Implements a timer with a turn-off delay (* Example declaration *) TOFInst : TOF ; (* Example in ST *) TOFInst ( IN := VarBOOL1 , PT := T#5s ); VarBOOL2 := TOFInst.Q ; InOut: Scope Name Type Comment Input IN BOOL Falling edge: starts delay counter Rising edge: resets delay counter PT TIME Time for the delay counter [ms] Output Q BOOL TRUE if IN is TRUE FALSE if IN is FALSE and delay time PT elapsed ET TIME Elapsed time since falling edge at IN
TON (FB) ¶ FUNCTION_BLOCK TON Implements a timer with a turn-on delay (* Example declaration *) TONInst : TON ; (* Example in ST *) TONInst ( IN := VarBOOL1 , PT := T#5s ); VarBOOL2 := TONInst.Q ; InOut: Scope Name Type Comment Input IN BOOL Rising edge: starts delay counter Falling edge: resets delay counter PT TIME Time for the delay counter [ms] Output Q BOOL FALSE if IN is FALSE TRUE if IN is TRUE and delay time PT elapsed ET TIME Elapsed time since rising edge at IN
TP (FB) ¶ FUNCTION_BLOCK TP Implements a pulse timer (* Example declaration *) TPInst : TP ; (* Example in ST *) TPInst ( IN := VarBOOL1 , PT := T#5s ); VarBOOL2 := TPInst.Q ; InOut: Scope Name Type Comment Input IN BOOL Rising edge starts the pulse timer and sets Q to TRUE PT TIME Length of the pulse (high-signal) Output Q BOOL Pulse signal, set to TRUE for PT milliseconds if EN has a rising edge ET TIME Elapsed time since pulse timer started. It will then remain constant after PT is reached.
Trigger ¶ F_TRIG (FunctionBlock) R_TRIG (FunctionBlock)