RS (FB) ¶ FUNCTION_BLOCK RS Realizes a bistable reset-dominat latch (* Example declaration *) RSInst : RS ; (* Example in ST *) RSInst ( SET := VarBOOL1 , RESET1 := VarBOOL2 ); VarBOOL3 := RSInst.Q1 ; InOut: Scope Name Type Comment Input SET BOOL Rising edge: Set Q1 to TRUE RESET1 BOOL Rising edge: Reset Q1 to FALSE (dominant) Output Q1 BOOL Output value
SR (FB) ¶ FUNCTION_BLOCK SR Realizes a bistable set-dominat latch (* Example declaration *) SRInst : SR ; (* Example in ST *) SRInst ( SET1 := VarBOOL1 , RESET := VarBOOL2 ); VarBOOL3 := SRInst.Q1 ; InOut: Scope Name Type Comment Input SET1 BOOL Rising edge: Set Q1 to TRUE (dominant) RESET BOOL Rising edge: Reset Q1 to FALSE Output Q1 BOOL Output value
Counter ¶ CTD (FunctionBlock) CTU (FunctionBlock) CTUD (FunctionBlock)
CTD (FB) ¶ FUNCTION_BLOCK CTD Decrements a given value (* Example declaration *) CTDInst : CTD ; (* Example in ST *) CTDInst ( CD := VarBOOL1 , LOAD := VarBOOL2 , PV := VarWORD1 ); VarBOOL3 := CTDInst.Q ; VarWORD2 := CTDInst.CV ; InOut: Scope Name Type Comment Input CD BOOL Rising edge: Decrementing CV by one LOAD BOOL TRUE : Set CV to the start value PV PV WORD Start value for decrementing Output Q BOOL TRUE if CV = 0 CV WORD Current counter value
CTU (FB) ¶ FUNCTION_BLOCK CTU Increments a given value (* Example declaration *) CTUInst : CTU ; (* Example in ST *) CTUInst ( CU := VarBOOL1 , RESET := VarBOOL2 , PV := VarWORD1 ); VarBOOL3 := CTUInst.Q ; VarWORD2 := CTUInst.CV ; InOut: Scope Name Type Comment Input CU BOOL Rising edge: Incrementing CV by one RESET BOOL TRUE : Reset CV to 0 PV WORD Upper limit for incrementing Output Q BOOL TRUE if CV >= PV CV WORD Current counter value
CTUD (FB) ¶ FUNCTION_BLOCK CTUD Increments and decrements a given value Note Datatype WORD , which is used for PV in CODESYS, does not match the IEC standard, which for PV defines datatype INT . (* Example declaration *) CTUDInst : CUTD ; (* Example in ST *) CTUDInst ( CU := VarBOOL1 , CD := VarBOOL2 , RESET := VarBOOL3 , LOAD := VarBOOL4 , PV := VarWORD1 ); VarBOOL5 := CTUDInst.QU ; VarBOOL6 := CTUDInst.QD ; VarWORD2 := CTUDInst.CV ; InOut: Scope Name Type Comment Input CU BOOL Rising edge: Incrementing CV by one CD BOOL Rising edge: Decrementing CV by one RESET BOOL TRUE : Reset CV to 0 LOAD BOOL TRUE : Set CV to the start value PV PV WORD Start value for decrementing / upper limit for incrementing Output QU BOOL TRUE if CV >= PV QD BOOL TRUE if CV = 0 CV WORD Current counter value
Miscellaneous ¶ RTC (FunctionBlock)
RTC (FB) ¶ FUNCTION_BLOCK RTC Calculates the elapsed time since a given start time Usage Examples: This function block can be used as an operation hour counter, when PDT is set to DT#1970-01-01-00-00:00 , or is simply not connected. This function block can be used to return the current date and time, by adjusting the FB to the current local time. Just, set the input PDT to the current local time, on the rising edge of EN . Note This counter will have an overflow at the 7th February, 2106. (* Example in ST *) RTC ( EN := VarBOOL1 , PDT := DT#2006-03-30-14:00:00 , Q => VarBOOL2 , CDT => VarTimeCur ); InOut: Scope Name Type Comment Input EN BOOL Rising edge: CDT is set to PDT and CDT starts increasing. Falling edge: CDT is set to DT#1970-01-01-00:00:00 . PDT DT Preset date and time Output Q BOOL TRUE as long as CDT is counting CDT DT Date and time, elapsed since PDT
String Functions ¶ CONCAT (Function) DELETE (Function) FIND (Function) INSERT (Function) LEFT (Function) LEN (Function) MID (Function) REPLACE (Function) RIGHT (Function)
CONCAT (FUN) ¶ FUNCTION CONCAT : STRING(255) Concatenates two strings CONCAT(STR1,STR2) means: Connect STR1 and STR2 to a single string STR1STR2 . (* Example declaration *) VarSTRING1 : STRING ; (* Example in ST , result is 'SUSIWILLI' *) VarSTRING1 := CONCAT ( 'SUSI' , 'WILLI' ); InOut: Scope Name Type Comment Return CONCAT STRING(255) Concatenated string, max. 255 characters. If the result doesn’t fit into these 255 bytes, it will be silently truncated. No error is produced. Input STR1 STRING(255) String 1 to be concatenated, max. 255 characters STR2 STRING(255) String 2 to be concatenated, max. 255 characters