Why use Methods?

Methods help organize large UDFBs into logical units of functionality.

For example, a machine controller UDFB might contain methods for:

  • Validating operator inputs.
  • Calculating motion profiles.
  • Checking safety conditions.
  • Detecting faults.
  • Generating alarms.

Instead of implementing all functionality in a single code block, each operation can be isolated within a dedicated method.

With Methods

UDFB can be organized into methods such as:

  • ValidateInputs()
  • CalculateTrajectory()
  • MonitorSafetyConditions()
  • GenerateDiagnostics()
  • ResetFaults()

Each method performs a specific task while keeping the main UDFB implementation concise, easy to understand and simplifies future maintenance.

Without Methods

A UDFB can contain hundreds or thousands of lines of code with logic for:

  • Input validation.
  • Motion calculations.
  • Fault detection.
  • State transitions.
  • Diagnostic collection.

All logic resides in a single implementation body, making maintenance more difficult.

See Also