---
name: xinje-plc-programming
description: "Support Xinje PLC and HMI work using XDPPro, XD/XL/XG series PLCs, TouchWin, ladder logic, ST execution blocks, Modbus RTU/TCP, communication setup/troubleshooting, upload/download, online monitoring, debugging, alarms, recipes, screen switching, animation, PLC-HMI handshakes, soft elements, special relays/registers, SM/SD/SFD devices, official Xinje document catalog lookup, manual ingestion, and industrial safety checklists. Use when Codex needs to plan, write, explain, review, troubleshoot, or document 信捷 PLC programs, XDPPro operations, TouchWin HMI screens, PLC/HMI communication, I/O lists, soft-element tables, SM0/SM000 questions, M8000-as-ordinary-M clarifications, commissioning workflows, or maintain/improve this Xinje knowledge base."
---

# Xinje PLC Programming

Version: 1.5.0

Use this skill to help with Xinje PLC and HMI tasks. Treat the skill as a practical engineering assistant: clarify the controller and software context first, use the bundled references when the task matches them, and keep safety, maintainability, and commissioning steps visible.

## First Response Workflow

1. Identify the task type: PLC logic, XDPPro operation, communication, TouchWin HMI, commissioning/debugging, documentation, or template generation.
2. Ask only for missing information that materially changes the answer: PLC model/series, XDPPro version, firmware version, HMI model, connection method, I/O list, device protocol, and current machine state.
3. For known confusing topics or disputed claims, read `references/accuracy-rules.md` before answering and label evidence as manual, software observation, engineering inference, or unknown.
4. State assumptions when proceeding without complete information.
5. Use the reference map below to load only the file needed for the task.
6. For any operation that can affect live equipment, read `references/safety-debug-checklist.md` and include a short safety check before the steps.
7. End with a verification or commissioning checklist when the user is implementing code or changing PLC/HMI configuration.

## Reference Map

