what is (FBD) Function Block Diagram?

Function Block Diagram (FBD) is a graphical programming language for expressing logic, calculations and block calls in PLC programs. It is included in IEC 61131-3:2025. During PLC programming, it helps show how information passes through operations to produce a result. FBD represents executable program logic, rather than merely a drawing or an electrical wiring diagram.
What do blocks and connections represent? Boxes represent operations or block calls; connections show values passing between those operations. A value can come from a sensor, a constant, an intermediate variable or another block's result. A line need not represent a physical wire, and a box need not represent a separate hardware module.
Program variables and field channels: A signal read from the field must be mapped to the appropriate input/output module channel. A result that controls a physical output must be assigned to the relevant output variable and channel. With remote I/O, consider communication status too. Correct program connections and correct field connections are both needed. An output variable being TRUE does not, by itself, confirm that the equipment is operating.
Why do data types matter? Data types determine what kind of information a connection carries. BOOL represents a true/false state, INT an integer, REAL a decimal value and TIME a duration. Make appropriate conversions explicitly when needed. A correctly typed value can still produce the wrong result if its units or scaling are wrong.
Common operations: AND, OR and NOT express logical conditions; ADD and MUL perform calculations; GT and GE perform comparisons. Appropriate blocks can handle timing, counting and PID control. Choose a block according to the required behaviour. Similar-looking blocks may have different inputs, reset rules or operating conditions.
When does an FBD program calculate its results? The CPU executes the program according to its assigned task. In cyclic tasks, task scheduling and the order of networks and block calls affect the result. Read data flow together with execution order. An input changing does not mean every block and physical output updates simultaneously.
Functions and function blocks: A function produces a calculation result; the standard function model does not keep internal state between calls. A function block such as TON can keep timing state in its own instance. This distinction matters when creating user-defined functions and blocks. FBD can represent both operations and calls to blocks that hold state.
Independent jobs need independent instances: To give two indicators separate delays, use two TON instances, such as Indicator1Delay and Indicator2Delay. Calling the same instance with different conditions affects the same internal state. Reusing a block type differs from calling the same block instance again.
A short FBD example — AND and TON: Connect ButtonHeld and IndicatorEnabled to AND inputs. Connect its result to TON's IN, and T#2s to PT. Assign TON's Q output to IndicatorRequest. The example produces an indicator request.
How the example behaves: With both conditions continuously TRUE, Q becomes TRUE when TON is processed after the two-second delay. ET shows elapsed time. When either condition becomes FALSE and the block is processed, Q becomes FALSE and timing resets. Task intervals also affect the observed response.
Call the timer regularly: In this cyclic example, call TON on each relevant task cycle and pass condition changes through IN. Assigning a new input value does not itself execute the block. If a block call is skipped, its output can remain at the last calculated value.
Level and edge are different: A button remaining TRUE presents the condition on every cycle. To act only on a FALSE-to-TRUE transition, use rising-edge detection. “Still held” and “just pressed” are different information. The AND–TON example measures how long the conditions remain continuously true.
Analogue processing and PID: In PID control with a PLC, FBD can show measurement scaling, limiting and controller connections. Define measurement units, setpoint, control direction and sampling time correctly. Adding a PID block to a diagram does not automatically tune the process correctly.
FBD advantages: Small, clearly separated networks make conditions, intermediate results and data flow easier to follow. Library blocks and user-defined blocks can be reused. Meaningful status variables for an HMI or SCADA system can also help maintenance. These benefits depend on clear variable names and an organised program structure.
FBD limitations: Too many connections, large networks and nested conditions can reduce readability. A graphical language does not remove the need for training or verification. Incorrect logic, data types, execution order and block parameters can still cause errors. FBD is not necessarily faster to write or less error-prone in every application.
Choosing FBD, Ladder, ST or SFC: Ladder can suit contact and coil logic; Structured Text can suit intensive calculations and loops; SFC can organise steps and transitions. Choose programming languages around the application and maintenance team's needs. FBD is particularly useful for showing data relationships between blocks. Where supported, different languages can be used in different parts of the same project.
Software and CPU support: When assessing FBD in an environment such as CODESYS, check the target CPU, libraries and programming software version. Block names, parameters and project structures can vary between manufacturers. Check compatibility after PLCopen XML transfers too. A similar-looking diagram does not establish that a project will run directly on another PLC.
What should you monitor while debugging? During debugging, examine input values, intermediate conditions, block parameters and outputs together. In the example, check IN, PT, ET and Q. Test what happens when a condition is lost and restored. Compare program results with actual field conditions and channel mapping.
Safety applications: Machine safety requires suitable hardware, a suitable software environment and validated safety functions together. Assess a safety relay or safety PLC according to the application. Using FBD alone does not determine safety suitability. Adding an emergency-stop condition to a standard FBD network does not automatically create a safety function.