IMDHMIControls LibraryShop main store

Troubleshooting

Why PLC Coder reports update diagram not possible with a clean model

PLC programming Published 6 min read

Short answer

PLC Coder raises the update diagram not possible error because generation runs a stricter diagram update than your simulation: an input or output port on the subsystem selected for STEP 7 generation is unconnected, and that fault surfaces only as a warning. Trace both sides of the generation boundary, connect or deliberately terminate every port, rerun the generation, and read the newest attempt's diagnostics; a clean simulation is a separate check, not a clearance.

On this page
  1. Why a model that simulates can still stop generation
  2. Trace both sides of the generation boundary
  3. Read the diagnostics from the generation attempt
  4. Connect or terminate, never dummy out
  5. Make an open port fail loudly next time
  6. What each passing check proves
  7. Questions asked

The message Update diagram not possible. Ensure model is able to simulate error free. during a STEP 7 generation run almost never means your simulation is broken. It means the diagram update PLC Coder runs inside code generation found a connectivity fault: an input or output port on the subsystem selected for generation is open on one side. Your simulation passed because that fault surfaces only as a warning in the diagnostics window. Trace both sides of the generation boundary, connect the real signals or deliberately terminate the ports you intend to leave unused, then rerun the generation and judge only that attempt's diagnostics.

Why a model that simulates can still stop generation #

A diagram update resolves the model's connectivity and signal attributes before any code is produced, and generation runs its own update as part of preparing the selected target. Simulation is a different stage with looser rules: a running model tolerates an open port by applying an implicit ground to an unconnected input and discarding an unconnected output, while generation has to resolve every boundary port into a real interface. The same model therefore simulates cleanly and still refuses to generate.

The misleading part is where the evidence sits. The unconnected-port fault was flagged only among the warnings — mixed into the same list as the precision-loss and data-type notices you had already decided to accept — and the error line summarizes the failed operation instead of naming the cause. The cause list belongs to the generation attempt, so read the diagnostics window from that run, warnings included. Repeating the simulation will never show you which warning stopped the build.

Trace both sides of the generation boundary #

The generation boundary is the port interface of the subsystem selected for PLC code generation. Work the ports before you touch solvers, targets or configuration:

  1. Confirm which subsystem carries the code-generation selection. The boundary you must clear is that subsystem's ports, not the top model's.
  2. Count the boundary paths: every input and output port on the selected subsystem is a path that must resolve. An interface of 3 inputs and 2 outputs is 5 paths.
  3. Trace each input from its source outside the subsystem, through the input port, to the blocks that consume it inside. A port stub with no line on either side is the defect.
  4. Trace each output from the block that produces it inside, through the output port, to its destination outside. An output with no destination blocks generation exactly as hard as an input with no source.
  5. Write down every open port before you edit, so the correction list stays explicit and the rerun can be judged against it.

Worked example with illustrative numbers, not a measured case: the selected subsystem has 3 inputs and 2 outputs, so 3 + 2 = 5 boundary paths. An edit removed the line on the second output. Simulation lists 4 warnings — precision loss, an under-specified data type, a missing unit, and 1 unconnected port — and completes anyway. Generation hits the same list and stops. The arithmetic that decides it: 4 of the 5 paths resolve, 1 does not, and that 1 open path, not the other 3 notices, is what stops the build. Reconnect the output and the build proceeds; the remaining 3 warnings are engineering decisions to review separately, not blockers.

Read the diagnostics from the generation attempt #

The error line is a summary of the failed operation, not a diagnosis. The named causes are in the diagnostics window from the generation run, and in this failure class a warning is a cause. Open every entry that points into the selected subsystem or its ports, and keep attempts distinguishable: a warning from an earlier model state says nothing about the model as it stands now.

Triage the entries by category, because they flag different engineering problems:

Diagnostic entry What it flags What to do
Unconnected subsystem port A boundary port has no line on one side, so the interface cannot resolve Trace both sides and connect the real signal or terminate deliberately. This entry stopped the build
Precision loss A conversion can change the numeric value a signal carries Compare both types against the range and resolution the control needs, then retype or accept with a reason
Under-specified data types The model leans on inference where the interface needs an explicit type Resolve the types and pin them at the boundary
Missing unit definition A signal's engineering unit is unset Confirm the unit across the calculation and set it where the interface carries it

Connectivity first, because it is the fault that blocks generation. The other three are decisions about data representation, and wiring a port does not settle them. Block-level review continues after the ports too: if the model contains timers, using the PLC Coder timer block correctly in TIA Portal is its own documented pitfall worth clearing while you are in the diagnostics.

Connect or terminate, never dummy out #

Connect a missing port to the signal the control design says belongs there. Do not attach a constant just to make the warning disappear: an invented input can quietly change permissives, sequencing or numeric results while the model still runs, and deleting an unused-looking output can discard a result the sequence needs downstream.

