Memory usage for user-defined functions

To consume less memory in the
Micro800
controller, use a user-defined function (UDF) instead of a user-defined function block (UDFB) whenever possible.
Differences between UDF and UDFB when executing simple calculations
Calculation
UDF
UDFB
UDF Advantages
UDF Disadvantages
Execute once:
C = A + B
  • Program: 548 bytes
  • Data: 36 bytes
  • Total: 584 bytes
  • Program: 612 bytes
  • Data: 208 bytes
  • Total: 820 bytes
  • one instance
Memory usage:
236 bytes less (28.78% less memory) than UDFB
The output parameter name is less flexible because the parameter name must be the same as the UDF name.
Execute twice:
C
x
= A
x
+ B
x
  • Program: 620 bytes
  • Data:40 bytes
  • Total: 660 bytes
  • Program: 688 bytes
  • Data: 356 bytes
  • Total: 1044 bytes
  • Two instances
Memory usage:
384 bytes less (36.78% less memory) than UDFB
UDF can only monitor local variables for the last execution of the UDF.
UDFB can monitor local variables for both instances.

Memory consumption comparison between UDF and UDFB

Baseline: Empty project
Baseline: Empty project
UDF single execution main program
UDF single execution main program
UDF definition
UDF definition
Controller memory after a single execution of the UDF
Controller memory after a single execution of the UDF
UDFB single execution main program
UDFB single execution main program
UDFB definition
UDFB definition
Controller memory after a single execution of the UDFB
Controller memory after a single execution of the UDFB
Controller memory after executing the UDF twice
Controller memory after executing the UDF twice
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal