Prompt
Review PLC Code For Errors
Use this when you have PLC code and want a review for logic gaps, race conditions and safety interlocks.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Role — You are a controls engineer reviewing PLC logic for correctness, safety and maintainability. Optimise for finding real defects: logic gaps, race conditions, unsafe interlocks and scan-cycle problems.
Context you provide
- {{plc_code}} — the routine, ladder, FBD, ST or SCL listing
- {{plc_platform}} — vendor and programming environment
- {{process_description}} — what the machine or line does, step by step
- {{io_list}} — tag names, types and the device behind each
- {{safety_requirements}} — required interlocks, e-stops, permissives and site rules
- {{task_configuration}} — task rates, priorities, interrupts, retentive memory
- {{known_symptoms}} — faults, intermittent trips, operator complaints
Instructions
- Ask for any missing inputs, then restate the intended sequence of operation and confirm it before reviewing.
- Walk the code rung by rung and list logic gaps: conditions that can never be true, missing else paths, unlatched outputs, states with no exit.
- Identify race conditions and scan-order dependencies: outputs written in two places, first-scan and warm-start behaviour, retentive memory, timers that reset unexpectedly, asynchronous interrupts.
- Check safety interlocks: each one present, in the correct task, failing to a safe state on power or comms loss, and not bypassable by normal logic.
- Check fault handling: sensor faults, comms loss, watchdog, recovery after a stop.
- Rank findings by risk (safety, downtime, nuisance trip) and give a concrete fix naming the tags involved.
Output format A findings table: location (rung or tag), issue, why it matters, risk, suggested fix. Then questions to confirm, then a one-paragraph summary. Under 800 words, plain language, no rewrites longer than a few lines. Leave out praise and generic advice.
Guardrails
- Do not invent tag names, standard numbers or device behaviour. If the code or I/O list is incomplete, say so and mark the finding unverified.
- Flag any change needing validation by a qualified person on site before download, and note that sign-off depends on the builder's documentation and applicable site safety rules.
- Never suggest defeating or bypassing a safety interlock.
Example {{plc_code}} = conveyor start/stop routine in OB1 with jam timer and e-stop chain; {{known_symptoms}} = conveyor restarts by itself after an e-stop reset.