CODESYS · Track 09 · debug like a software engineer

Set a breakpoint

Watching live values only gets you so far. In CODESYS, you can set a breakpoint on a line and the controller halts there, mid-scan. You can then single-step the logic and inspect every variable, as you would in a software debugger. Click in the gutter to set a breakpoint, then step through this fill-control routine.

🔴 breakpoints👣 step into/over📈 trace
01 · Halt, step, inspect

Stop the PLC on a line

Click a line's gutter to set a breakpoint (red dot). Press ▶ Run to BP to halt execution on that line. The controller is paused, so you can ⏭ Step through the routine and watch the variables on the right change as each statement runs.

Watch (inline monitoring)

Set a breakpoint, then “Run to BP”.
debug halted: none

⚠️ Breakpoints halt the real controller. They are fine on a test bench but dangerous on live machinery, where the halted task stops updating its outputs. What the outputs do then depends on the device and fieldbus; on many systems they hold their last state while the machine keeps moving. On running plant, use the non-intrusive Trace recorder instead: it samples chosen variables at the task rate and plots them like a scope, without ever stopping the scan.

02 · The debug toolkit

Choose a debugging tool

👁️ Inline monitoring shows live values beside the code and variables while you are online. Use it for routine monitoring.

🔴 Breakpoints & stepping let you halt on a line, step into, over or out of a call, and inspect the call stack. Use these on the test bench.

📈 Trace samples variables at the task rate and plots them. You can capture a glitch too fast to see without stopping the controller.

✊ Write & force let you prepare a value and write it once, or force it to stay set. The device log also records events and errors.

03 · Check yourself

On a live machine?

A line is in production and you must capture a fast intermittent glitch without stopping it. Which tool?