S7 functions

I wonder if somebody could explain to me the difference between function blocks and function calls.

Thanks

Reply to
Bob Watkinson
Loading thread data ...

formatting link
?q=function+calls Jerry

Reply to
Jerry Avins

Kinda hoping for a short definative reply rather than having to trawl through 26 million or so pages looking for a difference. Thanks anyway. ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

Reply to
Bob Watkinson

formatting link
formatting link
C++:
formatting link
Jerry

Reply to
Jerry Avins

A S7 or PLC Open function has no state. It uses only the parameters. For instance, a sine or cosine function only care about the angle. When implemented all the parameters are pushed on the stack and a value is returned in the accumulator or stored using a pointer. However, all the data that is pushed on the stack is "popped" off so the function starts with all new parameters the next time it is executed.

A S7 or PLC Open function block has state. A PID would be a function block because it must keep track of the errors and integrator state. This means that each instance of a FB must be declared or allocated in some way because each instance of a FB has it's own copy of "static" variables to hold the state. In the case of a PID, each PID would need to keep track of its own integrator and error history.

A function block is like a C function with a pointer to static variables.

Peter Nachtwey

Reply to
Peter Nachtwey

thanks Peter

Reply to
Bob Watkinson

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.