본문 바로가기
코딩 · 개발

AI 생성 PLC 코드 정밀 검수

AI가 작성한 제어 코드를 5단계 검수 절차를 통해 안전하게 검증

추천 툴
공통AI 분류
쓰인 기법
역할 부여 · 단계별 사고 · 출력 형식 지정

프롬프트 원문

I want you to act as a strict reviewer of PLC code written by an AI, before it is downloaded to a controller. Platform: ${Platform and version}. Language: ${Language}. Below are my numbered requirements, then the code.

Do a review in five passes and report each as a table. Do not rewrite the code.
Pass 1, requirements: Requirement | Where it is met (block/line) | Met / Partly / Not met | Why
Pass 2, instructions: every instruction or function used | Exists on my platform and version? (Yes / No / UNSURE) | Correct parameters and units?
Pass 3, structure: timers or edge detectors called inside IFs or conditional branches, reused instances, outputs written in more than one place, latches with no reset.
Pass 4, behaviour: what happens on first scan, power cycle, download, mode change, and when an input is stuck or a sensor fails.
Pass 5, gaps: anything the code does that no requirement asked for, and requirements with no code at all.

Finish with findings ranked by impact: Finding | Block/line | What goes wrong on the machine | Test that would prove it.

=== REQUIREMENTS ===
${Paste numbered requirements}

=== CODE ===
${Paste code}
한국어 풀이 보기(참고용)
당신은 AI가 작성한 PLC 코드가 컨트롤러에 다운로드되기 전 이를 엄격하게 검수하는 리뷰어입니다. 플랫폼: [플랫폼 및 버전], 언어: [언어]. 아래 요구사항과 코드를 바탕으로 5단계 리뷰를 수행하고 각 단계를 표로 보고하세요. 코드를 새로 작성하지 마십시오.
Pass 1(요구사항): 요구사항 | 충족 위치 | 충족 여부 | 이유
Pass 2(명령어): 사용된 모든 명령/함수 | 해당 플랫폼 지원 여부 | 매개변수 및 단위 정확성
Pass 3(구조): IF문 내 타이머 호출, 인스턴스 재사용, 출력 중복 작성, 리셋 없는 래치 등 확인
Pass 4(동작): 첫 스캔, 전원 사이클, 모드 변경, 센서 고장 시 동작 분석
Pass 5(간극): 요구되지 않은 기능이나 누락된 요구사항 확인
마지막으로 영향도 순으로 발견 사항을 정리하세요: 발견 사항 | 위치 | 기계에서 발생할 문제 | 증명 테스트 방법

=== 요구사항 ===
[요구사항 붙여넣기]

=== 코드 ===
[코드 붙여넣기]
  • 활용산업 현장에서 AI 코드를 적용할 때 발생할 사고를 미연에 방지합니다.
  • 활용5단계의 논리적 검수 과정을 통해 누락된 로직을 꼼꼼히 찾아냅니다.
  • 활용실제 기계에 미칠 영향과 테스트 방법까지 제시하여 실무적입니다.

출처 · prompts.chat · AI-Generated PLC Code Reviewer — 원문은 출처에 게시된 그대로이며, 권리는 원작자에게 있습니다.

텍스트 결과

Gemini로 실행한 결과입니다. 입력 항목에는 국내 환경의 예시값을 적용했습니다(AI 생성 — 사실 확인 필요).

실행 입력값 보기
I want you to act as a strict reviewer of PLC code written by an AI, before it is downloaded to a controller. Platform: Siemens TIA Portal V17. Language: Structured Text (SCL). Below are my numbered requirements, then the code.

Do a review in five passes and report each as a table. Do not rewrite the code.
Pass 1, requirements: Requirement | Where it is met (block/line) | Met / Partly / Not met | Why
Pass 2, instructions: every instruction or function used | Exists on my platform and version? (Yes / No / UNSURE) | Correct parameters and units?
Pass 3, structure: timers or edge detectors called inside IFs or conditional branches, reused instances, outputs written in more than one place, latches with no reset.
Pass 4, behaviour: what happens on first scan, power cycle, download, mode change, and when an input is stuck or a sensor fails.
Pass 5, gaps: anything the code does that no requirement asked for, and requirements with no code at all.

Finish with findings ranked by impact: Finding | Block/line | What goes wrong on the machine | Test that would prove it.

=== REQUIREMENTS ===
1. StartBtn(I0.0)이 눌리면 Motor(Q0.0)가 가동된다.
2. StopBtn(I0.1)이 눌리면 Motor가 즉시 정지한다.
3. Motor 가동 중 Sensor(I0.2) 신호 없이 10초가 경과하면 Motor를 정지시키고 Alarm(Q0.1)을 출력한다.

=== CODE ===
IF "StartBtn" AND NOT "StopBtn" THEN
    "Motor" := TRUE;
ELSIF "StopBtn" THEN
    "Motor" := FALSE;
END_IF;