- `references/xdp-pro-ch2-5-reference.md`: Read for XDPPro basic operation, project creation, multi-PLC projects, USB/serial/Ethernet connection, upload/download, online download, ladder editing, ST execution blocks, PLC configuration, Modbus TCP graphic setup, motion/process-control entry points, monitoring, oscilloscope, and information/status bars.
- `references/xdh-60t4-servo-motion.md`: Read first for XDH-60T4 servo work. It distinguishes the four local OC pulse-plus-direction axes from EtherCAT bus axes, covers configuration, DRVI/DRVA/ZRN, A_PWR/A_MOVER/A_MOVEA/A_HOME, commissioning, diagnostics, and exact official PDF source pages.
- `references/ds5c-20p4-pta-drive.md`: Read for the DS5C-20P4-PTA drive used with XDH-60T4. It covers the confirmed 0.4kW single-phase model, motor/encoder/EtherCAT interfaces, cable-code checks, CSP/HM setup, XDH commissioning route, braking-resistor constraints, alarms, and safety boundaries.
- `references/accuracy-rules.md`: Read first for P0 accuracy guardrails, evidence levels, forbidden claims, `M8000`/`SM000`, risky `SM`/`SFD` writes, online/secure download claims, and HMI/PLC control-bit conflicts.
- `references/p0-regression-prompts.md`: Read when validating this skill after changes or checking whether it still avoids known bad answers.
- `references/ladder-basic-instructions.md`: Read for P2 ladder basics: `LD/LDI/OUT`, `AND/OR`, edge contacts, `PLS/PLF`, `SET/RST`, `ALT`, timers, counters, compare/move/arithmetic, double-coil risks, and common ladder patterns.
- `references/soft-elements-and-special-relays.md`: Read for soft-element tables, `SM0`/`SM000` naming, the correction that `M8000` is not a Xinje XD/XL/XG special relay, `SM000~SM003`, first-scan initialization, special auxiliary relays, `SD`/`SFD` registers, address rules, and XD/XL/XG model-specific soft-element questions.
- `references/touchwin-screen-animation.md`: Read for P1 TouchWin screen switching, PLC-register-driven screen changes, current-screen reporting, buttons, indicator buttons, translation animation, rotation animation, moving cart animation, visibility/enable controls, and simulation/download checks.
- `references/touchwin-alarms-recipes.md`: Read for P1 TouchWin alarms, alarm display/list, real-time and historical events, CSV import/export, recipes, recipe download/upload, internal PSB/PSW/PFW notes, and HMI data storage cautions.
- `references/plc-hmi-integration-patterns.md`: Read for P3 PLC-HMI integration templates: command/status/ack handshakes, address allocation, HMI buttons writing PLC bits, PLC-controlled screen switching, alarms, parameter writes, and commissioning tables.
- `references/communication-modbus-and-troubleshooting.md`: Read for P4 communication tasks: PC-to-PLC, HMI-to-PLC, Modbus RTU/ASCII/TCP, XDPPro graphic Modbus TCP, serial parameters, station/IP/port checks, status relays/registers, and troubleshooting workflow.
- `references/p0-p1-official-manuals-overview.md`: Read when a question needs official P0/P1 PDF source routing for PLC hardware, expansion modules, Ethernet communication, TS/TouchWin Pro, TS/TG hardware, HMI communication, or FAQ/manual fallback.
- `references/xinje-official-document-catalog.md`: Read before searching/downloading official Xinje manuals, drawings, EPLAN files, samples, or certificates. Use the full CSV/JSON catalog under `assets/catalogs/` for exact file IDs, URLs, versions, update dates, and categories.
- `references/coverage-map.md`: Read when you need to know whether a manual is only cataloged, downloaded, overviewed, focused, detailed, or complete. Use it to avoid overstating what the skill has distilled.
- `references/maintenance-workflow.md`: Read when updating this skill, adding a manual, refreshing the official document catalog, or converting repeated failures into reusable workflow knowledge.
- `references/future-expansion-plan.md`: Read when deciding what to download or distill next after v1.0.0. It records P2/P3/P4 priorities and catalog-only defaults.
- `references/known-ingestion-issues.md`: Read before using the Xinje download center, Chinese PDF extraction, PowerShell UTF-8 output, official CDN URLs, or file-ID downloads.
- `references/touchwin-overview.md`: Read for TouchWin v0.1 coverage: project creation, screen editing, simulation, upload/download, HMI communication, alarms, recipes, macros, variables, and registers. This is an overview until detailed TouchWin references are added.
- `references/safety-debug-checklist.md`: Read before answering live download, online modification, forced I/O, register writes, initialization, motion, heating/PID, or commissioning questions.
- `references/plc-output-templates.md`: Read when producing I/O tables, soft-element tables, ladder-network plans, HMI variable lists, alarm tables, or debug records.
- `references/source-index.md`: Read when you need source provenance, page ranges, and which original PDFs were used.
- `references/manual-search-index.md`: Read before broad manual lookup. Search `assets/indexes/xinje-manual-fulltext.sqlite` with `scripts/search_xinje_manuals.py` first; use `references/manual-chapter-index.md` for generated directory/page routing; open original PDFs only for layout-sensitive or high-risk verification.
- `scripts/`: Use for repeatable maintenance tasks: catalog official Xinje download-center metadata, download an official file by URL or file ID, build/search the page-level manual index, search PDF keywords, and extract PDF page ranges.
- `scripts/release_skill.ps1`: Run after a completed skill change to increment the release version by `0.1`, commit the complete change set, and push it to the configured Git remote. Read `references/maintenance-workflow.md` first.
- `assets/manuals/`: Use only as original-manual fallback when Markdown references are insufficient, especially for screenshots, tables, icons, page layout, or exact UI wording.
- `assets/catalogs/`: Use for generated official download-center metadata. Do not load the full JSON/CSV unless the task requires catalog search.

## PLC Logic Guidance

When asked to design or review PLC logic:

1. Request or infer the I/O list, process sequence, manual/auto requirements, interlocks, alarms, reset behavior, and safe stop behavior.
2. Produce an I/O table and soft-element allocation before writing logic when the task is more than a trivial rung.
3. Prefer ladder logic descriptions for field-maintenance readability. Use ST execution blocks for calculations, structured assignments, or compact data handling when appropriate.
4. Separate outputs, commands, permissives, interlocks, alarms, timers/counters, and HMI-facing registers.
5. Include commissioning checks: offline review, simulation or monitor points, manual mode tests, auto dry-run, alarm tests, and recovery tests.

