---
title: "LD, FBD, SFC and CFC diagrams"
---

# LD, FBD, SFC and CFC diagrams

Open the graphical bodies of TwinCAT POUs as diagrams, navigate them with the keyboard, see live values on operands, and make the edits the stored form supports.

**State:** TwinCAT modelled and kit shipped. The graphical bodies of TwinCAT POU files are read as stored, drawn and edited, checked on twelve bodies in nine real files written by TwinCAT 3.1.4019 to 4026, Linux only. No file edited in the diagram has been opened in XAE, and how XAE draws each network was not compared with this view.

Beckhoff does not document how these bodies are stored. Everything shown is what the real files hold; a node, member or language the reader does not know is kept as written and shown as not read.

## Open a diagram

In the text editor of a `.TcPOU` file with a graphical body, use the editor title button or the Command Palette: **Open as Diagram** (category Neural Inverse PLC), or Reopen Editor With > **Diagram**. **Open Diagram as Text** goes back.

Every graphical body of the file is shown in file order, for the POU itself and for its actions, methods and property accessors, each headed by its owner and language. The view follows the text model: an edit in the text editor shows in the diagram after 100 ms.

The outline and breadcrumbs of a TwinCAT object file opened as text also list each graphical body, its networks (with their title or comment), SFC steps, transitions, branches and jumps, and CFC boxes.

## What each language shows

| Language | Shown |
|---|---|
| Ladder (LD), network list (`<NWL>`, "Ld" view) and the ladder editor model of 3.1.4026 (`<LADDER>`) | Each network with its number, title, comment and label, marked when commented out; a rung between two power rails with contacts in series and parallel, coils and blocks (type, instance, inputs by name with what feeds them, outputs with the variables they write, EN and ENO); negated contacts and coils |
| Function block diagram (FBD) | Boxes with their named inputs, each fed by an operand or another box drawn to its left, and the variables the network assigns |
| Sequential function chart (SFC) | Steps from top to bottom (the initial one with a double border) with the actions they call (entry, main, exit) and their IEC action associations with qualifier; transitions with their condition; simultaneous (double bar) and alternative branches side by side; jumps with their target |
| Continuous function chart (CFC) | Inputs, outputs, boxes and comments at the grid positions TwinCAT stored; box pins named, negated and set/reset pins marked; connections along the routes TwinCAT stored, and those without a stored route drawn between the pins (dashed) |

Values whose meaning Beckhoff does not document are shown as stored, not interpreted: an operand's `Flags` number in the network list (`flags 1`) and a coil's `Storage` number in the 4026 ladder model (`storage 2`).

## Keyboard and screen readers

The diagram is a tree of items (bodies, networks, contacts, coils, boxes, operands, steps, transitions, branches, jumps, CFC elements), each with a label for screen readers. Up and Down (or Left and Right) move between them, Home and End go to the first and last, Enter or a double click opens the text with the item's XML selected.

## Structured Text inside the diagram

Every operand, contact and coil expression, transition condition, action association and CFC input, output and instance is a Structured Text region of the file. The [structure checks](https://neuralinverse.com/docs/modules/plc/structured-text/) report problems in them at their exact place in the XML. TwinCAT's placeholder for an operand not filled in (`???`) is not checked.

## Live values in the diagram

With **Show Live Values** on and the file in the PLC project the connected target runs (see [Live values in the code](https://neuralinverse.com/docs/modules/plc/live-values/)), each contact, coil, FBD operand and CFC input or output that is a plain variable (`bStart`, `MAIN.fbMotor.bReady`, no operator, index or call) shows its value after it. BOOL values are styled, stale values struck through, and the value is in the item's label and hover. Read only. SFC step states are not shown. Not verified in the diagram against a connected target: the resolution is tested against a symbol table only.

## Edit a diagram

Only edits that the stored form of the real files establishes are offered. Every other element is shown but not edited, and a refused edit says why in the status line.

| Key | Edit |
|---|---|
| F2 (Change Text) | Change the text of an operand, coil, box input or output, function block instance, SFC transition condition or action association, CFC input, output or box instance. One line, not empty |
| F2 on an SFC step | Rename the step with every jump to it and the transitions' variable names |
| Delete (Remove Network) | Remove a network, not the last one |
| Insert (Copy Network) | Copy a network of the network list after itself, with every id of the copy renumbered above the highest id of the body |
| Insert (Add Step After) | On an SFC step that a transition follows, add a transition and a step after it, with the condition and name you give |
| Alt+N (Negate Contact) | Negate or un-negate a contact of the 4026 ladder model |
| Alt+Arrow | Move a CFC element one grid cell; its stored routes are removed so XAE routes them again |
| Enter (Show in Text) | Show the item in the text |

Each edit is one undoable change of the file's text: Ctrl+Z and Ctrl+Y work in the diagram or the text editor, the tab shows the file as modified, and saving writes it. Only the stored values the edit changes are written; GUIDs, ids and every other byte stay. The file is read again and the change checked before it is kept. An edit computed from a reading that is out of date writes nothing.

Rules for step names: an IEC identifier, unique among the chart's steps, without two underscores in a row. Code elsewhere that uses the step's flags by name (`Step.x`, `Step.t`) is not changed, and the status says so.

Edits beyond these wait until the stored form is established; see [What's next](https://neuralinverse.com/docs/modules/plc/whats-next/).

## Not verified

- No file edited in the diagram has been opened or built in XAE. Not known from XAE: whether it accepts the copied network's and new step's ids or renumbers them, whether it regenerates the transition variable names, whether it reads escaped `&`, `<` and `>` back, and whether moving a CFC element changes the execution order it derives.
- The network list's terminators, demultiplexers, jumps, returns and labels as items, embedded Structured Text in SFC steps and network list boxes, SFC macros, CFC pages, compositions and feedback, IL networks: no fixture holds them; they are kept as written and shown as not read.