"TON_Instance"(IN:="Motor" AND NOT "Sensor", PT:=T#10s);
IF "TON_Instance".Q THEN
    "Motor" := FALSE;
    "Alarm" := TRUE;
END_IF;

제시된 SCL 코드에 대한 5단계 검토 결과입니다.

Pass 1: 요건 충족 확인

요건위치상태이유
1L1-2Met시작 조건 충족
2L3-4Met정지 조건 충족
3L7-11Met타이머 후 정지 및 알람 출력

Pass 2: 명령어 유효성

명령어TIA V17?파라미터/단위
IF/ELSIFYes정상
TONYesT#10s (정상)

Pass 3: 구조적 결함

  • 이중 코일(Double Coil): "Motor" 변수가 L2, L4 및 L9에서 중복 작성됨. 스캔 마지막 단계인 L9의 결과가 L2/L4의 논리를 덮어쓸 위험이 큼.
  • 래치 해제 부재: "Alarm"(Q0.1)을 TRUE로 만드는 로직은 있으나, 이를 리셋(FALSE)하는 로직이 없음.

Pass 4: 동작 특성

  • First Scan: 모든 출력 FALSE로 시작(정상).
  • 센서 고장: Sensor가 Off 상태로 고정되면 Motor 기동 10초 후 무조건 Alarm 발생.
  • 모드 변경: STOP에서 RUN 전환 시 타이머 인스턴스 초기화됨.

Pass 5: 갭(Gap) 분석

  • 불필요한 코드: 없음.
  • 누락된 코드: 알람 발생 후 이를 해제(Acknowledge)하기 위한 요구사항 및 코드가 누락됨.

최종 결과 요약 (영향도 순)

FindingBlock/line기계에 미치는 영향증명 테스트
이중 출력L2,4 vs L9PLC 스캔 주기에 따라 Motor가 비정상적으로 떨리거나 오작동함운전 중 타이머 조건을 강제로 트리거하여 Motor 상태 확인
알람 리셋 부재L10알람 발생 후 장비를 재가동할 수 없음타이머 조건 만족 후 StopBtn을 눌러도 Alarm이 꺼지는지 확인

hotpick 개선안

원문을 더 잘 동작하게 고쳐 쓴 프롬프트

원문을 그대로 넣으면 AI 가 매번 다르게 답하거나 중요한 부분을 빠뜨릴 수 있습니다. 개선안은 원문의 뜻과 언어는 그대로 두고 역할 · 바꿔 넣을 입력 칸 · 결과 형식 · 지킬 조건을 보완해 다시 쓴 버전입니다. 원문과 같은 곳(ChatGPT · Claude 등)에 그대로 붙여 넣어 쓰면 됩니다.

AI 자체 평가 — 개선안을 쓴 AI 가 명확성 · 구체성 · 결과 형식 · 재사용성 기준(100점)으로 직접 매긴 점수 · 결과를 돌려 검증한 값은 아님

원문85
개선안95

원문의 문제 → 개선안에서 고친 점

  • AI 역할레슨 01 배우기 ›

    원문 · 없음AI 에게 맡길 역할이 정해져 있지 않아 답의 관점 · 수준이 그때그때 달라질 수 있었습니다.

    개선 · 역할을 정함You are a senior automation engineer acting as a strict safety reviewer of AI-generated PL

  • 입력 칸레슨 05 배우기 ›

    원문 · 4개바꿔 넣을 자리가 일부만 표시돼 있어 쓸 때마다 원문을 고쳐야 했습니다.

    개선 · 6개[Platform and version] · [Language]

고친 이유 (개선안을 만든 AI 의 설명)

  1. 1전문적인 시니어 자동화 엔지니어 역할을 부여하여 검토의 신뢰도와 깊이를 높였습니다.
  2. 2각 패스의 출력 형식과 검토 항목을 명확히 정의하여 누락 없는 분석을 유도했습니다.
  3. 3위험도 기반의 최종 요약 테이블에 검증 테스트 항목을 추가하여 실효성을 강화했습니다.

이 개선안에 쓰인 기법 — 프롬프트 클래스에서 배우기

01역할 정하기05입력 칸으로 템플릿 만들기08스스로 검토하게 하기

클래스 전체 ›

원문

I want you to act as a strict reviewer of PLC code written by an AI, before it is downloaded to a controller. Platform: ${Platform and version}. Language: ${Language}. Below are my numbered requirements, then the code.

Do a review in five passes and report each as a table. Do not rewrite the code.
Pass 1, requirements: Requirement | Where it is met (block/line) | Met / Partly / Not met | Why
Pass 2, instructions: every instruction or function used | Exists on my platform and version? (Yes / No / UNSURE) | Correct parameters and units?
Pass 3, structure: timers or edge detectors called inside IFs or conditional branches, reused instances, outputs written in more than one place, latches with no reset.
Pass 4, behaviour: what happens on first scan, power cycle, download, mode change, and when an input is stuck or a sensor fails.
Pass 5, gaps: anything the code does that no requirement asked for, and requirements with no code at all.

Finish with findings ranked by impact: Finding | Block/line | What goes wrong on the machine | Test that would prove it.

=== REQUIREMENTS ===
${Paste numbered requirements}

=== CODE ===
${Paste code}

개선안 · 색칠한 [칸]에 내 내용을 넣어 쓰세요

You are a senior automation engineer acting as a strict safety reviewer of AI-generated PLC code for [Platform and version] in [Language]. Your goal is to catch critical logic bugs, safety hazards, and non-compliance before controller download.

Perform a rigorous review in five distinct passes and output each pass as a Markdown table. Do not rewrite the code.

- Pass 1 (Requirements): Requirement | Where met (block/line) | Status (Met/Partly/Not met) | Justification
- Pass 2 (Instructions): Instruction/Function used | Valid on target platform/version? (Yes/No/UNSURE) | Correct parameters and units?
- Pass 3 (Structure): Timers/edge detectors in conditionals, reused instances, dual-coil outputs, unreset latches.
- Pass 4 (Behavior): State handling on first scan, power cycle, download, mode change, stuck inputs, sensor failure.
- Pass 5 (Gaps): Undocumented features/behaviors vs. unfulfilled requirements.

Conclude with a summary table of findings ranked by impact: Finding | Block/line | Failure impact on machine | Verification test.

=== REQUIREMENTS ===
${Paste numbered requirements}

=== CODE ===
${Paste code}

같은 분야 프롬프트 코딩 · 개발

더 보기 ›