When a port is genuinely unused, state that in the model instead of leaving it bare. Terminate the intentional open the way your modeling tool treats unused signals, and confirm that treatment is accepted by the generation target. The distinction to hold on to is unused versus missing: the first is a design statement, the second is a defect, and only one of them justifies a terminator.

Make an open port fail loudly next time #

The fault reached you as warning text because the connectivity diagnostics that flag unconnected ports were not set to stop the run. In the model's diagnostics settings, find those entries and, where an entry accepts a stricter severity, set it to error: the next diagram update then stops with the port named as the cause instead of passing as routine notice. Keep that stricter configuration for code-generation runs so a release model cannot carry an open interface through as warning text.

PLC Coder can also audit the subsystem before a full build: right-click the subsystem, open its PLC Code menu and run Check Subsystem Compatibility. The check reports the issues in the subsystem that would prevent code generation, which turns a failed build into a named correction list before you commit to the run.

What each passing check proves #

Keep the acceptance stages separate, because each answers a different question. A completed diagram update proves the interface resolves. A clean simulation proves the configured model behaves as designed. A completed generation proves structured text was produced, nothing more.

The generated text is optimized: dead logic is eliminated and expressions are folded, so it will not read block for block like the diagram. Review it against the design before it reaches a controller; the discipline in verifying AI-generated PLC code before you trust it carries over unchanged, because a generator's output is untrusted input either way. Handing the result to an engineering tool is its own step with its own failure modes, and importing PLC Coder XML with a PLCopen import is one documented route between tools. One safety line belongs here: generated logic is unvalidated logic, so keep it off a machine that runs until the machine's safety function has been validated as installed.

Decision: when this message appears, treat an open boundary port as the cause until the trace proves otherwise. Trace both sides of every port on the selected subsystem, connect real signals or terminate intentional opens, raise the unconnected-port diagnostic severity for the next run, and judge only the newest attempt's diagnostics. Reach for solver or configuration changes only when every boundary path resolves and the diagnostics name something else.

Questions asked

Why does the model still simulate cleanly with a port unconnected?

A running model does not need every boundary port wired. Simulink applies an implicit ground to an unconnected input and discards an unconnected output during the run, so the behavior looks normal while the diagnostics still list the open port as a warning. Code generation cannot accept that implicit interface, so the same open port stops its diagram update. The warning you read as routine was the cause list.

Is the fault in the solver settings or the model configuration?

Almost never. The failing stage is connectivity resolution, which runs before a solver ever steps the model, so solver changes address nothing here. The configuration that does matter is the diagnostics severity for unconnected ports: left at warning it lets the defect pass simulation, and raising it to error is the one setting change worth making before the next generation run.

Every port is connected now and generation still stops. What next?

Judge the newest attempt only and read its diagnostics window from the top. The common leftovers after a connectivity fix are boundary types that never resolved and precision-loss conversions, which passed as warnings earlier but can stop a later stage. Run Check Subsystem Compatibility from the subsystem's PLC Code context menu to collect every remaining generation blocker in one list, then correct them in the order reported.

Does a clean simulation prove the generated structured text is correct?

No. A clean run validates the configured model, and a clean compile of the generated text validates only syntax; neither proves control behavior. The generator also optimizes while it writes, so the text will not match the diagram block for block. Accept generated logic on a review against the design plus a function test at the controller, not on the simulation that ran beforehand.

Keep reading

  • How-to

    EL3314 status word error handling in TwinCAT PLCs

    Declare the EL3314's four channels as one array of value-and-status structures with AT %I*, link each element through an index-to-member assignment in the TcLinkTo attribute, and decode the status WORD with three AND masks: 16#0001 underrange, 16#0002 overrange, 16#0040 error. Dividing the raw integer by 10.0 gives degrees Celsius at 0.1 °C resolution; one function block instance per channel packages scale and decode so four indexed calls replace copy-pasted rungs.

    PLC programming

  • Troubleshooting

    Use the PLC Coder timer block correctly in TIA Portal

    A Stateflow delay generated with PLC Coder follows wall-clock time only when the timing implementation and the PLC task call interval agree with the model sample time. Pick the target IDE timer for real elapsed time; use the Target-Independent Counter only when the generated code runs at a fixed periodic interval equal to the model step.

    PLC programming

  • Explainer

    How a REPEAT loop runs in PLC structured text

    In IEC 61131-3 structured text, a REPEAT loop executes its body first and evaluates the UNTIL condition after it, so the body always runs at least once and the whole loop completes inside one task invocation. With i := 0 and UNTIL i >= 10, the body runs 10 times and i ends at exactly 10; the test position is what explains the off-by-one cases and when WHILE fits better.

    PLC programming