Troubleshooting
Why your ladder program is not called by the PLC task
Short answer
A gray ladder diagram after a clean download means the runtime never calls that program: compile, download, login and start move the application but create no call path. Open the task configuration and either assign your ladder program to the task or call it from the assigned program; in the reported three-tank project, replacing the default PLC_PRG with the tank program made the coil states go live.

On this page
Compile, download, login and start can all succeed while your ladder diagram stays gray: the application transferred, but the runtime never calls that program. A task executes only the programs assigned to it plus whatever those programs call, so a ladder POU outside that chain never scans — the coils show no on/off state and no contact can be modified online, because online work needs logic that is actually running. Put the ladder on a task's call path and both symptoms clear at once: assign your ladder program directly on the task, or call it from the assigned program. In the reported three-tank project on the VirtualPLC, replacing the default PLC_PRG with the tank program did exactly that, and the coil states went live. Here is how to trace the path, count the calls and close the gap.
What a gray ladder diagram means #
The editor grays every POU that nothing calls — no task reaches it and no program calls it. Treat gray as the diagnosis itself: the networks compiled, they sit in the application, and they will never execute until something reaches them. That one fact explains both observations at the same time. The coils show no state because no task scans the rungs, and the contact will not change online because online editing operates on logic in the active path.
Gray is not a download symptom. The same application downloaded ten times still leaves an uncalled program gray, so skip the loop of generating code and transferring again — it rebuilds the same dead path every time.
Trace the execution path from the task to your rungs #
Execution flows one way. The runtime runs the tasks in the task configuration, each task calls the programs on its list, and each called program can call further POUs. Only POUs reachable from a running task execute on that task's cycle.
Open the task object in the device tree and read the program list on its Configuration tab; a program added there also appears below the task in the device tree. Compare each name on that list with your ladder program's name. If yours is not listed, open every listed program and look for a call to it — a rung of contacts and coils with no program call never reaches another POU.
The rule does not change when a chart is the entry point instead of a task: an SFC still has to call the ladder function block itself, which is worked through in calling a ladder function block from SFC in CODESYS so it executes.
Decision rule: if your program's name appears neither on a task's list nor inside any call made by a listed program, it cannot run. Repair the path before touching a single contact.
What compile, download, login and start prove #
Each step of the reported session establishes one thing, and none of them creates a call path:
- Generate code (F11): the project compiles, and every POU — gray ones included — is in the application.
- Download: the application reached the target. If the download itself aborts with license exceptions, that is a different fault, handled step by step in fixing ctrlX PLC license invalid exceptions on download.
- Login (Alt+F8): the engineering session is online to the runtime.
- Start (F5): the application is running whatever program the task actually calls.
A connected session and a running runtime coexist happily with an uncalled program, which is exactly the state the gray diagram reports. Transfer moves code; only the task configuration decides what executes.
Tracing the call path for the three-tank project on the VirtualPLC #
The inputs, and where each comes from:
- Target: the VirtualPLC of a ctrlX PLC 1.20.7 setup, engineered with CtrlX Works 1.20.11 — the reported environment.
- Application: a three-tank filling project whose tank logic sits in one ladder program, TankFillingDeviceSolution_LD — the reported project.
- Task state: one task whose program list holds the default PLC_PRG and nothing else — the state that produced the gray diagram.
- Calls reaching the tank program: 0, because the editor draws TankFillingDeviceSolution_LD gray, its mark for a POU that is never called.
The rule: a program executes on a task only when the task's call reaches it, directly or through programs it calls, so the reachable count decides everything.
The arithmetic: the task calls 1 program directly (PLC_PRG); that program calls 0 programs; programs reachable from the task = 1 + 0 = 1; of those, programs containing tank rungs = 0. The rungs for all three tanks therefore execute 0 times per task cycle.
The result: TankFillingDeviceSolution_LD receives 0 scans per cycle, so no coil updates and no contact can be edited.
The decision: a reachable count of 0 is the threshold, and no number of downloads moves it. Close the path either by assigning TankFillingDeviceSolution_LD on the task in place of PLC_PRG — the reachable set becomes 1 program, all of it yours — or by adding one call to it inside PLC_PRG, which lifts the count to 1 + 1 = 2. The reported fix was the direct replacement; after it, the rungs for all three tanks scanned every cycle and the coil states went live.
Fix the call path #
- Open the task configuration and read the program list on the task's Configuration tab; note which program is assigned.
- Choose the shape of the fix. If your ladder program is meant to be the main program, assign it directly, the way the reported project put the tank program where PLC_PRG stood. If the assigned program carries startup or housekeeping logic you need to keep, leave the assignment alone and add one call to your ladder program inside it.
- Check the program's interface first: a program assigned straight to a task that declares VAR_IN_OUT variables can trip compiler error C0039 on CODESYS 3.5.17, and the resolution is laid out in resolving the C0039 VAR_IN_OUT error for a PRG called from the task configuration.
- Generate code with F11, download once, log in with Alt+F8 and start with F5.
- Open the ladder view and confirm the POU draws active rather than gray, with coil states that track the logic while it scans.
On real hardware, run the first scan of a rebuilt call path with the machine in a safe state: logic that sat uncalled can drive outputs the moment it begins to execute.
Direct assignment suits the case where the ladder routine is meant to be the task's program; a call from the existing program suits the case where that program must keep running its own logic. Never chase a missing call path by downloading an unchanged application again — transfer does not create the relationship.
When the ladder runs but a coil stays off #
Active-but-off is a different fault. Once the rungs scan and the editor shows live states, a coil can still read off because its rung conditions are false, so check the live values at the contacts before suspecting the call path again. In a tank simulation the level inputs come from somewhere: if nothing in the project models the tanks, the rungs wait forever on levels that never arrive, and the block that supplies them is covered in why a PLC tank simulation needs a plant model block.
The contact edit in the reported session failed for the same reason the coils were dead: there was no executing logic to edit. Once the program runs, use the target's supported online operations — write a value to change a variable, use the online change function for logic edits where the target allows them — and confirm the new state in the ladder view. An unchanged display counts against the call path only while the diagram is still gray; once the program is active, an unchanged display means the edit did not take, not that the program is dead.
Questions asked
Is PLC_PRG a required program name?
No. PLC_PRG is just the default main program the project template creates and the one the task template lists. The runtime executes whatever program the task's list names, whatever that name is. Renaming or replacing it is safe as long as the task still points at a program that reaches your logic; in the reported fix the tank program simply took its place on the task.
Can one task run several ladder programs?
Yes. A task's program list can hold more than one program, and each listed program can also call its own POUs, so a common layout is one dispatcher program on the task that calls each ladder program in turn. Every program reached this way scans once per task cycle; anything left off the list and out of every call stays gray exactly as before.
Does a function block instance run by itself?
No. Declaring an instance of a function block only reserves its data; the block's code runs when a POU on the execution path invokes that instance. That is why a block can stay gray while its instance already exists. Call the instance from a program the task reaches, or call one of its actions or methods, and the block joins the execution path like any other POU.
Does the same rule apply in simulation mode?
Yes. Simulation changes where the application runs, not how it is reached. The simulated runtime still executes tasks, and the program still has to be started after login before anything scans. Keep the ladder tied to a task by assignment or by a call, generate code, download to the simulated target, log in, start it, and the coil states appear just as they do on real hardware.