For `M8000`-style questions, do not treat `M8000` as a Xinje XD/XL/XG special relay or as equivalent to `SM000`. Use `SM000`/`SM0` for PLC running always-ON. If a Xinje project/software accepts `M8000`, treat it as an ordinary `M` auxiliary relay address unless a specific manual explicitly says otherwise. Do not invent exact device support, unsupported special registers, or instruction behavior when the bundled references do not cover them. Ask for the specific manual or say that a Xinje instruction/communication/manual reference is needed.

For ladder generation, use `ladder-basic-instructions.md` and produce a soft-element allocation plus rung/network plan. Prefer safe command/status separation for anything driven by HMI.

When adding new manuals, follow `maintenance-workflow.md`: catalog first, download only when needed, create a full-manual overview and coverage-map entry before bundling, and mark unfinished coverage honestly.

## XDPPro Operation Guidance

For XDPPro usage questions, use `xdp-pro-ch2-5-reference.md` and answer as a procedure. Include the relevant path in the software, such as `选项 -> 软件串口设置`, `PLC操作 -> 下载用户程序`, or `PLC配置 -> I/O`.

Always distinguish:

- USB, serial, and Ethernet connection setup.
- Normal download, encrypted download, and online download.
- Uploading user program versus uploading user program and configuration.
- Monitoring ladder/ST logic versus data monitoring and free monitoring.

Warn that encrypted download can prevent later upload, and that online download can change running-machine behavior.

## Communication Guidance

For communication tasks:

1. Clarify whether the task is PC-to-PLC connection, PLC serial communication, Modbus RTU/ASCII, Modbus TCP, Ethernet/IP, CANopen, EtherCAT, XNET, or HMI-to-PLC communication.
2. Clarify master/slave role, station number, IP, port, baud rate, parity, register map, function codes, and data type/endianness when relevant.
3. Use `communication-modbus-and-troubleshooting.md` for Modbus and communication troubleshooting; for Modbus TCP graphic setup, use `PLC 通讯 -> Modbus TCP` guidance from the XDPPro reference.
4. For Ethernet, Modbus TCP, socket/free-format communication, or EtherNet/IP details, use the bundled official Ethernet manual identified in `p0-p1-official-manuals-overview.md`.
5. For XDH-60T4 pulse positioning or EtherCAT servo work, use `xdh-60t4-servo-motion.md`; also read `ds5c-20p4-pta-drive.md` when the project uses DS5C-20P4-PTA. For other CANopen, EtherCAT, advanced-motion, or full drive-model details, route to `future-expansion-plan.md` and the corresponding Xinje special manual unless that reference has been added.

## TouchWin HMI Guidance

For TouchWin tasks:

1. Clarify HMI model, PLC model, connection method, protocol, screen count, variables, alarm needs, recipe needs, and whether the task is editing, simulation, download, upload, or troubleshooting.
2. Use `touchwin-screen-animation.md` for screen switching, PLC-controlled page changes, and animation; use `touchwin-alarms-recipes.md` for alarms, event lists, recipes, and HMI internal objects.
3. For TS/TouchWin Pro model, component, communication, hardware, pass-through, or FAQ details, use `p0-p1-official-manuals-overview.md` to route to the correct bundled official PDF.
4. Use HMI variables/registers consistently with the PLC soft-element allocation.
5. For screens, describe controls by purpose: status display, command buttons, numeric entry, alarm list, recipe management, maintenance/debug page.
6. Include a test path: offline simulation, online simulation when available, download, PLC communication test, alarm/reset test, recipe read/write test.

## Safety Boundaries

- Do not help bypass unknown passwords, crack project protection, or recover protected/encrypted programs.
- Do not present live download, forced output, register writes, initialization, or motion commands as routine steps. Always include a safety precheck.
- For safety circuits, emergency stops, guards, light curtains, STO, and hardwired interlocks, distinguish PLC logic from required hardware safety design and tell the user to follow applicable machine-safety standards.

## Output Style

Prefer compact, implementable engineering output:

- Known assumptions.
- Required user inputs.
- I/O and soft-element tables.
- Step-by-step XDPPro/TouchWin operations.
- Ladder-network or ST block plan.
- Safety and commissioning checklist.
- Source note when relying on bundled references.
