How-to
How CODESYS FBD accepts two box outputs on one box
Short answer
Yes, CODESYS FBD accepts two outputs from separate boxes on different inputs of one box, but the wiring order decides whether the editor takes the branch. Connect the second source to the destination first, attach the first source to the second source's second input connector until the plus sign appears, or assign the shared result to an intermediate variable and feed that variable to both inputs.
On this page
Two outputs from separate boxes can drive different inputs of one box in CODESYS FBD, and the fix is concrete: wire the second source box to the destination input first, then attach the first source box to the second source's second input connector and accept the branch when the editor shows the plus sign. If the editor still refuses, assign the shared result to a BOOL variable, for example some_output, and wire that variable to both destination inputs instead. For any box with two BOOL inputs, such as an AND function fed by two OR functions, this order decides whether the branch connects. It matters when the shared output depends on a long chain of logic you do not want to build twice.
The wiring order that works #
Work in this sequence inside the FBD editor:
- Place the destination function. The example uses an AND function as the box that consumes both sources; any function or function block with two inputs behaves the same way.
- Place the second source box (in that example, the second OR function) and connect its output to a destination input.
- Take the first source box (the first OR function) and connect it first to the second connector of the second source box. When CODESYS displays the plus sign, accept it, and the branch lands on the destination's other input as desired.
- Wire the shared variable, called some_output in the example, to both destination inputs so the same named signal feeds both.
The step that trips people up is the order. If you try to add a branch in front of a previous block, the editor will not create the connection, or it will only accept it through an intermediate variable. So never start from the first source; start from the second and grow the branch from there.
The intermediate-variable fallback #
When the direct branch will not connect, split the signal path at the block whose result you need twice:
- Assign that block's output to a named variable, for example a BOOL called tank_high_and_running for a high-level-and-running interlock.
- Wire that variable to both destination inputs.
- Keep the upstream logic untouched; nothing is duplicated and both inputs read the same evaluated value every scan.
This is also the honest answer to the original motivation: the whole point of the branch is to avoid repeating the logic that produces some_output, and a named variable achieves that with a clearer drawing than a forced graphical branch. For the same reason, keep signal flow visible and deterministic when you map inputs and outputs in CODESYS for ladder and structured text use; a named variable at a branch point is easier to trace than an unlabeled wire.
Ladder-to-FBD conversion when wiring stalls #
If the FBD editor will not take the layout you want, build the equivalent rung in ladder and convert. The conversion is instant with Ctrl+1 and Ctrl+2, so you can flip between representations and check whether the outcome matches the logic you intended. Reporters of this method note the converted FBD looks like a mix of FBD and ladder, which is CODESYS's own presentation of that branch; the logic is correct even when the drawing is not pretty. If you work in ladder daily, the same connection discipline applies when you connect a TON output to a function block input in TwinCAT ladder: wire from the destination side and let the editor offer the connector, rather than dragging a branch into place.
When to just use structured text #
If there is no requirement that the logic live in FBD, write it in structured text instead. Two source conditions feeding one destination is a single expression:
some_output := (cond_a OR cond_b);
interlock := some_output AND cond_c;
Here cond_a, cond_b and cond_c are example BOOL inputs declared in the POUs variable list, some_output and interlock are example BOOL results, and the test is trivial: force cond_c TRUE, pulse cond_a, and watch interlock follow some_output on the same scan. A name on the left of an assignment also forces you to think about whether the result is actually used, which avoids the classic structured-text trap where a function result is computed but never assigned and the output stays zero.
Which method to pick #
- Editing an existing FBD network: use the connection order above, second source first, plus sign to add the branch.
- Branch refused and you must stay graphical: assign the block result to an intermediate variable and wire it to both inputs.
- New logic, language not fixed: write it in structured text; it is shorter, reviewable as text, and conversion back to a graphical view costs one Ctrl shortcut if a colleague needs the drawing.
One safety note: whichever method you choose, the branch changes only the drawing, not the scan behaviour, so an existing interlock evaluated through this path keeps its timing. Verify on the bench with a forced input before trusting the redrawn network on a machine that runs.
For the underlying language rules that all three paths follow, IEC 61131-3 defines FBD as a graphical language in which you connect block outputs to block inputs; everything above is the CODESYS editor's particular way of accepting those connections.
Questions asked
Why does CODESYS FBD refuse a branch in front of an existing block?
The editor does not accept a branch placed before a previous block in the signal path; the connection simply cannot be made, or only through an intermediate variable. When a block result must feed two destinations, split it into two branches after the block, or assign the result to a variable and wire that variable to both destinations.
Which shortcut converts between ladder and FBD in CODESYS?
The conversion is instant with Ctrl+1 and Ctrl+2, so you can build the rung in ladder, press the shortcut, and immediately check whether the FBD presentation matches the logic. The notes do not establish which shortcut selects which representation, so confirm the mapping in your editor version with one throwaway rung before relying on it.
Is the intermediate-variable method safe for shared logic?
Yes. The variable holds one evaluated result, so both destination inputs see the same value every scan, and the upstream logic is not duplicated. During commissioning, force or monitor the variable once and confirm both consuming inputs change together; after that, treat the variable as the single source for that signal.