FUNCTION or FUNCTION_BLOCK(AC 500)
I am writing a program for HVAC system. my program have 3 mode that they are cooling, heating and auto. Now i dont know i should write this subroutins in FUNCTION or FUNCTION_BLOCK?
both of my subroutin have input, output, analog value, timer, ...
please help me
It's really easy - if You subroutine uses a timer or any kind of "memory", You need to use Function Block.
The definitions according to IEC 61131-3 are:
Function is a program organisation unit that can be assigned parameters, but has no static variables (os it is without memory), which, when invoked with the same input parameters, always yields the same result as a function value (output).
Function Block on the other hand HAS static variables (so it has memory, like a counter or timer). When invoked with the same input parameters, will yield values which are also depend on state of internal and external variables (which are retained from one execution of the function block to next).
Hope this clears things up,
Source: IEC 61131-3
Perhaps this will help you - for HVAC
HVAC specific Control and Calculation Blocks in libraries with documentation and example project.