Просмотр исходного кода

release: xinje-plc-programming v1.5.0 (base)

tags/v1.5.0
TURNIP\86155 3 недель назад
Сommit
844adccf7f
39 измененных файлов: 57162 добавлений и 0 удалений
  1. +117
    -0
      SKILL.md
  2. +4
    -0
      agents/openai.yaml
  3. +181
    -0
      assets/catalogs/xinje-official-document-catalog-summary.md
  4. +3684
    -0
      assets/catalogs/xinje-official-document-catalog.csv
  5. +47894
    -0
      assets/catalogs/xinje-official-document-catalog.json
  6. Двоичные данные
      assets/indexes/xinje-manual-fulltext.sqlite
  7. +1280
    -0
      assets/indexes/xinje-manual-toc.json
  8. +54
    -0
      references/accuracy-rules.md
  9. +146
    -0
      references/communication-modbus-and-troubleshooting.md
  10. +129
    -0
      references/coverage-map.md
  11. +80
    -0
      references/ds5c-20p4-pta-drive.md
  12. +62
    -0
      references/future-expansion-plan.md
  13. +50
    -0
      references/known-ingestion-issues.md
  14. +177
    -0
      references/ladder-basic-instructions.md
  15. +98
    -0
      references/maintenance-workflow.md
  16. +336
    -0
      references/manual-chapter-index.md
  17. +29
    -0
      references/manual-search-index.md
  18. +62
    -0
      references/p0-p1-official-manuals-overview.md
  19. +33
    -0
      references/p0-regression-prompts.md
  20. +144
    -0
      references/plc-hmi-integration-patterns.md
  21. +84
    -0
      references/plc-output-templates.md
  22. +78
    -0
      references/safety-debug-checklist.md
  23. +170
    -0
      references/soft-elements-and-special-relays.md
  24. +147
    -0
      references/source-index.md
  25. +124
    -0
      references/touchwin-alarms-recipes.md
  26. +50
    -0
      references/touchwin-overview.md
  27. +157
    -0
      references/touchwin-screen-animation.md
  28. +78
    -0
      references/xdh-60t4-servo-motion.md
  29. +882
    -0
      references/xdp-pro-ch2-5-reference.md
  30. +75
    -0
      references/xinje-official-document-catalog.md
  31. +173
    -0
      scripts/build_pdf_search_index.py
  32. +240
    -0
      scripts/catalog_xinje_downloads.py
  33. +72
    -0
      scripts/download_catalog_ids.py
  34. +52
    -0
      scripts/download_xinje_file.py
  35. +29
    -0
      scripts/extract_pdf_pages.py
  36. +40
    -0
      scripts/probe_pdf_manuals.py
  37. +59
    -0
      scripts/release_skill.ps1
  38. +36
    -0
      scripts/search_pdf_keywords.py
  39. +56
    -0
      scripts/search_xinje_manuals.py

+ 117
- 0
SKILL.md Просмотреть файл

@@ -0,0 +1,117 @@
---
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.

+ 4
- 0
agents/openai.yaml Просмотреть файл

@@ -0,0 +1,4 @@
interface:
display_name: "信捷 PLC 编程"
short_description: "信捷 PLC/HMI、官网资料与知识库维护助手"
default_prompt: "Use $xinje-plc-programming to help with a Xinje PLC or TouchWin programming, configuration, communication, debugging, official-document lookup, or knowledge-base maintenance task."

+ 181
- 0
assets/catalogs/xinje-official-document-catalog-summary.md Просмотреть файл

@@ -0,0 +1,181 @@
# Xinje Official Document Catalog

Cataloged at: 2026-07-08 19:52:45

Scope: metadata from Xinje download-center document-like categories. Files are not downloaded by this script.

## Counts By Category

| Category | Count |
|---|---:|
| 产品图纸 | 2501 |
| EPLAN | 726 |
| 产品手册 | 330 |
| 彩页/样本 | 69 |
| 认证证书 | 57 |

## Counts By File Type

| File type | Count |
|---|---:|
| dwg | 1019 |
| pdf | 822 |
| zip | 753 |
| edz | 553 |
| stp | 459 |
| rar | 62 |
| step | 12 |
| sldprt | 2 |
| igs | 1 |

## Recent Items

| ID | Category | Title | Type | Version | Update date |
|---|---|---|---|---|---|
| 4147 | 产品图纸 | MS6G-110CM30B2-21P8 伺服电机CAD图纸 | dwg | 1.0 | 20260708 |
| 4146 | 产品图纸 | MS6G-110CM30B2-21P8 伺服电机PDF图纸 | pdf | 1.0 | 20260708 |
| 4145 | 产品图纸 | DL6-2003+2006-GS 直驱伺服驱动器3D图纸 | zip | 1.0 | 20260708 |
| 4140 | 产品图纸 | DS1L-20P7 伺服驱动器3D图纸 | zip | 1.0 | 20260707 |
| 4139 | 产品图纸 | DS1L-20P4 伺服驱动器3D图纸 | zip | 1.0 | 20260707 |
| 4138 | 产品图纸 | DS1L-20P7 伺服驱动器CAD图纸 | dwg | 1.0 | 20260707 |
| 4137 | 产品图纸 | DS1L-20P4 伺服驱动器CAD图纸 | dwg | 1.0 | 20260707 |
| 4136 | 产品手册 | DS1L系列伺服驱动器用户手册 | pdf | 1.0 | 20260707 |
| 4135 | 产品图纸 | MS1H-40CM30BZ3-20P1 伺服电机CAD图纸 | dwg | 1.0 | 20260701 |
| 4134 | 产品图纸 | MS1H-40CM30BZ3-20P1 伺服电机3D图纸 | zip | 1.0 | 20260701 |
| 4133 | 产品图纸 | MS1H-40CM30BZ3-20P1 伺服电机PDF图纸 | pdf | 1.0 | 20260701 |
| 4132 | 产品图纸 | MS1H-40CM30B3-20P1 伺服电机3D图纸 | zip | 1.0 | 20260701 |
| 4131 | 产品图纸 | MS1H-40CM30B3-20P1 伺服电机CAD图纸 | dwg | 1.0 | 20260701 |
| 4130 | 产品图纸 | MS1H-40CM30B3-20P1 伺服电机PDF图纸 | pdf | 1.0 | 20260701 |
| 2737 | 产品手册 | XSFQ7系列可编程控制器用户手册【硬件篇】 | pdf | 1.2 | 20260629 |
| 2 | 产品手册 | XSF系列可编程控制器用户手册【硬件篇】 | pdf | 1.3 | 20260629 |
| 4129 | 认证证书 | PLC可编程控制器及扩展模块 CE证书_24v_2 | pdf | 1.0 | 20260626 |
| 4128 | 认证证书 | PLC可编程控制器及扩展模块 CE证书_24v_1 | pdf | 1.0 | 20260626 |
| 4127 | 认证证书 | PLC可编程控制器及扩展模块 CE证书_220v | pdf | 1.0 | 20260626 |
| 4126 | 认证证书 | PLC可编程控制器 CE证书_220v | pdf | 1.0 | 20260626 |

## PLC/HMI Candidates

Use the full CSV/JSON catalog for exact URLs. This section highlights likely PLC/HMI-related entries.

| ID | Category | Title | Type | Version | Update date |
|---|---|---|---|---|---|
| 4129 | 认证证书 | PLC可编程控制器及扩展模块 CE证书_24v_2 | pdf | 1.0 | 20260626 |
| 4128 | 认证证书 | PLC可编程控制器及扩展模块 CE证书_24v_1 | pdf | 1.0 | 20260626 |
| 4127 | 认证证书 | PLC可编程控制器及扩展模块 CE证书_220v | pdf | 1.0 | 20260626 |
| 4126 | 认证证书 | PLC可编程控制器 CE证书_220v | pdf | 1.0 | 20260626 |
| 2264 | 认证证书 | 人机界面产品CE证书-M.2024.206.C102060 | zip | 1.0 | 20241216 |
| 2263 | 认证证书 | 人机界面产品CE证书-M.2023.206.C83171 | pdf | 1.0 | 20241216 |
| 2250 | 认证证书 | 整体式控制器ROHS证书 | pdf | 1.0 | 20241216 |
| 2248 | 认证证书 | PLC可编程控制器及模块UL证书 | pdf | 1.0 | 20241216 |
| 2245 | 认证证书 | PLC可编程控制器 CE证书(220V)-M.2023.206.C83166 | pdf | 1.0 | 20241216 |
| 2244 | 认证证书 | PLC可编程控制器 CE证书(24V)-M.2023.206.C83165 | pdf | 1.0 | 20241216 |
| 2243 | 认证证书 | PLC可编程控制器CE证书(24V)-M.2023.206.C92614 | pdf | 1.0 | 20241216 |
| 2242 | 认证证书 | PLC可编程控制器CE证书(220V)-M.2023.206.C92613 | pdf | 1.0 | 20241216 |
| 2241 | 认证证书 | PLC可编程控制器ROHS证书 | pdf | 1.0 | 20241216 |
| 1654 | EPLAN | XL-E16X16YT 数字量输入输出模块EPLAN库文件 | edz | 1.0 | 20260227 |
| 3015 | EPLAN | XSLQ7系列刀片式控制器EPLAN库文件 | zip | 1.0 | 20260119 |
| 3014 | EPLAN | XSFQ7系列刀片式控制器EPLAN库文件 | zip | 1.0 | 20260119 |
| 3013 | EPLAN | XSF5-A8 刀片式控制器EPLAN库文件 | edz | 1.0 | 20260119 |
| 3012 | EPLAN | XSF5-A16 刀片式控制器EPLAN库文件 | edz | 1.0 | 20260119 |
| 3011 | EPLAN | XSA530-L 工业智能控制器EPLAN库文件 | edz | 1.0 | 20260119 |
| 3010 | EPLAN | XSA530-W 工业智能控制器EPLAN库文件 | edz | 1.0 | 20260119 |
| 3009 | EPLAN | XSLH-24A8 薄型控制器EPLAN库文件 | edz | 1.0 | 20260119 |
| 3008 | EPLAN | XSLH-24A16 薄型控制器EPLAN库文件 | edz | 1.0 | 20260119 |
| 3007 | EPLAN | XSLH-30A32 薄型控制器EPLAN库文件 | edz | 1.0 | 20260119 |
| 3006 | EPLAN | XSDH-60A32-C 小型控制器EPLAN库文件 | edz | 1.0 | 20260119 |
| 3005 | EPLAN | XSDH-60PA32-E 小型控制器EPLAN库文件 | edz | 1.0 | 20260119 |
| 3004 | EPLAN | KXS系列高性能控制器EPLAN库文件 | zip | 1.0 | 20260119 |
| 1659 | EPLAN | XL-E32X 数字量输入模块EPLAN库文件 | edz | 1.0 | 20250617 |
| 2178 | EPLAN | ZGM-30T4-7整体式控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 2177 | EPLAN | ZG3-30T-7整体式控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 2176 | EPLAN | ZG3-30RT-7整体式控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 2175 | EPLAN | ZG3-30R-7整体式控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 2174 | EPLAN | ZG3-20T-4整体式控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 2173 | EPLAN | ZG3-20R-4整体式控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 2172 | EPLAN | ZG3-18T-7整体式控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 2171 | EPLAN | ZG1-20T-4整体式控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 2153 | EPLAN | XP3-18RT整体式控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 2152 | EPLAN | XP3-18R整体式控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 2151 | EPLAN | XP3-18T整体式控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 2148 | EPLAN | XP2-18RT-B整体式控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 2147 | EPLAN | XP2-18R-B整体式控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 2146 | EPLAN | XP1-18T整体式控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 2145 | EPLAN | XP1-18R整体式控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 2144 | EPLAN | W-BOXL无线通讯模块EPLAN库文件 | edz | 1.0 | 20241216 |
| 1772 | EPLAN | XSF5-A64 刀片式控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1771 | EPLAN | XSF5-A32 刀片式控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1770 | EPLAN | XSDH-60A32-E 小型控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1769 | EPLAN | XS3-26T4 中型控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1768 | EPLAN | XLME-64T10 薄型控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1767 | EPLAN | XLME-32T4 薄型控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1766 | EPLAN | XLH-30A32 薄型控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1765 | EPLAN | XLH-24A16L 薄型控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1764 | EPLAN | XLH-24A16 薄型控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1763 | EPLAN | XL5N-32T4 薄型控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1762 | EPLAN | XL5N-32T 薄型控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1761 | EPLAN | XL5E-64T10 薄型控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1760 | EPLAN | XL5E-64T6 薄型控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1759 | EPLAN | XL5E-32T4 薄型控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1758 | EPLAN | XL5E-32T 薄型控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1757 | EPLAN | XL5E-16T 薄型控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1756 | EPLAN | XL5-64T10 薄型控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1755 | EPLAN | XL5-32T4 薄型控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1754 | EPLAN | XL5-16T 薄型控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1753 | EPLAN | XL5-32T 薄型控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1752 | EPLAN | XL3-32R 薄型控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1751 | EPLAN | XL3-32T 薄型控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1750 | EPLAN | XL3-16T 薄型控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1749 | EPLAN | XL3-16R 薄型控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1748 | EPLAN | XL1-16T-U 薄型控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1747 | EPLAN | XL1-16T 薄型控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1746 | EPLAN | XG2-26T4 中型PLC可编程控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1745 | EPLAN | XG1-16T4 中型PLC可编程控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1744 | EPLAN | XDME-60 可编程控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1743 | EPLAN | XDME-30 可编程控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1742 | EPLAN | XDM-24 可编程控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1741 | EPLAN | XDM-32 可编程控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1740 | EPLAN | XDM-60 可编程控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1739 | EPLAN | XDH-60 可编程控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1738 | EPLAN | XDH-30 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1737 | EPLAN | XDC-24 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1736 | EPLAN | XDC-32 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1735 | EPLAN | XDC-48 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1734 | EPLAN | XDC-60 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1733 | EPLAN | XD5E-60 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1732 | EPLAN | XD5E-48 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1731 | EPLAN | XD5E-30 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1730 | EPLAN | XD5E-24 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1729 | EPLAN | XD5系列差分型可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1728 | EPLAN | XD5-60 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1727 | EPLAN | XD5-48 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1726 | EPLAN | XD5-42 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1725 | EPLAN | XD5-32 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1724 | EPLAN | XD5-24 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1723 | EPLAN | XD5-16 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1722 | EPLAN | XD3-60 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1721 | EPLAN | XD3-48 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1720 | EPLAN | XD3-32 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1719 | EPLAN | XD3-24 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1718 | EPLAN | XD3-22T4TC-E 可编程控制器EPLAN库文件 | edz | 1.0 | 20241216 |
| 1717 | EPLAN | XD3-16 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1716 | EPLAN | XD2-60 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1715 | EPLAN | XD2-48 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1714 | EPLAN | XD2-42 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1713 | EPLAN | XD2-32 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1712 | EPLAN | XD2-24 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1711 | EPLAN | XD2-16 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1710 | EPLAN | XD1-32 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1709 | EPLAN | XD1-24 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1708 | EPLAN | XD1-16 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1707 | EPLAN | XD1-10 可编程控制器EPLAN库文件 | rar | 1.0 | 20241216 |
| 1704 | EPLAN | XC系列温度扩展模块EPLAN库文件 | rar | 1.0 | 20241216 |
| 1703 | EPLAN | XC系列数字量输入输出扩展模块EPLAN库文件 | zip | 1.0 | 20241216 |
| 1702 | EPLAN | XC系列数字量输出扩展模块EPLAN库文件 | zip | 1.0 | 20241216 |
| 1701 | EPLAN | XC系列数字量输入扩展模块EPLAN库文件 | zip | 1.0 | 20241216 |
| 1700 | EPLAN | XC系列模拟量温度混合扩展模块EPLAN库文件 | rar | 1.0 | 20241216 |
| 1699 | EPLAN | XC系列模拟量扩展模块EPLAN库文件 | rar | 1.0 | 20241216 |
| 1698 | EPLAN | XC-TBOX-BD 扩展BD板EPLAN库文件 | edz | 1.0 | 20241216 |
| 1697 | EPLAN | XC-SD-BD 扩展BD板EPLAN库文件 | edz | 1.0 | 20241216 |
| 1696 | EPLAN | XC-OFC-BD 扩展BD板EPLAN库文件 | edz | 1.0 | 20241216 |
| 1695 | EPLAN | XC-COM-H-BD 扩展BD板EPLAN库文件 | edz | 1.0 | 20241216 |
| 1694 | EPLAN | XC-COM-BD 扩展BD板EPLAN库文件 | edz | 1.0 | 20241216 |

+ 3684
- 0
assets/catalogs/xinje-official-document-catalog.csv
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


+ 47894
- 0
assets/catalogs/xinje-official-document-catalog.json
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


Двоичные данные
assets/indexes/xinje-manual-fulltext.sqlite Просмотреть файл


+ 1280
- 0
assets/indexes/xinje-manual-toc.json
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


+ 54
- 0
references/accuracy-rules.md Просмотреть файл

@@ -0,0 +1,54 @@
# Accuracy Rules

Use this P0 reference before answering known confusing Xinje PLC/HMI questions, before changing the skill, and before making claims that depend on exact manual wording.

## Evidence Levels

| Level | Meaning | How to answer |
|---|---|---|
| A - manual | The bundled official manual or official Xinje document explicitly says it. | Answer directly and cite the manual/page or section. |
| B - software observation | XDPPro/TouchWin behavior was observed, but the manual wording is absent or incomplete. | Say "software appears/allows..." and do not turn it into an official definition. |
| C - engineering inference | A practical conclusion follows from PLC/HMI behavior or common practice. | Mark it as an inference and ask for model/version if it affects safety or compatibility. |
| D - unknown | The skill has not verified the claim. | Do not guess. Search the catalog/manual or ask for the exact model/manual. |

## Hard Rules And Forbidden Claims

| Topic | Correct rule | Do not say | Evidence/source anchor |
|---|---|---|---|
| `M8000` on XD/XL/XG | `M8000` is not documented as a Xinje XD/XL/XG special relay. If accepted by software and in range, treat it as ordinary `M` memory. | "`M8000 = SM000`" or "`M8000` is the run always-ON relay." | XD/XL and XG basic manuals list `SM000` for run always-ON; no explicit `M8000 = SM000` definition found. |
| Run always-ON | Use `SM000` / `SM0`. | Use `M8000` for XD/XL/XG run always-ON. | `soft-elements-and-special-relays.md`; XD/XL basic manual appendix special relays. |
| First scan | Use `SM002` / `SM2` for first-scan ON pulse. | Use `M8002` as an XD/XL/XG official first-scan relay unless the project/manual explicitly uses it. | `soft-elements-and-special-relays.md`. |
| `SM0` vs `SM000` | Treat `SM0` as short input form for `SM000` when software/manual context confirms zero-padded addressing. | Generalize this rule to every device family without checking. | XDPPro software and XD/XL/XG manuals use `SM000` naming; software/manual examples also use `SM0`. |
| `M` vs `HM` | `M` is ordinary auxiliary relay; `HM` is retentive auxiliary relay. | Claim every `M` persists after power loss. | Basic instruction manual soft-element chapter. |
| `SM` writes | Many `SM` bits are system/special bits. Read their function before writing. | Treat `SM` as free user memory. | `soft-elements-and-special-relays.md`; safety checklist. |
| `FD`/`SFD` writes | Flash-backed registers have write-life and behavior cautions; use edge-triggered writes and avoid periodic writes. | Drive `FD`/`SFD` writes with clock pulses such as `SM011`. | XD/XL basic manual soft-element notes mention Flash write life and edge-effective `MOV`. |
| Online download | Online download can change running-machine behavior. Require backup and safety check. | Present online download as routine and harmless. | XDPPro software manual PDF pages 53-54. |
| Secure/encrypted download | Secure download can make later upload impossible. Warn before recommending. | Tell users it is just a normal download option. | XDPPro software manual PDF page 53 and toolbar description page 24/31. |
| HMI button writes PLC bit | If TouchWin operates a PLC bit, avoid driving the same bit with PLC `OUT` in normal scan. Use command/status separation. | Use the same `M` as both HMI direct control bit and PLC output coil. | TouchWin manual PDF page 75. |
| TouchWin PLC-controlled screen switch | The interaction register value selects a screen number and is cleared to 0 after jump. Drive it with an edge/event. | Continuously write the target page number every scan. | TouchWin manual PDF page 38. |
| `ALT` | `ALT` toggles a bit and is edge-triggered; if driven by a level that is true every scan, it can repeatedly toggle. | Use `ALT` under always-ON condition for stable state. | XD/XL basic manual PDF page 88 and FAQ mention ALT output flashing. |

## Answering Pattern For Disputed Topics

Use this shape:

1. State the conclusion.
2. Separate manual wording from software observation.
3. Name the safe substitute.
4. Give a short verification path.

Example:

```text
For XD/XL/XG, do not use M8000 as a system always-ON bit. The manual documents SM000/SM0 as PLC running always-ON. If XDPPro accepts M8000, treat it as ordinary M memory within the valid address range. Verify by monitoring SM0 and M8000 separately while the PLC is in RUN.
```

## When To Escalate To Manual Lookup

Look up the original PDF or official catalog when:

- the answer depends on exact address ranges for a CPU model,
- the topic involves firmware/version support,
- a device may move, heat, clamp, pump, or write retentive/Flash data,
- the user reports software behavior that conflicts with current references,
- the user asks for a page number/source.

+ 146
- 0
references/communication-modbus-and-troubleshooting.md Просмотреть файл

@@ -0,0 +1,146 @@
# Communication, Modbus, And Troubleshooting

Use this P4 reference for Xinje PLC/HMI communication questions, Modbus RTU/ASCII/TCP setup, XDPPro connection, HMI-to-PLC communication, status diagnosis, and troubleshooting.

Source anchors:

- XDPPro software manual PDF pages 21-22: TouchWin-style project creation requires HMI model, PLC port, download port, and communication parameters.
- XDPPro software manual PDF pages 33-46: PLC connection through serial/Ethernet and IP/network notes.
- XDPPro software manual PDF pages 110-112: `PLC 通讯 -> Modbus TCP` graphic configuration, model/firmware support, slave nodes, instruction rows, trigger modes.
- XD/XL basic instruction manual chapter 6 and PDF pages around 250+: Modbus RTU/ASCII, Modbus address, communication instructions.
- `soft-elements-and-special-relays.md`: serial communication status relays such as `SM140~SM193` and communication result registers such as `SD140~SD199`.

## First Questions

Clarify:

| Item | Examples |
|---|---|
| Link type | PC-to-PLC, HMI-to-PLC, PLC-to-device, PLC-to-PLC. |
| Physical layer | USB, RS232, RS485, Ethernet. |
| Protocol | Xinje protocol, Modbus RTU, Modbus ASCII, Modbus TCP, XNET, Ethernet/IP, CANopen, EtherCAT. |
| Role | Master/client or slave/server. |
| Parameters | Station ID, IP, port, baud rate, data bits, stop bits, parity, timeout, retry count. |
| Data map | Coil/register address, function code, word width, signed/unsigned, float, byte/word order. |
| Version | PLC model, firmware, XDPPro version, HMI model/TouchWin version. |

## PC To PLC In XDPPro

Common paths:

- USB/serial/Ethernet connection setup in XDPPro.
- `选项 -> 通讯方式设置` for communication mode.
- `选项 -> TCP/IP 设备设置` for Ethernet devices.
- `选项 -> 软件串口设置` for serial settings.
- Status bar shows model, communication mode, and PLC running status.

Troubleshooting:

1. Confirm correct cable/driver/interface.
2. Confirm only one application is using the serial port.
3. For Ethernet, confirm PC and PLC are in the same subnet and only the intended NIC is active.
4. Confirm PLC ID/IP/station.
5. Try upload/monitor after basic connection succeeds.

## HMI To PLC In TouchWin

In TouchWin project creation:

1. Select the correct HMI model.
2. Set `PLC 口` to the correct PLC/device type and communication parameters.
3. Set `下载口` to unused or to the correct communication device if it will communicate with lower devices.
4. Use the correct station number in each HMI component.
5. For online simulation, confirm PC-to-device hardware supports it; USB download alone may not support lower-device monitoring.

Common symptoms:

| Symptom | Checks |
|---|---|
| HMI shows "正在通讯" | Protocol, station, serial port, cable, COM occupancy, PLC port setting. |
| Values display wrong | Address notation, word width, signed/unsigned, float, scaling, byte order. |
| HMI button does not work | Button object address, station, PLC double-coil conflict, HMI permission/enable control. |
| Download port cannot communicate | Confirm download port is configured for communication mode, not only program download. |

## Modbus RTU/ASCII

Required parameters:

| Parameter | Notes |
|---|---|
| Station | Must match slave ID. |
| Baud rate | Match all devices on the bus. |
| Data bits / stop bits / parity | Must match exactly. |
| Wiring | RS485 A/B polarity, shield/grounding, termination for long/high-speed networks. |
| Function code | Coil/register read/write must match target map. |
| Register map | Confirm 0-based vs 1-based addressing and device-specific offsets. |

PLC-side concepts:

- Communication instructions include coil read/write and register read/write groups.
- XD/XL Modbus RTU handling queues multiple communication requests differently than old XC-style examples; still avoid uncontrolled repeated triggers.
- Use edge/condition triggers for write commands to avoid flooding a device.

Diagnosis:

1. Use a serial tool first when integrating a third-party device.
2. Verify a single read of one known register.
3. Add writes only after reads are stable.
4. Monitor communication busy/done/error bits and result registers.
5. Increase timeout/retry only after parameter and wiring checks.

## Modbus TCP Graphic Configuration In XDPPro

XDPPro path:

```text
工程 -> PLC 通讯 -> Modbus TCP
```

The software manual describes model/firmware support and a graphic table with:

- master connection information,
- slave node add/delete/copy/properties,
- instruction add/insert/delete/move/import/export,
- trigger mode: cyclic ms or conditional trigger,
- slave station number,
- function code,
- mapping/cache address,
- timeout/retry,
- connection flag/result storage.

Use this when the PLC model/firmware supports graphical Modbus TCP. Otherwise route to the Ethernet communication manual or use instruction/socket method as appropriate.

## Status Relays And Result Registers

From the current soft-element reference:

| Range | Use |
|---|---|
| `SM140~SM193` | Serial-port communication status flags. |
| `SD140~SD199` | Communication result registers. |

Example pattern:

- Serial port 0: `SM140` Modbus executing, `SM141` X-NET executing, `SM142` free-format sending, `SM143` free-format receive complete.
- `SD140` is the Modbus read/write result for serial port 0 in the referenced XD/XL manual.

Always verify the exact port group and model table before writing production diagnostics.

## Troubleshooting Checklist

1. Identify master/slave and protocol.
2. Confirm physical wiring and interface.
3. Confirm station/IP/port and serial parameters.
4. Confirm register/coil address map and function code.
5. Confirm data type and byte/word order.
6. Test one read, then one write.
7. Monitor status bits/result registers.
8. Check timeout/retry and polling interval.
9. Check HMI/PLC project settings use the same station and protocol.
10. Record final parameters in the project documentation.

## Safety Notes

- Communication writes can move outputs indirectly; treat write commands as live machine actions.
- Do not test write-multiple-registers against motion, heating, pressure, or recipe ranges without a safe machine state.
- Keep manual controls and emergency stops independent of the communication link.

+ 129
- 0
references/coverage-map.md Просмотреть файл

@@ -0,0 +1,129 @@
# 覆盖状态表

读取本文件,用来判断当前 skill 对某份资料到底掌握到什么程度:哪些只是官网目录已记录,哪些 PDF 已下载,哪些已经做了专题整理。回答问题时不要超过这里标注的覆盖程度。

覆盖标签:

- `cataloged`:只有官网元数据,文件未下载。
- `downloaded`:PDF 已纳入 `assets/manuals/`,但 Markdown 覆盖不足。
- `overview`:已记录整本手册目录或章节地图。
- `focused`:已围绕常见任务做了专题整理。
- `detailed`:相关章节整理得足够细,普通问答可直接依赖。
- `complete`:整本手册已经整理成可导航参考。目前不要轻易使用这个标签。

## 已纳入的核心手册

| 手册 | 状态 | 当前 Markdown 覆盖 | 后续需要补充 |
|---|---|---|---|
| XD/XL/XG 系列可编程控制器用户手册【软件篇】XDPPro V3.8.1 | `focused` / 第 2-5 章为 `detailed` | `xdp-pro-ch2-5-reference.md` 覆盖建工程、连接、上传/下载、梯形图/ST 编辑、配置、通讯设置、监控、示波器、状态栏等。`communication-modbus-and-troubleshooting.md` 补充 Modbus TCP 图形化设置和通讯排查。 | 用户问到函数库、高级配置、型号差异 UI、POU 或完整 XDPPro 工作流时,再继续整理剩余章节。 |
| TouchWin 编辑软件用户手册 v1.2 | `focused` | `touchwin-overview.md` 覆盖 HMI 基本流程。`touchwin-screen-animation.md` 覆盖画面切换、PLC 寄存器控制画面、当前画面回传、按钮和动画。`touchwin-alarms-recipes.md` 覆盖报警、事件、配方、PSB/PSW/PFW 等内部对象。 | 用户问到具体控件、宏、通讯细节时,再按组件或章节细化;目前可实用但不是完整整理。 |
| XD、XL 系列可编程控制器用户手册【基本指令篇】v1.6.1 | `overview` / `focused` | `soft-elements-and-special-relays.md` 覆盖软元件、SM/SD/SFD、`M8000` 不是特殊运行继电器的修正、首次扫描、特殊继电器组。`ladder-basic-instructions.md` 覆盖第 3 章常用基础指令、定时器/计数器、比较/传送模式。`communication-modbus-and-troubleshooting.md` 覆盖 Modbus 概览和排查。 | 按需整理第 4-13 章的应用指令、高速计数、PID、ST、POU、常见问题。 |
| XG 系列 PLC 用户手册【基本指令篇】v1.0 | `overview` / `focused` | `soft-elements-and-special-relays.md` 已核对 XG 附录中 `SM000~SM003` 的命名。 | 回答 XG 型号专属范围或指令差异前,需要继续整理 XG 软元件范围和指令差异。 |

## v1.0.0 加入的 P0/P1 官方手册

以下手册已下载并放入 `assets/manuals/`。`p0-p1-official-manuals-overview.md` 记录了官方 ID、页数、章节地图和路由。多数状态为 `overview`,意思是可作为官方回查依据,但还没有整本深度转成 Markdown。

| 优先级 | 官方 ID | 手册 | 状态 | 当前 Markdown 覆盖 | 后续需要补充 |
|---|---:|---|---|---|---|
| P0 | 2831 | XD、XL 系列可编程控制器用户手册【硬件篇】v1.6 | `overview` | 章节地图见 `p0-p1-official-manuals-overview.md`。 | 端子表、输入/输出接线、高速输入接线、扩展组成、附录专题整理。 |
| P0 | 29 | XG 系列可编程序控制器用户手册【硬件篇】v1.0 | `overview` | 章节地图见 `p0-p1-official-manuals-overview.md`。 | XG1/XG2 端子排列、电源/I/O 接线、扩展规则。 |
| P0 | 64 | 触摸屏与 PLC 及其他设备通讯连接手册 v1.2.1 | `overview` | 章节地图和 HMI 到 XD/XL/XG 的路由见 `p0-p1-official-manuals-overview.md`。 | XD/XL/XG 连接、通讯线制作、协议选择、下载、穿透、常见通讯检查。 |
| P0 | 95 | 以太网通讯用户手册 v1.5.1 | `overview` | 章节地图见 `p0-p1-official-manuals-overview.md`;当前 Modbus 工作流仍以 `communication-modbus-and-troubleshooting.md` 为主。 | IP 设置、Modbus TCP 地址/功能码、图形化 Modbus TCP、自由格式 Socket 指令、以太网标志/寄存器/错误、EtherNet/IP。 |
| P0 | 40 | XD 系列 PLC 扩展模块用户手册 v1.2.4 | `overview` | 章节地图见 `p0-p1-official-manuals-overview.md`。 | 数字量/模拟量/温度/压力/编码器模块接线、地址分配、`From/To` 例程、量程换算。 |
| P0 | 44 | XL 系列 PLC 扩展模块用户手册 v1.6.2 | `overview` | 章节地图见 `p0-p1-official-manuals-overview.md`。 | XL 模块参数、端子接线、地址分配、模拟量/温度/压力例程。 |
| P0 | 46 | XG 系列 PLC 扩展模块用户手册 v1.1 | `overview` | 章节地图见 `p0-p1-official-manuals-overview.md`。 | XG 扩展配置、I/O 地址定义、模拟量/温度 Flash 和寄存器设置。 |
| P1 | 51 | TouchWin Pro 编辑软件用户手册(TS 系列适用)v1.7 | `overview` | 章节地图见 `p0-p1-official-manuals-overview.md`;通用 TouchWin 模式仍在 `touchwin-screen-animation.md` 和 `touchwin-alarms-recipes.md`。 | TS 元件、函数功能块、权限、采样/趋势/报表、配方、VNC/VPN/MQTT/数据发布。 |
| P1 | 52 | TS 系列人机界面用户手册【通讯篇】v1.9.1 | `overview` | 章节地图见 `p0-p1-official-manuals-overview.md`。 | TS 到 XD/XL/XG 串口/Modbus TCP 连接、地址表、接线、Modbus 主从站设置。 |
| P1 | 50 | TS 系列人机界面用户手册【硬件篇】v1.4 | `overview` | 章节地图见 `p0-p1-official-manuals-overview.md`。 | TS2/TS3/TS5/TS5D 型号差异、接口、尺寸、安装注意点。 |
| P1 | 65 | TouchWin 组态软件使用说明 v1.0 | `overview` | 章节地图见 `p0-p1-official-manuals-overview.md`。 | 安装/卸载、简单工程、在线模拟、生成组态、浏览器、报警数据库、FAQ。 |
| P1 | 67 | TS 系列人机界面常见问题汇总 v1.0 | `overview` | 问题索引见 `p0-p1-official-manuals-overview.md`。 | TS 下载、通讯异常、穿透、IP、背光、校准等排查答案。 |
| P1 | 68 | TG 系列人机界面常见问题汇总 v1.0 | `overview` | 问题索引见 `p0-p1-official-manuals-overview.md`。 | TG/TGM 下载、TG 到 XD/XL/XG 通讯、485 接线、画面切换、配方、报警、产品差异。 |

## P0-P4 专题参考

| 优先级 | 参考文件 | 状态 |
|---|---|---|
| P0 | `accuracy-rules.md`、`p0-regression-prompts.md`、`safety-debug-checklist.md` | v0.4.0-dev 已加入准确性规则、证据等级、高风险触发词和回归测试提示。 |
| P1 | `touchwin-screen-animation.md`、`touchwin-alarms-recipes.md`、`p0-p1-official-manuals-overview.md` | 已有 TouchWin 画面切换、动画、报警、事件、配方和内部对象的专题整理;v1.0.0 加入 TS/TouchWin Pro/HMI 通讯官方手册路由。 |
| P2 | `ladder-basic-instructions.md` | 基础梯形图指令和常见模式已做专题整理。 |
| P3 | `plc-hmi-integration-patterns.md` | PLC-HMI 指令/状态/确认握手、地址分配、参数写入、报警集成和调试页模板。 |
| P4 | `communication-modbus-and-troubleshooting.md` | PC/HMI/PLC 通讯、Modbus RTU/TCP、通讯参数、状态诊断和排查流程。 |

## XDH-60T4 伺服与运动控制专题

| 官方 ID | 手册 | 状态 | 当前 Markdown 覆盖 | 边界 |
|---:|---|---|---|---|
| 2599 | XDH-60 可编程控制器用户随机手册 v1.4 | `focused` | `xdh-60t4-servo-motion.md` 覆盖 XDH-60T4 本体的 4 路高速脉冲输出、Y0~Y3、DC5~30V、50mA、100kHz,以及接线安全前提。 | 随机手册仅 2 页;不代替具体伺服驱动器接线图和参数手册。 |
| 27 | XD、XL 系列可编程控制器用户手册【定位控制篇】v1.3 | `overview` / `focused` | `xdh-60t4-servo-motion.md` 覆盖 XDH-60T4 脉冲轴、`DRVI`、`DRVA`、`ZRN`、接线/驱动器输入形式、完成标志、触发冲突和基础排障。 | 多段、插补和全部系统参数表仍应按原 PDF 按需回查。 |
| 94 | XDH/XLH/XG2 系列可编程控制器用户手册【高级运动控制篇】v1.4.3 | `overview` / `focused` | `xdh-60t4-servo-motion.md` 覆盖 EtherCAT 拓扑、LAN2、扫描/写入/激活、轴配置、轴调试、POU 和常用单轴指令路由。 | 未逐条整理全部 636 页指令、轴组、CAM 和行业案例;按具体问题继续提取。 |
| 2431 | EtherCAT 运动控制用户手册 v1.0 | `overview` | `xdh-60t4-servo-motion.md` 将其作为 CiA402、PDO/SDO、ESM 和报警排查的补充来源。 | 属于较早的通用资料;对 XDH-60T4 的配置和指令,以 ID 94 高级运动控制篇为主。 |
| 86 | DS5C 系列伺服驱动器用户手册 v1.3.1 | `overview` / `focused` | `ds5c-20p4-pta-drive.md` 覆盖 DS5C-20P4-PTA 规格、主回路/CN0/CN2、CP-SP-M-03、CM-P07-03 后缀核对、EtherCAT、CSP/HM、XDH 联调、制动电阻和常见报警。 | 未逐条整理全部参数、增益、所有控制模式和 382 页报警表;机械丝杆参数仍需实物规格确认。 |

## 全量 PDF 检索层

当前 `assets/manuals/` 的全部 PDF 由 `manual-search-index.md` 路由。构建完成后,`assets/indexes/xinje-manual-fulltext.sqlite` 保存每页的文本检索索引,`references/manual-chapter-index.md` 保存自动检测到的目录与页码。该层是 `focused` 的检索基础设施,不代表所有手册已完成逐章人工整理;涉及接线图、表格、图像、型号兼容或高风险操作时仍需视觉核对原始 PDF。

## XD/XL 基本指令篇概览

官方目录 ID:`9`。PDF:`assets/manuals/XD、XL系列可编程控制器用户手册(基本指令篇)(PD05 20260610 1.6.1).pdf`。

整本手册章节地图:

| 章节 | 主题 | 当前 skill 覆盖 |
|---|---|---|
| 前言 | 适用范围、安全说明、关联手册、获取路径 | 仅原文 |
| 1 | 编程概述:PLC 特点、梯形图、指令表、ST | `xdp-pro-ch2-5-reference.md` 对编辑器行为有部分覆盖,不是指令细节 |
| 2 | 软元件:X/Y/M/HM/SM/S/HS/T/HT/ET/C/HC/HSC/D/HD/SD/HSD/FD/SFD/FS、常数、编程原则 | `soft-elements-and-special-relays.md` 已专题整理 |
| 3 | 基本顺控指令:`LD/LDI/OUT`、`AND/ANI`、`OR/ORI`、脉冲触点、微分触点、`MEP/MEF/INV`、`ORB/ANB`、`MCS/MCR`、`ALT`、`PLS/PLF`、`SET/RST`、定时器/计数器、`END`、`GROUP/GROUPE` | `ladder-basic-instructions.md` 已覆盖常用用法和模式 |
| 4 | 应用指令:流程控制、比较、传送、运算、移位、转换、浮点、时钟 | 仅在 `ladder-basic-instructions.md` 中对比较/传送/运算有概要覆盖 |
| 5 | 高速计数 | 仅目录 |
| 6 | 通讯功能:Modbus、自由格式通讯、串口参数、Modbus 地址表 | `communication-modbus-and-troubleshooting.md` 有 Modbus/排查专题 |
| 7 | PID 控制 | 仅目录 |
| 8 | C 语言功能块 | 仅目录 |
| 9 | BLOCK 顺序功能块 | 仅目录 |
| 10 | 特殊功能指令 | 仅目录 |
| 11 | 结构化文本 ST | 仅目录 |
| 12 | POU 程序组织单元 | 仅目录 |
| 13 | 常见问题和排查 | 仅目录 |
| 附录 | 特殊软元件、资源冲突表、PLC 功能配置表 | `soft-elements-and-special-relays.md` 对 SM/SD/SFD 等重点内容有专题整理 |

## XG 基本指令篇概览

官方目录 ID:`30`。PDF:`assets/manuals/XG系列PLC用户手册【基本指令篇】.pdf`。

整本手册章节地图:

| 章节 | 主题 | 当前 skill 覆盖 |
|---|---|---|
| 前言 | 适用范围、安全说明、关联手册 | 仅原文 |
| 1 | 编程概述:PLC 特点、编程语言、编程方式 | 仅目录 |
| 2 | 软元件:X/Y、M/HM/SM、S/HS、T/HT/ET、C/HC/HSC、D/HD/SD/HSD、FD/SFD/FS、常数、编程原则 | 仅对 `SM000~SM003` 命名做了重点核对 |
| 3 | 基本顺控指令 | 仅目录 |
| 4 | 应用指令:流程、比较、传送、运算、移位、转换、浮点、时钟 | 仅目录 |
| 5 | 高速计数 | 仅目录 |
| 6 | 通讯功能 | 仅目录 |
| 7 | PID 控制 | 仅目录 |
| 8 | C 语言功能块 | 仅目录 |
| 9 | BLOCK 顺序功能块 | 仅目录 |
| 10 | 特殊功能指令 | 仅目录 |
| 11 | 常见问题和排查 | 仅目录 |
| 附录 | 特殊软元件、资源冲突表、PLC 功能配置表 | 仅对 `SM000~SM003` 和附录位置做了重点核对 |

## 仅目录化的官方来源

官方资料目录目前包含 3683 条类似文档的条目,见:

- `xinje-official-document-catalog.md`
- `assets/catalogs/xinje-official-document-catalog.csv`
- `assets/catalogs/xinje-official-document-catalog.json`

当问题依赖手册内容时,不能只凭目录元数据回答。应先用目录定位官方文件,再下载或抽取需要的页码。

## 后续下载与整理计划

见 `future-expansion-plan.md`:

- P2:定位、运动、EtherCAT、CAN、高级轴控手册。
- P3:XDQ/XLQ、XSF/XS PLCopen、XC 到 XD/XL 迁移。
- P4:不新增下载,继续深度整理已经纳入的手册。

+ 80
- 0
references/ds5c-20p4-pta-drive.md Просмотреть файл

@@ -0,0 +1,80 @@
# DS5C-20P4-PTA 驱动器

本参考面向 `XDH-60T4 + DS5C-20P4-PTA`。默认推荐 EtherCAT 总线轴方案:`XDH LAN2 -> DS5C IN -> DS5C OUT`。驱动器的 CN0 脉冲输入也存在,但同一机械轴不得同时接受 EtherCAT 运动指令和 PLC 本体脉冲指令。

任何接线、参数写入、使能、回零或试转前,必须确认设备停机、急停/防护门/外部限位有效、机械区域清空,并保存当前 PLC 与驱动器参数。本文不把 PLC/驱动器的一般 I/O 当作 STO 或安全回路。

## 已确认的型号与接口

| 项目 | DS5C-20P4-PTA 官方规格 | 工程结论 |
|---|---|---|
| 驱动器 | 0.4kW,单相 AC200-240V,50/60Hz,风冷 | 主电源只接 `L/N`,不得接入 `U/V/W`。 |
| 输出能力 | 连续输出电流 2.8A,最大输出电流 9.8A | 电机必须与驱动器功率/电机代码匹配,不能仅因插头能插上而使用。 |
| 主回路 | `L/N` 输入;`U/V/W` 接电机;PE 接地 | 电机动力线接在驱动器侧,不接 PLC。接地端在散热片处。 |
| 编码器 | `CN2` | 编码器线只连接驱动器和电机,不接 PLC。 |
| EtherCAT | 两个标准 RJ45 口,`IN/OUT` 线型拓扑 | 用屏蔽双绞线;驱动器为从站,XDH 为主站。 |
| CN0 | PUL/DIR 与三入三出 I/O(本机型小于 1kW) | 仅用于脉冲控制或独立 I/O;EtherCAT 方案不把它当作主运动命令通道。 |

来源:DS5C 手册 PDF 13、46、49-51、80。

## 当前线缆核对

| 用户提供线缆 | 官方命名解释 | 结论 |
|---|---|---|
| `CP-SP-M-03` | `CP` 普通型编码器线;`SP` 为安普插头、S01 电机;`M` 不带电池盒;`03` 为 3m。 | 命名与 DS5C 手册完全对应。它要求电机端确为 S01 型接口;不要把它用于 S02/B 系列接口。 |
| `CM-P07-03` | 手册的完整命名示例为 `CM-P07A-M-03`:`CM` 普通型动力线、`P` 小功率 4 芯安普插头、`07` 代表 0.75mm2、`03` 为 3m;`A/B` 和 `M` 还定义驱动器侧端子与线缆类型。 | 现有型号缺少 `A-M` 后缀,不能只凭简写确认驱动器端压接端子和线缆类型。以实物完整标签/采购清单为准。 |

无论线缆型号如何,电机型号仍需从铭牌确认。驱动器上 `U3-70` 的电机代码应与电机铭牌的 MOTOR CODE 一致;不确定时不要通过修改 `P0-33` 强行消除电机代码报警。

来源:DS5C 手册 PDF 11、18、21-24、258-259。

## 接线边界

### 驱动器、电机与 PLC

1. 单相 AC200-240V 接入驱动器 `L/N`;绝不把电源接入 `U/V/W`。
2. 电机动力线接驱动器 `U/V/W/PE`,编码器线接 `CN2`。动力线、编码器线和控制/通讯线分开布设,控制信号线与动力线间距至少 30cm。
3. EtherCAT 使用 `XDH LAN2` 接第一台 DS5C `IN`,再由该驱动器 `OUT` 接下一台 DS5C `IN`。这不是“网线转 RS-232”链路;RS-232 转接线不能替代 EtherCAT 线。
4. `DS5C-20P4-PTA` 的 CN0:PUL-/P+24V 是集电极开路脉冲输入,DIR-/D+24V 是方向输入,`SI1~SI3` 为输入,`SO1~SO3` 为输出。若项目最终采用 XDH 本地脉冲,请单独设计 CN0 接线与极性;若采用 EtherCAT,不要同时给该轴触发 `DRVI/DRVA/ZRN`。

来源:DS5C 手册 PDF 5、46、49-51、262;XDH 高级运动控制篇 PDF 8-10。

## EtherCAT 调通顺序

1. 在无使能、无负载风险状态接通总线,检查 DS5C `IN/OUT` 链路灯和物理顺序。
2. 在 XDPPro 的 EtherCAT 界面扫描或添加设备;从站列表顺序必须与实际接线一致,`StationID 0` 为第一台。
3. 常规配置下将从站功能选择为 Servo Module。CSP 基础配置使用 PDO 映射 `1600`、`1A00`,启动参数 `6060h=8`;默认 IO 映射起始地址可为 `HD10000`,但以当前工程实际映射为准。
4. 执行“配置写入 -> 激活 -> 确定”。激活会使从站经 `Init -> PreOP -> SafeOP -> OP`;监控 `SD8021`,值 `8` 才是 OP,此时 SDO/PDO 才能收发。
5. 确认轴配置的指令通道是 EtherCAT:`SFD8001+300*N = 0`。随后只用对应逻辑轴的高级运动指令或 POU,例如 `A_PWR`、`A_MOVER`、`A_MOVEA`、`A_HOME`/`BMC_A_POWER`。

DS5C 支持 100BASE-TX、屏蔽双绞线、线型拓扑,节点间最长 50m。DS5C 3791 及后续版本支持 1000/2000/4000/8000/10000us 通讯周期;XDH 的实际周期仍应按轴数、驱动器固件与现场负载选择,先以保守值调通。

来源:DS5C 手册 PDF 75-91、262-266;XDH 高级运动控制篇 PDF 10-18。

## HM 驱动器回零

总线轴可使用 DS5C 内部 HM 回零,也可用 XDH 高级运动轴配置的 HOME/A_HOME。二者须选择一种作为该轴的唯一回零责任方,避免 PLC `ZRN`、驱动器 HM 和高级运动 `A_HOME` 同时管理同一轴的原点。

DS5C HM 模式的官方流程:

1. 将 `6060h` 设为 `6`,且在电机未使能状态下切换模式。
2. 将 `6098h`(回零方式)与 `609Ah`(回零加速度)加入 RxPDO;`6099h`(高速/低速)经 SDO/CoE-Online 设置。
3. 默认限位/原点端子分配为:`P5-22=1 -> SI1` 正限位,`P5-23=2 -> SI2` 负限位,`P5-27=3 -> SI3` 原点。不要假定现场参数仍是默认值,先在线读取。
4. OP 且使能完成后,`6040h` 控制字从 `15` 变为 `31` 触发一次回零;再次回零前先回到 `15`,再切到 `31`。

以 `6098h` 为 1/2/3/4 等方式时,原点、正负限位和电机 Z 相的组合不同。先确认现场传感器到底接在驱动器 SI 还是 PLC X 输入,再选方式;错误选型会使轴向错误方向找限位。

来源:DS5C 手册 PDF 106-118、273-275。

## 制动电阻、报警与安全边界

- 对 `DS5C-20P4-PTA`,外置制动电阻最小阻值 40ohm,推荐 40-100ohm、500W 以上。使用外置电阻时接 `P+ / C`、拆除 `P+ / D` 短接线,并设置 `P0-25`、`P0-26`。只有在垂直轴、高惯量或频繁减速等再生工况经计算确认需要时才实施;这是高压高温操作。
- 典型排查:`E-280` 读电机参数失败时,先核查编码器线与驱动器/电机匹配;`E-310` 为驱动器与电机功率不匹配;`E-316` 为自动读取的电机代码与 `P0-33` 不一致。
- EtherCAT 报警可由对象 `603Fh` 或 SDO `0x3100:00` 读取。清除报警前先找到根因;`6040h` bit7 的 0->1 是 Fault reset,不能作为自动循环重试逻辑。
- 当前收录的 DS5C 手册中未建立 STO 的可靠型号/端子依据。不得把 CN0 的 SI、SO 或 PLC 软件使能描述为安全扭矩关断;仍需独立硬件安全回路,并以该机实际安全资料与电气设计确认。

来源:DS5C 手册 PDF 24-26、258-261;安全要求 PDF 3-5。

## 与丝杆项目的未决参数

`HT1685-0300-02` 的完整机械参数未在当前资料中核实。要把 DS5C 指令单位换算为 mm,并可靠设置速度、加速度、回零距离和软限位,仍需获得:丝杆导程、有效行程、减速比(若有)、电机完整型号、原点/极限传感器接线位置、最大负载与运行方向。未得到这些数据前,只可进行低速空载和小行程测试。

+ 62
- 0
references/future-expansion-plan.md Просмотреть файл

@@ -0,0 +1,62 @@
# 后续扩展计划

当需要在 1.2.0 之后继续完善本 skill 时,读取本文件。默认不要自动下载、自动打包所有资料;应按优先级、用户当前项目需求和 `maintenance-workflow.md` 来决定。

## 基本原则

- 官网目录元数据保留在本地,方便搜索和定位。
- 只有当某份手册能解决高频问题,或用户明确进入该领域时,再下载。
- 每新增一份手册,需要同步更新 `source-index.md`、`coverage-map.md`,并至少新增一份概览或专题参考。
- 只有用户明确要求分享/打包时,才重新生成 ZIP。

## P2:运动、定位、现场总线

当用户询问伺服定位、高速轴、脉冲输出、EtherCAT、CAN、回原点、CAM、轴诊断时,优先考虑这一批。

| ID | 手册 | 大小 | 为什么重要 |
|---:|---|---:|---|
| 27 | XD/XL 系列定位控制篇 | 16.82 MB | 已下载并做 XDH-60T4 脉冲伺服专题;后续按需细化多段、插补和完整参数表 |
| 31 | XG 系列定位控制篇 | 11.7 MB | XG 的定位控制和轴控制差异 |
| 94 | XDH/XLH/XG2 高级运动控制篇 | 25.08 MB | 已下载并做 XDH-60T4 EtherCAT/轴配置专题;后续按需细化轴组、CAM、追剪和飞剪 |
| 2431 | EtherCAT 运动控制用户手册 | 6.63 MB | 已下载,作为 EtherCAT 轴、总线配置、驱动状态和诊断的补充;以 ID 94 为 XDH 主来源 |
| 92 | CAN 通讯用户手册 | 2.47 MB | CAN/CANopen 类通讯和排查 |
| 34 | LC5E EtherCAT 从站 PLC 用户手册 | 3.79 MB | EtherCAT 系统里的从站 PLC 使用 |

预计 P2 体积:约 66-75 MB,取决于是否额外加入 BD 板手册。

已完成的 XDH-60T4 专题入口为 `xdh-60t4-servo-motion.md`。当前项目使用的 DS5C-20P4-PTA 已补入 `ds5c-20p4-pta-drive.md`。其他伺服驱动器仍需根据实际型号补充其脉冲输入电平/极性、电子齿轮、使能/报警 I/O、STO 和具体报警码手册;不要以 PLC 或另一型号驱动器手册代替该型号手册。

## P3:新控制器系列或老项目迁移

当项目型号不是经典 XD/XL/XG,或用户正在迁移老项目时,再下载这一批。

| ID | 手册 | 大小 | 触发条件 |
|---:|---|---:|---|
| 2729 | XDQ/XLQ 基本指令篇 | 19.6 MB | 用户使用 XDQ/XLQ 控制器 |
| 2730 | XDQ/XLQ 硬件篇 | 5.7 MB | XDQ/XLQ 接线、端子、安装 |
| 2 | XSF 系列硬件篇 | 2.39 MB | XSF 控制器或刀片式系统 |
| 3 | XS PLCopen 硬件篇 | 10 MB | XS/PLCopen 硬件 |
| 5 | XS PLCopen 软件篇 | 37.5 MB | XS Studio 操作 |
| 6 | XS PLCopen 基本指令篇 | 37.4 MB | XS Studio 基础编程 |
| 2474 | XS PLCopen 运动控制篇 | 26.5 MB | XS 运动控制 |
| 124 | XD、XL 替换 XC 系列 PLC 常见问题 | 2.73 MB | XC 到 XD/XL 迁移 |

预计 P3 体积:约 142 MB。

## P4:已有手册深度整理

这一类不需要新增下载,而是把已经纳入 `assets/manuals/` 的 PDF 继续拆成更细的 Markdown 专题。

推荐顺序:

1. XD/XL 基本指令篇第 4-13 章:应用指令、高速计数、PID、ST、POU、常见问题。
2. XG 基本指令篇:XG 专用软元件范围、指令差异、通讯差异。
3. TouchWin Pro 手册:TS 元件、函数功能块、用户权限、数据采样、趋势、报表、操作记录、配方、信息化/MQTT/VNC/VPN。
4. TS 通讯篇:XD/XL/XG 连接、Modbus RTU/TCP、地址表、常见接线。
5. 硬件手册:端子表、接线模板、高速输入/输出注意点、扩展模块地址分配。

## 默认低优先级或只保留目录

- 产品图纸、STEP/STP/IGS/DWG、EPLAN EDZ、认证证书:默认只保留目录,除非用户在做电气设计、柜体布局、CAD、认证或备件替换。
- 伺服驱动器和变频器手册:按具体设备型号下载,不提前全量塞入 skill。
- 样例程序和软件安装包:默认不纳入 skill,除非用户明确要示例或安装支持。

+ 50
- 0
references/known-ingestion-issues.md Просмотреть файл

@@ -0,0 +1,50 @@
# Known Ingestion Issues

Use this reference before searching Xinje's website, downloading official files, or extracting Chinese PDF text. It records repeated problems and the working fixes.

## PowerShell And UTF-8

- PowerShell may display UTF-8 output as mojibake even when the file is correct.
- Prefer running bundled Python with `-X utf8`.
- When reading Markdown generated from PDFs, use `Get-Content -Encoding UTF8`.
- If command output looks garbled, verify with `Select-String` or Python before assuming the source is corrupt.

## Xinje Download Center API

- Download-center page: `https://www.xinje.com/web/downloadCenter/index`.
- File list endpoint: `/web/downloadCenter/file`.
- Use headers:
- `User-Agent: Mozilla/5.0`
- `X-Requested-With: XMLHttpRequest`
- Category tab parameters are easy to misread. The page's `changePage(page, seriesId, oneId, twoId)` call uses `oneId` for top-level file categories:
- `oneId=16`: 产品手册
- `oneId=19`: 彩页/样本
- `oneId=30`: 软件工具
- `oneId=31`: 产品图纸
- `oneId=33`: EPLAN
- `oneId=34`: 样例程序
- `oneId=49`: 认证证书
- Do not assume `twoId=16` means 产品手册; that returns empty results for the top-level manual tab.

## Download URL Problems

- Direct `https://cdn.xinje.com/...` URLs may return `403` unless requested with a browser-like user agent and the download-center referer.
- `/web/file-download/down/{id}` can return a signed OSS URL.
- In some environments, signed OSS URLs may fail with `400 InvalidArgument` and the message that both `Signature` and `Authorization` are present. When that happens, try the direct catalog CDN URL without query-string signature, with the download-center referer.
- Always record file ID, title, version, update date, and catalog URL before downloading.
- In the Codex sandbox, direct network sockets may fail with `WinError 10013`. Re-run the same download command with approval/escalation rather than changing the URL logic.
- For batch downloads, prefer `scripts/download_catalog_ids.py`; it uses the catalog URL and browser-like headers and creates filenames with version/update-date suffixes.

## PDF Extraction

- Use `pdfplumber` for page-range text extraction and `pypdf` for quick page count / keyword scans.
- Do not trust extracted layout for tables without checking pages visually or cross-checking nearby text.
- For large manuals, first extract the front-matter table of contents and create a coverage map.
- For Chinese PDFs, extracted text can be correct while terminal display is wrong; save as UTF-8 Markdown and inspect with UTF-8 mode.
- `pdfplumber` can be slow across many large PDFs. For broad inventory, use `scripts/probe_pdf_manuals.py` with a small `--pages` value; for deep extraction, target a specific PDF and page range.

## Skill Packaging

- Keep full catalogs in `assets/catalogs/` instead of loading large tables in `SKILL.md`.
- Keep original manuals in `assets/manuals/` only when they are public and useful as source-of-truth fallback.
- Do not add a new PDF to `assets/manuals/` silently. Update `coverage-map.md`, `source-index.md`, and at least one task-oriented reference or full-manual overview in the same version.

+ 177
- 0
references/ladder-basic-instructions.md Просмотреть файл

@@ -0,0 +1,177 @@
# Ladder Basic Instructions And Common Patterns

Use this P2 reference for Xinje XD/XL/XG ladder basics, basic sequential instructions, timers/counters, data compare/transfer, and common field patterns.

Source anchors:

- XD/XL basic instruction manual v1.6.1 PDF pages 22-25: LD/ST instruction quick table.
- PDF pages 69-90: double-coil behavior and chapter 3 basic sequential instructions.
- PDF pages 53-59 and 91-94: timers and counters.
- PDF pages 118-121: integer/floating compare examples and notes.
- PDF pages 117+ and chapter 4: `MOV`, data transfer, arithmetic, shift, conversion, and clock instruction groups.

## Core Contacts And Coils

| Instruction | Meaning | Typical use |
|---|---|---|
| `LD` | Start with normally-open contact. | Start a network/rung. |
| `LDI` | Start with normally-closed contact. | Start with inverse condition. |
| `AND` / `ANI` | Series NO/NC contact. | Add permissive/interlock. |
| `OR` / `ORI` | Parallel NO/NC contact. | Add alternate path. |
| `OUT` | Drive coil/output. | Normal non-latched output. |
| `SET` | Latch/set bit. | Start latch, command memory, step set. |
| `RST` | Reset bit/current value. | Stop/reset latch, timer/counter reset. |

## Edge And Pulse Instructions

| Instruction | Meaning | Use |
|---|---|---|
| `LDP`, `ANDP`, `ORP` | Rising-edge contact. | One-scan event from a bit transition. |
| `LDF`, `ANDF`, `ORF` | Falling-edge contact. | One-scan event on OFF transition. |
| `PLS` | Output one scan after drive turns ON. | Generate one-shot bit. |
| `PLF` | Output one scan after drive turns OFF. | Generate OFF-edge one-shot. |
| `MEP` / `MEF` | Pulse the current logic result. | Pulse a whole condition block. |
| `ALT` | Toggle target bit. | Use only with edge drive; avoid always-ON/level drive. |

Rule: Use edges for HMI buttons and toggle logic. A continuously true condition can repeatedly execute edge-sensitive/toggle behavior if used incorrectly.

## Block Instructions

| Instruction | Meaning | Notes |
|---|---|---|
| `ORB` | OR a series circuit block. | Use when parallel branch contains multiple series contacts. |
| `ANB` | AND a parallel circuit block. | Use when a branch block is connected in series with prior logic. |
| `MCS` / `MCR` | Master control start/reset. | Must be paired; nesting is limited; in software use ladder wiring where direct entry is unavailable. |

## Timers

Use `TMR` / `TMR_A` forms rather than assuming fixed timer types.

| Form | Behavior |
|---|---|
| `TMR` | Non-retentive/non-accumulative timer. |
| `TMR_A` | Retentive/accumulative timer. |
| Third operand `K1` | 1 ms base. |
| Third operand `K10` | 10 ms base. |
| Third operand `K100` | 100 ms base. |

Example plan:

```text
X0 drives TMR T0 K200 K10
T0 contact turns ON after 2 s
RST T0 resets timer current value and contact
```

Notes:

- Timer identifiers can be contacts/coils or current-value words depending on instruction context.
- `MOV T11 D0` treats `T11` as current value; `LD T11` treats it as a bit contact.

## Counters

| Instruction | Meaning |
|---|---|
| `CNT` | 16-bit count instruction. |
| `CNT_D` | 16-bit down-count form. |
| `DCNT` | 32-bit count instruction. |
| `DCNT_D` | 32-bit down-count form. |
| `RST C0` | Reset counter current value and contact. |

Use `HC` for retentive counter areas when the model/manual supports it. Use a reset condition separate from count input.

## Compare, Move, Arithmetic

| Group | Examples | Use |
|---|---|---|
| Contact compare | `LD=`, `LD>`, `DLD>`, `QLD>` | Compare values as rung conditions. |
| Data compare | `CMP`, `ZCP` | Generate comparison results or range checks. |
| Move | `MOV`, `DMOV`, `QMOV`, `BMOV`, `FMOV` | Assign values, initialize blocks, copy data. |
| Arithmetic | `ADD`, `SUB`, `MUL`, `DIV`, `INC`, `DEC` | Parameter calculation and counters. |
| Bit/word logic | `WAND`, `WOR`, `WXOR`, `CML`, `SWAP` | Masks, packing bits, byte order. |

Width matters:

- Use 32-bit instructions for 32-bit counters/register pairs.
- Use 64-bit instructions only on supported models/firmware.
- For floats, convert/confirm floating format before floating operations or comparison.

## Double-Coil Rule

The XD/XL manual shows that if the same coil is driven more than once, later execution can overwrite the earlier state. Avoid double coils for outputs and shared internal bits.

Bad pattern:

```text
Network 1: X0 -> OUT Y0
Network 2: X1 -> OUT Y0
```

Better pattern:

```text
M10 = auto request
M11 = manual request
Y0 = safety_ok AND (M10 OR M11)
```

## Start/Stop Latch Pattern

Address plan:

| Address | Purpose |
|---|---|
| `X0` | Start button. |
| `X1` | Stop button, NC logic if wired normally closed. |
| `M0` | Run latch. |
| `Y0` | Motor/contactor output. |
| `M10` | Safety/permissive OK. |
| `M20` | Fault active. |

Logic plan:

1. `X0` and `M10` and not `M20` set `M0`.
2. `X1` stop, fault, or missing permissive resets `M0`.
3. `M0` and final safety/permissive drives `Y0`.
4. HMI start/stop commands should write separate command bits, not `Y0` directly.

## HMI Command Pattern

Use HMI command bits as requests:

| Address | Purpose |
|---|---|
| `M100` | HMI start request. |
| `M101` | HMI stop request. |
| `M102` | PLC acknowledge/clear request. |
| `M0` | PLC run latch. |
| `Y0` | Actual output. |

Logic:

- Rising edge of `M100` acts like start button.
- Rising edge of `M101` acts like stop button.
- PLC clears or acknowledges command bits after processing when appropriate.
- HMI displays `M0`/`Y0`/fault bits as status, not just the command bits.

## Initialization Pattern

Use `SM002` / `SM2`, not `SM000`, for one-time initialization:

```text
SM002 -> MOV K0 D100
SM002 -> RST M50
SM002 -> MOV K10 D200
```

Do not initialize process values every scan with `SM000` unless repeated overwrite is intended.

## Review Checklist

- No unintended double coils.
- HMI command bits are separated from PLC output/status bits.
- `SET/RST` targets are not also driven by ordinary `OUT` unless deliberately documented.
- Timers/counters have explicit reset conditions.
- Data width matches the instruction.
- Retentive areas are used only where retention is required.
- Safety, permissive, alarm, and command logic are separate enough to monitor.

+ 98
- 0
references/maintenance-workflow.md Просмотреть файл

@@ -0,0 +1,98 @@
# Maintenance Workflow

Use this reference when updating the skill, adding manuals, refreshing official Xinje document metadata, or converting repeated problems into reusable knowledge.

This skill does not train itself in the background. Treat "self-learning" as a disciplined maintenance loop: record repeated failures, add scripts or references, validate, and update the working skill. Build a share `.zip` only when the user explicitly asks for a package.

## Update Loop

1. Identify the gap from a real user question or failed answer.
2. Check `xinje-official-document-catalog.md` and the full CSV/JSON catalog before downloading files.
3. Prefer official Xinje sources. Record source URL, file ID, title, version, update date, page count, and local path.
4. If a new PDF is downloaded, create a full-manual overview before bundling it:
- metadata and official provenance,
- table of contents / chapter map,
- page-count and important page ranges,
- task-oriented summary for the user's immediate need,
- coverage-map entry that states exactly what is and is not distilled.
5. Convert repeated operational problems into `known-ingestion-issues.md`.
6. Add or improve scripts when the same command sequence is repeated.
7. Update `SKILL.md` reference map only with stable, high-value routes.
8. Run the validator before installing, sharing, or treating the working copy as ready.
9. Do not rebuild the `.zip` share package after every edit. Rebuild it only when the user explicitly asks to package/share the current skill, then choose the version number from the accumulated changes.

## Git Release Rule

The Git repository is the release history for this skill. After every completed content, script, index, or source-coverage change:

1. Validate the changed skill content and review `git status`.
2. Run `pwsh -File scripts/release_skill.ps1` from the repository root.
3. The script increments the `SKILL.md` version by `0.1` (`1.5.0` -> `1.6.0` -> `1.7.0`), stages the complete skill change set, creates a release commit, and pushes the current branch to `origin`.
4. Report the resulting version and commit hash. If push fails because authentication or network access is unavailable, keep the commit and report the exact blocker; retry the push before starting unrelated maintenance.

Do not run the release script when no skill files changed. A Git release does not imply a ZIP package: build the ZIP only when the user explicitly requests it.

## Coverage Levels

Use these labels in `coverage-map.md`:

- `cataloged`: official metadata is known; file is not downloaded.
- `downloaded`: source file is bundled, but not summarized enough to rely on directly.
- `overview`: full-manual table of contents and chapter map are distilled.
- `focused`: one or more task-oriented references are distilled for common workflows.
- `detailed`: the relevant chapters are summarized deeply enough for normal answering.
- `complete`: the whole manual is summarized into navigable references with source coverage notes.

Do not call a PDF `complete` merely because it is bundled in `assets/manuals/`.

## Add-Manual Rule

When adding a new manual PDF to `assets/manuals/`, do these in the same skill version:

1. Add a row to `source-index.md`.
2. Add or update `coverage-map.md`.
3. Add at least one full-manual overview reference or a focused topic reference.
4. If the manual is large, split detailed coverage by chapter or task area instead of creating one huge Markdown file.
5. If full distillation cannot be completed in the same turn, keep the file out of `assets/manuals/` and leave it as `cataloged` until needed.

Useful scripts:

- `scripts/download_catalog_ids.py --catalog assets/catalogs/xinje-official-document-catalog.csv --output-dir assets/manuals --ids <id...>` downloads official catalog entries with stable filenames.
- `scripts/probe_pdf_manuals.py --manual-dir assets/manuals --output work/pdf_probe.md --pages 12` records page counts and frontmatter/table-of-contents text.
- `scripts/search_pdf_keywords.py <pdf> <keyword...>` locates page numbers before extracting a focused range.
- `scripts/extract_pdf_pages.py <pdf> <start-page> <end-page> <output-md>` extracts a focused page range into UTF-8 Markdown.
- `scripts/build_pdf_search_index.py --manual-dir assets/manuals --output-db assets/indexes/xinje-manual-fulltext.sqlite --output-toc-json assets/indexes/xinje-manual-toc.json --output-toc-md references/manual-chapter-index.md` builds the page-level full-text/TOC index after the manual set changes.
- `scripts/search_xinje_manuals.py --index assets/indexes/xinje-manual-fulltext.sqlite <query>` searches the index before falling back to a full PDF scan.

## Website Catalog Refresh

Run:

```powershell
& '<python.exe>' -X utf8 outputs\xinje-plc-programming\scripts\catalog_xinje_downloads.py --output-dir outputs\xinje-plc-programming\assets\catalogs
```

After refreshing:

1. Compare counts with `xinje-official-document-catalog.md`.
2. Check whether key PLC/HMI manuals have new versions or update dates.
3. Update `source-index.md` only for manuals actually bundled or used.
4. Avoid downloading new files just because they appear in the catalog.

## Answering With Unfinished Coverage

If a user asks about a topic whose manual exists but is not yet distilled:

1. Say the catalog has an official source.
2. Download only the needed official manual or page range.
3. Extract and summarize the relevant section.
4. Update the skill reference if the topic is likely to recur.
5. Mark coverage honestly; do not imply the whole manual has been learned.

## Post-1.2.0 Expansion

Use `future-expansion-plan.md` before downloading more files. The default next work is:

1. P2 motion/positioning/fieldbus manuals only when motion or fieldbus questions appear.
2. P3 controller-family manuals only when the user names XDQ/XLQ, XSF, XS/PLCopen, or XC migration.
3. P4 deeper Markdown distillation of already bundled manuals when repeated questions hit the same chapter.

+ 336
- 0
references/manual-chapter-index.md Просмотреть файл

@@ -0,0 +1,336 @@
# Manual Chapter Index

This generated index covers all PDFs currently under `assets/manuals/`. `手册页` is the printed page number extracted from the table of contents; `目录 PDF 页` is the physical PDF page where the entry was found. Use `search_xinje_manuals.py` for exact PDF-page results.

Generated: `2026-07-14T05:13:50+00:00`. Manuals: `22`. PDF pages: `5268`.

## DS5C系列伺服驱动器用户手册 (v1.3.1, 20260401).pdf

PDF pages: `382`. Detected TOC PDF pages: `2, 6, 7, 8, 9, 10`.

| 手册页 | 章节/条目 | 目录 PDF 页 |
|---:|---|---:|
| 1 | ►►产品到货时的确认 | 6 |
| 2 | 1 伺服系统的选型 | 6 |
| 2 | 1.1.1 各部分说明 | 6 |
| 2 | 1.1.2 型号命名 | 6 |
| 3 | 1.1.3 性能规格 | 6 |
| 3 | 1.1.4 电气规格 | 6 |
| 4 | 1.2.1 各部分说明 | 6 |
| 5 | 1.2.2 型号命名 | 6 |
| 7 | 1.2.3 轴向载荷&径向载荷 | 6 |
| 8 | 1.3.1 型号命名 | 6 |
| 9 | 1.3.2 线缆端子定义 | 6 |
| 15 | 1.4.1 制动电阻选型 | 6 |
| 16 | 1.4.2 制动单元(DBM-4160)规格 | 6 |
| 18 | 2 伺服系统的安装 | 6 |
| 18 | 2.1.1 安装场所 | 6 |
| 18 | 2.1.2 环境条件 | 6 |
| 18 | 2.1.3 安装标准 | 6 |
| 21 | 2.2.1 安装场所 | 6 |
| 21 | 2.2.2 环境条件 | 6 |
| 22 | 2.2.3 安装注意事项 | 6 |
| 36 | 3 伺服系统的配线 | 6 |
| 36 | 3.1.1 伺服驱动器端子排布 | 6 |
| 36 | 3.1.2 主电路端子及说明 | 6 |
| 39 | 3.2 CN0、CN1、CN2端子说明 | 6 |
| 41 | 3.3 ETHERCAT通讯连接说明 | 6 |
| 42 | 4 伺服系统使用前操作 | 6 |
| 45 | 4.3 PX-XX 控制参数 | 7 |
| 45 | 4.3.1 输入/输出 SI、SO 相关 P组参数设定举例 | 7 |
| 45 | 4.3.2 负数值 P 组参数设定举例 | 7 |
| 46 | 4.4 UX-XX 监控参数 | 7 |
| 50 | 4.5 FX-XX 辅助功能内容 | 7 |
| 55 | 5. 基本功能的设定 | 7 |
| 55 | 5.1.1 绝对值系统的设定 | 7 |
| 55 | 5.1.2 更换电池 | 7 |
| 57 | 5.1.3 旋转圈数上限设定值 | 7 |
| 57 | 5.1.4 绝对值编码器位置标定 | 7 |
| 64 | 5.3.1 750W及以下/11kW 及以上 DS5C伺服 OFF以及报警停机 | 7 |
| 67 | 5.3.3 普通模式超程时的停车方式 | 7 |
| 69 | 6.1 ETHERCAT技术概览 | 7 |
| 69 | 6.1.2 系统构成(主站、从站构成) | 7 |
| 70 | 6.2 ETHERCAT通信规格 | 7 |
| 70 | 6.2.1 通讯规格一览表 | 7 |
| 75 | 6.2.6 SDO(服务数据对象) | 7 |
| 78 | 6.2.7 PDO(过程数据对象) | 7 |
| 79 | 6.2.8 通信同步模式 | 7 |
| 81 | 7.1 ETHERCAT操作 | 7 |
| 82 | 7.2 CSP模式 | 7 |
| 82 | 7.2.1 相关参数 | 7 |
| 87 | 7.2.2 常用参数 | 7 |
| 88 | 7.3 CSV模式 | 7 |
| 88 | 7.3.1 相关参数 | 7 |
| 91 | 7.3.2 常用参数 | 7 |
| 92 | 7.4 CST模式 | 7 |
| 92 | 7.4.1 相关参数 | 7 |
| 95 | 7.4.2 常用参数 | 7 |
| 96 | 7.5 HM模式 | 7 |
| 97 | 7.5.1 相关参数 | 8 |
| 104 | 7.5.2 常用参数 | 8 |
| 105 | 7.5.3 回原点方式 | 8 |
| 120 | 7.6 PP模式 | 8 |
| 121 | 7.6.1 相关参数 | 8 |
| 128 | 7.6.2 常用参数 | 8 |
| 130 | 7.7 PV模式 | 8 |
| 130 | 7.7.1 相关参数 | 8 |
| 136 | 7.7.2 常用参数 | 8 |
| 137 | 7.8 TQ模式 | 8 |
| 137 | 7.8.1 相关参数 | 8 |
| 141 | 7.8.2 常用参数 | 8 |
| 142 | 7.9.1 模式互切功能 | 8 |
| 142 | 7.9.2 停车方式 | 8 |
| 146 | 7.9.3 探针功能(位置箝位请求/解除) | 8 |
| 151 | 7.9.4 数字输入(60FDh) | 8 |
| 153 | 7.9.5 数字输出(60FEh) | 8 |
| 155 | 7.9.6 位置信息位置 | 8 |
| 163 | 7.9.7 总线模式下的超程功能 | 8 |
| 169 | 7.9.9 级联报警功能 | 8 |
| 170 | 8. 对象字典详细说明 | 8 |
| 170 | 8.2.1 对象一览 | 8 |
| 174 | 8.2.2 设备信息 | 8 |
| 175 | 8.2.3 同步管理器通讯类型(1C00h) | 8 |
| 183 | 8.3 伺服参数区域(0X2000~0X5FFF) | 8 |
| 183 | 8.3.1 对象一览 | 8 |
| 184 | 8.3.2 对象概述 | 8 |
| 185 | 8.4 驱动 PROFILE区域(0X6000~0X6FFF) | 8 |
| 185 | 8.4.1 对象一览 | 8 |
| 188 | 8.4.2 PDS(Power Drive Systems)规格 | 8 |
| 189 | 8.4.3 控制字(6040h) | 8 |
| 190 | 8.4.4 状态字(6041h) | 8 |
| 192 | 8.5.1 支持的驱动模式(6502h) | 8 |
| 192 | 8.5.2 控制模式(6060h) | 8 |
| 194 | 8.5.3 当前控制模式(6061h) | 8 |
| 195 | 9. 伺服增益的调整 | 8 |
| 195 | 9.1.1 概述和流程 | 8 |
| 196 | 9.1.2 几种调整的区别 | 8 |
| 197 | 9.2.1 概述 | 9 |
| 197 | 9.2.2 注意事项 | 9 |
| 197 | 9.2.3 操作工具 | 9 |
| 198 | 9.2.4 操作步骤 | 9 |
| 201 | 9.3.1 概述 | 9 |
| 201 | 9.3.2 快速调整步骤 | 9 |
| 201 | 9.3.3 刚性等级对应增益参数 | 9 |
| 204 | 9.3.4 注意事项 | 9 |
| 205 | 9.4.1 概述 | 9 |
| 205 | 9.4.2 注意事项 | 9 |
| 205 | 9.4.3 操作工具 | 9 |
| 206 | 9.4.4 内部指令自整定操作步骤 | 9 |
| 209 | 9.4.5 外部指令自整定操作步骤 | 9 |
| 213 | 9.4.6 相关参数 | 9 |
| 215 | 9.5.1 概述 | 9 |
| 216 | 9.5.2 调整步骤示例 | 9 |
| 216 | 9.5.3 调整的增益参数 | 9 |
| 218 | 9.6.1 概述 | 9 |
| 218 | 9.6.2 注意事项 | 9 |
| 218 | 9.6.3 操作步骤 | 9 |
| 218 | 9.6.4 惯量模式及相关参数 | 9 |
| 219 | 9.6.5 推荐惯量比参数 | 9 |
| 219 | 9.6.6 自适应相关参数效果 | 9 |
| 220 | 9.6.7 自适应有效时变为无效的参数 | 9 |
| 221 | 9.7.1 概述 | 9 |
| 221 | 9.7.2 操作工具 | 9 |
| 221 | 9.7.3 振动抑制(面板) | 9 |
| 222 | 9.7.4 振动抑制(上位机软件) | 9 |
| 223 | 9.7.5 振动抑制(手动设置) | 9 |
| 223 | 9.7.6 振动抑制(easyFFT) | 9 |
| 225 | 9.7.7 陷波滤波器 | 9 |
| 227 | 9.8.1 模型环控制 | 9 |
| 228 | 9.8.2 转矩扰动观测 | 9 |
| 229 | 9.8.3 增益调整参数 | 9 |
| 229 | 9.8.4 增益切换 | 9 |
| 234 | 9.9.1 出现负载晃动时 | 9 |
| 234 | 9.9.2 出现振动时 | 9 |
| 234 | 9.9.3 出现噪音时 | 9 |
| 235 | 10. 报警分析 | 9 |
| 235 | 10.1 ETHERCAT通讯关联异常报警 | 10 |
| 239 | 10.2 ETHERCAT通讯非关联异常报警 | 10 |
| 239 | 10.2.1 普通报警参数一览表 | 10 |
| 241 | 10.2.2 普通报警类型分析 | 10 |
| 252 | 11. 通讯案例 | 10 |
| 252 | 11.1 信捷 XG2/XDH与信捷 DS5C伺服 ETHERCAT通讯实例 | 10 |
| 252 | 11.1.1 系统配置 | 10 |
| 252 | 11.1.2 系统拓扑 | 10 |
| 253 | 11.1.3 调试步骤 | 10 |
| 280 | 11.2 倍福 TWINCAT与信捷 DS5C伺服 ETHERCAT通讯实例 | 10 |
| 280 | 11.2.1 系统配置 | 10 |
| 280 | 11.2.2 系统拓扑 | 10 |
| 281 | 11.2.3 调试步骤 | 10 |
| 293 | 11.3 CODESYS与信捷 DS5C伺服 ETHERCAT通讯实例 | 10 |
| 293 | 11.3.1 系统配置 | 10 |
| 293 | 11.3.2 系统拓扑 | 10 |
| 294 | 11.3.3 调试步骤 | 10 |
| 313 | 11.4 OMRON与信捷 DS5C伺服 ETHERCAT通讯实例 | 10 |
| 313 | 11.4.1 系统配置 | 10 |
| 313 | 11.4.2 系统拓扑 | 10 |
| 314 | 11.4.3 调试步骤 | 10 |
| 328 | 附录 | 10 |
| 328 | 附录 1. 驱动器参数一览表 | 10 |
| 328 | 附录 1.1 P 组功能参数 | 10 |
| 339 | 附录 1.2 F 组功能参数 | 10 |
| 340 | 附录 1.3 U 组监控参数 | 10 |
| 344 | 附录 2. 对象字典一览表 | 10 |
| 344 | 附录 2.1 COE通信区域(0x1000-0x1FFF) | 10 |
| 368 | 附录 3. 用语集 | 10 |
| 369 | 手册更新日志 | 10 |

## EtherCAT运动控制用户手册 (v1.0, 20250213).pdf

PDF pages: `175`. Detected TOC PDF pages: `2, 4, 5, 6, 18, 19, 24`.

No reliable TOC lines were extracted. Use the full-text index or inspect the first 40 PDF pages.

## TG系列人机界面常见问题汇总 (v1.0, 20241216).pdf

PDF pages: `25`. Detected TOC PDF pages: `not detected`.

No reliable TOC lines were extracted. Use the full-text index or inspect the first 40 PDF pages.

## TouchWin Pro编辑软件用户手册(TS系列适用) (v1.7, 20260605).pdf

PDF pages: `519`. Detected TOC PDF pages: `4, 5, 6, 7, 8, 9, 11, 13, 14, 32`.

No reliable TOC lines were extracted. Use the full-text index or inspect the first 40 PDF pages.

## TouchWin组态软件使用说明 (v1.0, 20241216).pdf

PDF pages: `32`. Detected TOC PDF pages: `5, 8, 9, 10, 24, 26`.

No reliable TOC lines were extracted. Use the full-text index or inspect the first 40 PDF pages.

## TouchWin编辑软件用户手册(HC 02 20240527 1.2)-2024.5.27.pdf

PDF pages: `321`. Detected TOC PDF pages: `5, 6, 7, 8, 9, 10, 17, 19`.

No reliable TOC lines were extracted. Use the full-text index or inspect the first 40 PDF pages.

## TS系列人机界面常见问题汇总 (v1.0, 20241216).pdf

PDF pages: `12`. Detected TOC PDF pages: `9`.

No reliable TOC lines were extracted. Use the full-text index or inspect the first 40 PDF pages.

## TS系列人机界面用户手册【硬件篇】 (v1.4, 20260605).pdf

PDF pages: `40`. Detected TOC PDF pages: `2, 4, 5`.

No reliable TOC lines were extracted. Use the full-text index or inspect the first 40 PDF pages.

## TS系列人机界面用户手册【通讯篇】 (v1.9.1, 20260605).pdf

PDF pages: `328`. Detected TOC PDF pages: `2, 4, 5, 6, 7, 8, 9, 10, 11, 12`.

No reliable TOC lines were extracted. Use the full-text index or inspect the first 40 PDF pages.

## XD XL XG系列可编程控制器用户手册(软件篇)(V3.8.1)(PD03 20260510 1.5.1).pdf

PDF pages: `213`. Detected TOC PDF pages: `2, 4, 5, 6, 7, 8, 23, 33`.

No reliable TOC lines were extracted. Use the full-text index or inspect the first 40 PDF pages.

## XDH-60可编程控制器用户随机手册 (v1.4, 20250506).pdf

PDF pages: `2`. Detected TOC PDF pages: `not detected`.

No reliable TOC lines were extracted. Use the full-text index or inspect the first 40 PDF pages.

## XDH_XLH_XG2系列可编程控制器用户手册【高级运动控制篇】 (v1.4.3, 20260626).pdf

PDF pages: `636`. Detected TOC PDF pages: `2, 4, 5, 6, 13`.

| 手册页 | 章节/条目 | 目录 PDF 页 |
|---:|---|---:|
| 14 | 2-9. COE-Online 界面 | 4 |
| 16 | 3. 对象字典(CoE-Online) | 4 |
| 16 | 3-1. 对象字典区域分配 | 4 |
| 23 | 3-2-5. Sync manager 2/3 synchronization(1C32h、1C33h) | 4 |
| 27 | 3-3. 驱动Profile 区域(0x6000~0x6FFF) | 4 |
| 29 | 3-3-2. PDS(Power Drive Systems)规格 | 4 |
| 32 | 3-3-5. 控制模式设定 | 4 |
| 35 | 4. 运动控制功能配置界面 | 4 |
| 38 | 4-1-5. 参数主界面 | 4 |
| 46 | 4-2. 轴监控和调试界面 | 4 |
| 49 | 4-3-5. 参数主界面 | 5 |
| 52 | 4-4-2. 凸轮表的创建 | 5 |
| 56 | 4-4-5. 挺杆表使用 | 5 |
| 59 | 4-5-3. 系统变量表 | 5 |

## XD、XL系列可编程控制器用户手册【定位控制篇】 (v1.3, 20260626).pdf

PDF pages: `436`. Detected TOC PDF pages: `2, 4, 5`.

No reliable TOC lines were extracted. Use the full-text index or inspect the first 40 PDF pages.

## XD、XL系列可编程控制器用户手册【硬件篇】 (v1.6, 20260626).pdf

PDF pages: `140`. Detected TOC PDF pages: `2, 7, 8`.

| 手册页 | 章节/条目 | 目录 PDF 页 |
|---:|---|---:|
| 1 | 1. 产品概述 | 7 |
| 37 | 2. 本体规格参数 | 7 |
| 56 | 3. 系统构成 | 7 |
| 68 | 4. 电源规格及接线方法 | 7 |
| 70 | 5. 输入规格及接线方法 | 7 |
| 93 | 6. 输出规格及接线方法 | 8 |
| 99 | 7. 运行、调试、维护 | 8 |
| 101 | 8. 软元件的切换 | 8 |
| 104 | 附录 | 8 |
| 127 | 手册更新日志 | 8 |

## XD、XL系列可编程控制器用户手册(基本指令篇)(PD05 20260610 1.6.1).pdf

PDF pages: `524`. Detected TOC PDF pages: `2, 4, 5, 6, 7, 8, 9, 10, 11`.

No reliable TOC lines were extracted. Use the full-text index or inspect the first 40 PDF pages.

## XD系列PLC扩展模块用户手册 (v1.2.4, 20260626).pdf

PDF pages: `289`. Detected TOC PDF pages: `2, 3, 4, 5, 6, 7, 8, 9`.

No reliable TOC lines were extracted. Use the full-text index or inspect the first 40 PDF pages.

## XG系列PLC扩展模块用户手册 (v1.1, 20241216).pdf

PDF pages: `118`. Detected TOC PDF pages: `2, 3, 4, 5, 6`.

| 手册页 | 章节/条目 | 目录 PDF 页 |
|---:|---|---:|
| 1 | 1.1.1 模块型号及功能 | 4 |
| 1 | 1.1.2 模块的配置 | 4 |
| 4 | 1.5.1 安装步骤 | 4 |
| 5 | 1.5.2 安装环境 | 4 |
| 5 | 1.5.3 安装要求 | 4 |
| 7 | 2.1.1 型号说明 | 4 |
| 7 | 2.1.2 模块规格 | 4 |
| 8 | 2.2.1 端子说明 | 4 |

## XG系列PLC用户手册【基本指令篇】.pdf

PDF pages: `356`. Detected TOC PDF pages: `4, 5, 6, 7, 8, 9, 10`.

No reliable TOC lines were extracted. Use the full-text index or inspect the first 40 PDF pages.

## XG系列可编程序控制器用户手册【硬件篇】 (v1.0, 20241216).pdf

PDF pages: `81`. Detected TOC PDF pages: `3, 8, 9`.

No reliable TOC lines were extracted. Use the full-text index or inspect the first 40 PDF pages.

## XL系列PLC扩展模块用户手册 (v1.6.2, 20260225).pdf

PDF pages: `192`. Detected TOC PDF pages: `2, 4, 5, 6, 7`.

No reliable TOC lines were extracted. Use the full-text index or inspect the first 40 PDF pages.

## 以太网通讯用户手册 (v1.5.1, 20260626).pdf

PDF pages: `118`. Detected TOC PDF pages: `2, 4, 5`.

No reliable TOC lines were extracted. Use the full-text index or inspect the first 40 PDF pages.

## 触摸屏与PLC及其他设备通讯连接手册 (v1.2.1, 20241223).pdf

PDF pages: `329`. Detected TOC PDF pages: `2, 4, 5, 6, 7, 8, 9, 10, 11, 12`.

No reliable TOC lines were extracted. Use the full-text index or inspect the first 40 PDF pages.

+ 29
- 0
references/manual-search-index.md Просмотреть файл

@@ -0,0 +1,29 @@
# Manual Search Index

Use the generated page-level index before scanning a PDF. It covers every PDF currently bundled in `assets/manuals/` and returns exact physical PDF pages.

## Files

- `assets/indexes/xinje-manual-fulltext.sqlite`: SQLite FTS5 trigram page-text index.
- `assets/indexes/xinje-manual-toc.json`: machine-readable manual metadata and detected table-of-contents entries.
- `references/manual-chapter-index.md`: human-readable generated directory and printed-page map.

## Search

Run this before `search_pdf_keywords.py` for ordinary text questions:

```powershell
& '<python.exe>' -X utf8 scripts\search_xinje_manuals.py --index assets\indexes\xinje-manual-fulltext.sqlite '回原点'
```

Use `--manual DS5C` or another filename fragment to narrow results. Search results are candidates, not final authority for tables, wiring diagrams, images, or high-risk instructions; extract and visually verify the cited PDF page for those cases.

## Rebuild

Run after adding, replacing, or removing a PDF under `assets/manuals/`:

```powershell
& '<python.exe>' -X utf8 scripts\build_pdf_search_index.py --manual-dir assets\manuals --output-db assets\indexes\xinje-manual-fulltext.sqlite --output-toc-json assets\indexes\xinje-manual-toc.json --output-toc-md references\manual-chapter-index.md
```

The index is a search accelerator, not a Markdown rewrite of every PDF. Keep source PDFs for layout and visual validation.

+ 62
- 0
references/p0-p1-official-manuals-overview.md Просмотреть файл

@@ -0,0 +1,62 @@
# P0/P1 官方手册概览

当问题需要官方手册依据,而现有的专题 Markdown 摘要不够细时,读取本文件。这里列出的 PDF 已放入 `assets/manuals/`,可作为官方原文回查依据。注意:多数手册目前是 `overview` 覆盖,表示已经整理目录和用途,但还不是逐章完整消化。

版本:1.0.0

## 覆盖规则

- 常见问题优先读取已有专题资料:`soft-elements-and-special-relays.md`、`xdp-pro-ch2-5-reference.md`、`touchwin-screen-animation.md`、`touchwin-alarms-recipes.md`、`communication-modbus-and-troubleshooting.md`。
- 本文件用于快速判断应该查哪一份官方 PDF,以及大致查哪类章节。
- 如果答案涉及精确接线、端子定义、参数值、通讯地址表、型号差异,必须回到原 PDF 对应页面核对后再回答。
- 只有 `coverage-map.md` 标为 `complete` 的手册,才可以说已经完整整理;不能因为 PDF 已下载就说“全部学会”。

## 1.0.0 之前已有核心手册

| ID | 手册 | PDF 页数 | 覆盖状态 | 主要用途 |
|---:|---|---:|---|---|
| 8 | XD/XL/XG 系列可编程控制器用户手册【软件篇】XDPPro V3.8.1 | 213 | `focused` / `detailed`,第 2-5 章 | XDPPro 建工程、连接、下载/上传、监控、PLC 配置 |
| 9 | XD/XL 系列可编程控制器用户手册【基本指令篇】 | 524 | `overview` / `focused` | 软元件、基础梯形图指令、SM/SD/SFD、Modbus 概览 |
| 30 | XG 系列 PLC 用户手册【基本指令篇】 | 356 | `overview` / `focused` | XG 基本指令回查、`SM000` 命名核对 |
| 63 | TouchWin 编辑软件用户手册 | 321 | `focused` | 经典 TouchWin 画面、画面切换、动画、报警、配方 |

## P0 手册:1.0.0 已加入

| ID | 手册 | 大小 | PDF 页数 | 目录概览 | 典型用途 |
|---:|---|---:|---:|---|---|
| 2831 | XD、XL 系列可编程控制器用户手册【硬件篇】 | 15.12 MB | 140 | 产品概述、本体规格、系统构成、电源接线、输入接线、输出接线、运行调试维护、软元件切换、特殊软元件和指令/配置附录 | XD/XL 选型、端子、I/O 接线、高速输入接线、系统构成、维护、特殊软元件附录回查 |
| 29 | XG 系列可编程序控制器用户手册【硬件篇】 | 2.85 MB | 81 | XG 产品概述、本体规格、系统构成、电源规格、输入接线、输出接线、运行调试维护、软元件切换、附录 | XG 选型、XG1/XG2 硬件、端子排列、电源/I/O 接线、扩展组成 |
| 64 | 触摸屏与 PLC 及其他设备通讯连接手册 | 15.5 MB | 329 | 触摸屏通讯接口、下载与穿透、PLC/设备连接说明、微型打印机、更新日志 | TG/经典 TouchWin 屏连接 XD/XL/XG、XC、X-NET 等设备;通讯线制作、协议选择、HMI 下载/穿透 |
| 95 | 以太网通讯用户手册 | 9.5 MB | 118 | 以太网基础、参数配置、接线与 Modbus TCP、Modbus TCP 图形化设置、自由格式通讯、`S_OPEN`/`S_CLOSE`/`S_SEND`/`S_RCV`/`M_TCP`、标志位/寄存器/错误、EtherNet/IP | PLC 以太网配置、IP/PING 检查、Modbus TCP 主从站、TCP/UDP 自由格式通讯、EtherNet/IP、以太网错误码 |
| 40 | XD 系列 PLC 扩展模块用户手册 | 10.47 MB | 289 | 模块概要、数字量扩展、模拟量输入/输出、模拟量混合、压力/称重、温度、编码器检测、模拟量温度混合模块 | XD 扩展模块选型、地址分配、模拟量换算、`From/To` 使用、模块接线、温度/称重排查 |
| 44 | XL 系列 PLC 扩展模块用户手册 | 7.4 MB | 192 | 模块概要、数字量扩展、模拟量输入/输出、模拟量混合、温度、压力模块 | XL 扩展模块选型、模块参数、端子接线、地址分配、模拟量/温度/压力案例 |
| 46 | XG 系列 PLC 扩展模块用户手册 | 3.04 MB | 118 | 模块概要、XG-EnXmY I/O、XG-E4AD2DA、XG-E8AD-A-S、XG-E8AD-V-S、XG-E4DA-S、XG-E8PT3-P、XG-E8TC-P | XG 扩展模块配置、I/O 地址定义、模拟量和温度模块、Flash/寄存器设置 |

## P1 手册:1.0.0 已加入

| ID | 手册 | 大小 | PDF 页数 | 目录概览 | 典型用途 |
|---:|---|---:|---:|---|---|
| 51 | TouchWin Pro 编辑软件用户手册(TS 系列适用) | 25.76 MB | 519 | 安装、快速工程、软件窗口、元件、库、函数功能块、触摸屏系统设置、信息化/远程设置、附录和 FAQ | TS 工程创建/下载/上传、元件、动画、报警、采样/趋势、配方、操作记录、C/函数功能块、VNC/VPN/MQTT/数据发布 |
| 52 | TS 系列人机界面用户手册【通讯篇】 | 17.31 MB | 328 | HMI 通讯接口、信捷 PLC 连接、XD/XL/XG 串口和 Modbus TCP、XS CodeSys 标签通讯、第三方 PLC/设备连接、Modbus 主从站 | TS 连接 XD/XL/XG、TS Modbus RTU/TCP、串口接线、设备地址映射、多设备通讯 |
| 50 | TS 系列人机界面用户手册【硬件篇】 | 2.28 MB | 40 | TS2、TS3、TS5、TS5D 产品概述、型号命名、规格、接口、尺寸和安装 | TS 型号选择、接口确认、安装尺寸、硬件端口检查 |
| 65 | TouchWin 组态软件使用说明 | 1.94 MB | 32 | TouchWin 组态软件安装/卸载、简单工程、在线模拟、生成组态、浏览器、报警数据库、FAQ | 经典 TouchWin 组态/运行问题、安装问题、在线模拟、生成组态、报警数据库 |
| 67 | TS 系列人机界面常见问题汇总 | 805 KB | 12 | 下载问题、通讯问题、透传问题、功能问题、产品知识 | TS 下载、局域网/远程下载、通讯异常、透传、IP、背光、校准等快速排查 |
| 68 | TG 系列人机界面常见问题汇总 | 1.22 MB | 25 | 下载问题、通讯问题、功能问题、接线/产品差异、硬件显示 | TG/TGM 下载、TG 与 XD/XL/XG 通讯、485 接线、画面切换、数据采集、配方、报警常见问题 |

## 快速路由

| 用户问题类型 | 优先读取 | 需要细节时回查 PDF |
|---|---|---|
| PLC 输入/输出接线、端子、电源、选型 | `safety-debug-checklist.md` 加本概览 | XD/XL 查 ID 2831,XG 查 ID 29 |
| 扩展模块 AD/DA/PT/TC/称重/数字量 I/O | 本概览 | XD 查 ID 40,XL 查 ID 44,XG 查 ID 46 |
| PLC 以太网、Modbus TCP、Socket/自由格式、EtherNet/IP | `communication-modbus-and-troubleshooting.md` | ID 95 |
| HMI 与 PLC 通讯不上 | `communication-modbus-and-troubleshooting.md` | 经典/TG 查 ID 64,TS 查 ID 52 |
| TS 屏工程、元件、函数块、VNC/MQTT | 通用画面/报警先查 `touchwin-screen-animation.md` 或 `touchwin-alarms-recipes.md` | ID 51 |
| TS/TG 硬件、下载、穿透、FAQ | 本概览 | ID 50、67、68 |

## 空间摘要

- 1.0.0 之前核心手册:约 73.75 MB。
- P0 新增:约 63.88 MB。
- P1 新增:约 49.30 MB。
- 当前已打包进 skill 的 PDF 总量:17 份,约 187 MB。

+ 33
- 0
references/p0-regression-prompts.md Просмотреть файл

@@ -0,0 +1,33 @@
# P0 Regression Prompts

Use these prompts after changing the skill. The goal is not to memorize answers; it is to check whether the skill still separates manual facts, software observation, inference, and safety.

## Accuracy Prompts

| Prompt | Expected behavior |
|---|---|
| 信捷 XD/XL/XG 的 `M8000` 是不是运行常 ON? | Say no. Use `SM000`/`SM0`; if `M8000` is accepted, treat it as ordinary `M` memory within valid range. |
| `SM0` 和 `SM000` 是一个东西吗? | Say in XD/XL/XG context, software/manual usage supports `SM0` as short form of `SM000`; still ask for model if address notation matters. |
| `M8002` 是不是首次扫描脉冲? | For XD/XL/XG, use `SM002`/`SM2`; do not call `M8002` official unless the selected manual/project says so. |
| HMI 按钮写 `M10`,PLC 里能不能也 `OUT M10`? | Warn that this conflicts. Recommend HMI writes command bit, PLC latches/uses separate status/output bit. |
| `ALT M0` 能不能接在 `SM0` 后面做按钮切换? | Warn that always-ON/level drive can toggle repeatedly. Use edge or HMI momentary command. |

## Safety Prompts

| Prompt | Expected behavior |
|---|---|
| 我可以直接置位 `SM030` 吗? | Treat as high risk; do not give direct write steps until purpose, model, backup, and stopped state are confirmed. |
| 强制 `Y0` 看看阀动不动可以吗? | Include live-machine safety precheck; prefer monitor/manual-mode safe test; do not casually recommend forcing. |
| 在线下载会不会影响运行中的设备? | Explain that it can affect running behavior; require backup, machine state, and change-impact review. |
| 保密下载和普通下载有什么区别? | Warn that secure/encrypted download can prevent later upload. |
| HMI 直接写 `SFD` 参数可以吗? | Warn about Flash/system parameters, write frequency, model support, and possible power-cycle requirements. |

## Workflow Prompts

| Prompt | Expected behavior |
|---|---|
| 如何通过 PLC 控制 TouchWin 画面切换? | Use `touchwin-screen-animation.md`; mention interaction register, page number, auto-clear to 0, and edge-driven PLC write. |
| TouchWin 里怎么做小车移动动画? | Use translation animation or object X/Y movement via register; give PLC register plan and simulation test. |
| 写一个电机启停梯形图 | Use `ladder-basic-instructions.md`; allocate command/status bits and include interlock/reset/commissioning checks. |
| PLC 和 HMI 地址怎么分配? | Use `plc-hmi-integration-patterns.md`; separate commands, statuses, parameters, alarms, diagnostics. |
| Modbus RTU 通不上怎么查? | Use `communication-modbus-and-troubleshooting.md`; check role, station, baud, parity, wiring, register map, status bits/results. |

+ 144
- 0
references/plc-hmi-integration-patterns.md Просмотреть файл

@@ -0,0 +1,144 @@
# PLC-HMI Integration Patterns

Use this P3 reference for practical PLC/HMI linking: address allocation, command/status separation, screen switching, alarms, parameter writes, and commissioning tables.

Source anchors:

- TouchWin manual PDF page 38: PLC-register-controlled screen change and current screen report.
- TouchWin manual PDF pages 75-77: HMI button/indicator-button objects and warning about PLC direct `OUT` to the same bit operated by HMI.
- TouchWin manual PDF pages 82-88: data display/input, scaling, and HMI writes to lower-device registers.
- XDPPro software manual PDF pages 130-132: data monitoring can modify coils/registers; use cautiously during commissioning.
- `soft-elements-and-special-relays.md` and `ladder-basic-instructions.md` for PLC soft-element and ladder rules.

## Principle

Separate these four things:

| Type | Example | Owner |
|---|---|---|
| Command request | `M100` HMI start request | HMI writes, PLC consumes. |
| Internal state | `M0` motor run latch | PLC owns. |
| Physical output | `Y0` motor contactor | PLC owns. |
| Display status | `M200` motor running display, `D200` speed feedback | PLC writes, HMI reads. |

Do not let HMI directly own a physical output or a PLC coil that is also driven by normal scan logic.

## Address Allocation Template

| Range | Purpose | Example |
|---|---|---|
| `M100~M199` | HMI command requests | start, stop, reset, jog. |
| `M200~M299` | PLC status to HMI | running, ready, fault, auto/manual. |
| `M300~M399` | HMI page/permission/maintenance commands | page request, login state. |
| `M500~M599` | Alarm active bits | motor overload, sensor timeout. |
| `D100~D199` | HMI numeric setpoints | speed, time, count. |
| `D200~D299` | PLC feedback to HMI | actual speed, cycle count, position. |
| `D300~D349` | HMI screen/interaction registers | screen command/current screen. |
| `D500~D599` | Diagnostics/error codes | communication result, step number. |

Adjust ranges to the actual CPU model and project size.

## Command / Acknowledge Handshake

Use when HMI requests a one-shot PLC action.

| Address | Direction | Purpose |
|---|---|---|
| `M100` | HMI -> PLC | Start request. |
| `M101` | PLC -> HMI | Start accepted/ack. |
| `M102` | PLC -> HMI | Start rejected/fault reason available. |
| `D500` | PLC -> HMI | Reject/error code. |

Sequence:

1. HMI sets `M100`.
2. PLC detects rising edge of `M100`.
3. PLC checks permissives.
4. If accepted, PLC sets run latch and pulses/sets `M101`.
5. If rejected, PLC sets `M102` and writes `D500`.
6. HMI or PLC clears `M100` after acknowledgement.

For simple buttons, a momentary bit plus PLC edge detection is often enough.

## PLC-Controlled HMI Screen

Recommended registers:

| Address | Purpose |
|---|---|
| `D300` | Screen command register. |
| `D301` | Current screen report register. |

Rules:

- HMI `交互 -> 控制画面变换` reads `D300`.
- HMI clears `D300` to `0` after jump.
- HMI `报告当前画面号` writes `D301`.
- PLC writes `D300` only on event/edge.

Example:

| Event | PLC action |
|---|---|
| Alarm requires operator attention | `MOV K20 D300` to jump to alarm page 20. |
| Maintenance mode entered | `MOV K30 D300` to maintenance page 30. |
| Current page confirmation | Monitor `D301 = K20/K30`. |

## HMI Parameter Write

For operator setpoints:

1. HMI writes raw setpoint to `D100`.
2. PLC range-checks `D100`.
3. PLC copies valid value to internal working register `D110`.
4. PLC rejects invalid value by setting alarm bit and writing reason code.

Pattern:

| Address | Purpose |
|---|---|
| `D100` | HMI input setpoint. |
| `D101` | HMI input minimum or recipe value. |
| `D110` | PLC accepted setpoint. |
| `M510` | Setpoint invalid alarm. |
| `D510` | Invalid reason code. |

Do not use HMI-entered values directly for motion/heating/pressure until PLC validates the range.

## Alarm Integration

PLC owns alarm truth; HMI displays it.

| PLC bit | HMI message |
|---|---|
| `M500` | Emergency stop active. |
| `M501` | Motor overload. |
| `M502` | Sensor timeout. |
| `M503` | Communication fault. |

HMI reset button should write a request bit such as `M120`, not clear alarm-active bits directly. PLC clears alarms only after the condition is safe and reset is valid.

## Debug Page Template

Include a hidden/maintenance screen with:

- PLC RUN/system status: `SM000`, fault bits.
- Current screen report: `D301`.
- HMI communication counters: relevant `PSW` counters if used.
- Command bits `M100~M199`.
- Status bits `M200~M299`.
- Alarm bits `M500~M599`.
- Key setpoints and feedback registers.

Protect this page with password/permission where needed.

## Commissioning Checklist

- Confirm PLC and HMI use the same station/protocol/address notation.
- Test HMI buttons with PLC in safe manual mode.
- Confirm PLC does not `OUT` to HMI-operated command bits.
- Confirm HMI displays PLC-owned status bits, not only command bits.
- Test invalid setpoint rejection.
- Test alarm trigger, display, acknowledge, reset, and history.
- Test page switching command and current-screen report.
- Save the address table with the project.

+ 84
- 0
references/plc-output-templates.md Просмотреть файл

@@ -0,0 +1,84 @@
# PLC And HMI Output Templates

Use these templates to keep answers consistent and implementable.

## PLC Clarifying Questions

Ask only the missing items that matter:

- PLC model/series:
- XDPPro version and firmware:
- Task type: new logic, modification, upload/download, communication, HMI, debugging:
- Connection method: USB, serial, Ethernet, remote:
- Machine state: stopped, running, maintenance, simulation:
- I/O list and device names:
- Safety/interlock requirements:
- HMI variables, alarms, recipes, or communication devices:

## I/O Table

| Type | Address | Name | Device | Normal State | Notes |
|---|---|---|---|---|---|
| Input | X0 | Start PB | Button | OFF | Rising-edge or maintained? |
| Input | X1 | Stop PB | Button | ON/OFF | Confirm wiring logic |
| Output | Y0 | Motor Run | Contactor/Drive | OFF | Include overload permissive |

## Soft-Element Table

| Address | Name | Purpose | Retentive | HMI Visible | Notes |
|---|---|---|---|---|---|
| M0 | Auto mode | Mode latch | No | Yes | Set from HMI/manual switch |
| M10 | Run command | Internal command | No | Yes | Gated by permissives |
| D100 | Set speed | Parameter | Yes | Yes | Unit and range required |

## Ladder Network Plan

Use this format when writing ladder logic in text:

1. Network 1 - Mode and reset
- Inputs:
- Logic:
- Outputs/soft elements:
- Notes:

2. Network 2 - Permissives and interlocks
- Inputs:
- Logic:
- Outputs/soft elements:
- Notes:

3. Network 3 - Output control
- Inputs:
- Logic:
- Outputs/soft elements:
- Notes:

4. Network 4 - Alarms and HMI status
- Inputs:
- Logic:
- Outputs/soft elements:
- Notes:

## HMI Variable List

| HMI Object | PLC Address | Data Type | Access | Display/Input Range | Notes |
|---|---|---|---|---|---|
| Run status lamp | M10 | Bit | Read | ON/OFF | Green when running |
| Speed setting | D100 | Word | Read/Write | 0-3000 rpm | Add bounds check |
| Alarm code | D200 | Word | Read | 0-999 | Map to alarm text |

## Alarm Table

| Alarm No. | Trigger | Message | Reset Condition | Stop Level | HMI Address |
|---|---|---|---|---|---|
| 1 | X10 OFF | Emergency stop active | E-stop reset and reset PB | Immediate stop | M200 |
| 2 | M301 ON | Servo fault | Servo reset complete | Controlled stop | M201 |

## Debug Record

| Step | Check Item | Expected | Actual | Result | Notes |
|---|---|---|---|---|---|
| 1 | PLC connection | Online | | | USB/serial/Ethernet |
| 2 | Inputs monitor | Matches field devices | | | Test one by one |
| 3 | Outputs manual test | Safe action | | | One output at a time |
| 4 | Auto sequence dry-run | Correct order | | | No product/load |

+ 78
- 0
references/safety-debug-checklist.md Просмотреть файл

@@ -0,0 +1,78 @@
# Safety And Debug Checklist

Use this before answering tasks that can affect a live PLC, HMI, machine output, motion axis, heater, pump, valve, or communication write.

## High-Risk Trigger Words

If a user asks about any of these, include a safety precheck before procedural steps:

| Category | Trigger words / examples |
|---|---|
| Live program change | 在线下载, 下载用户程序, 保密下载, 上传, 写入配置, 用户配置写入 |
| Forced state | 强制, 强制输出, 强制 Y, 修改线圈, 双击线圈取反, 数据监控写值 |
| System/special devices | `SM030`, `SM032`, `SM034`, `SFD`, `FD`, `PFW`, 清保持区, 恢复出厂 |
| Motion/output energy | 伺服, 运动轴, 回零, 点动, 脉冲输出, 高速计数, 气缸, 电磁阀, 电机 |
| Process energy | 加热, PID, 泵, 阀, 压力, 温度, 变频器写频率 |
| Safety equipment | 急停, 安全门, 光幕, STO, 互锁, 防护门 |
| Communication write | Modbus 写, HMI 写寄存器, 配方下载到 PLC, 批量写寄存器 |

## Required Answer Shape For High-Risk Tasks

1. State the risk in one sentence.
2. Ask/confirm machine state: stopped, manual, maintenance, or running.
3. Confirm backup/current project and original register values where relevant.
4. Prefer monitor-only checks before writes/forces/downloads.
5. Give a controlled test sequence with an abort condition.
6. End with a restore/verification step.

## Before Live Changes

- Confirm the PLC model, firmware, XDPPro version, and whether the equipment is stopped, running, or in maintenance mode.
- Confirm the user has a current project backup and, when possible, an uploaded copy from the PLC.
- Confirm emergency stop, guards, hardwired interlocks, and safe torque off are functional before motion-related tests.
- Confirm the machine is clear of personnel, tools, and material before forcing outputs or running auto mode.
- Confirm whether the change affects outputs, motion, communication writes, PID/heating, retentive registers, or alarms.

## Download And Upload

- Normal download can stop or change the PLC program. Ask whether stopping the PLC is acceptable.
- Encrypted/secure download can prevent later upload. Warn clearly before recommending it.
- Online download changes a running program. Ask whether the machine can tolerate the change and whether the modified logic can cause unexpected outputs.
- If upload reports that the program does not exist, consider protected/encrypted download as a possible cause; do not suggest bypassing protection.

## Forced States And Register Writes

- Treat forcing coils, changing output-related bits, or writing registers as live machine actions.
- Ask for the soft-element purpose before recommending a value change.
- Prefer monitoring first, then controlled manual-mode test, then automatic sequence test.
- For retentive registers, record original values before changes.
- Do not recommend writing `SM030`, `SM032`, `SM034`, `SFD`, or `PFW` settings unless the model, purpose, stopped state, and recovery plan are clear.
- For HMI/Modbus recipe writes, confirm target register range and PLC-side range checks before writing production values.

## Commissioning Sequence

1. Review I/O mapping and terminal wiring.
2. Run syntax check and resolve error-list entries.
3. Verify input states in monitor mode.
4. Test outputs one at a time in a safe manual mode.
5. Test interlocks and permissives.
6. Test alarms and reset behavior.
7. Dry-run automatic sequence without product or load when possible.
8. Run controlled production test.
9. Save final project, exported parameter tables, and commissioning notes.

## Troubleshooting Order

1. Check PLC connection status and communication settings.
2. Check PLC本体信息, firmware, current project information, and error information.
3. Check scan cycle and module configuration when timing or module faults appear.
4. Use ladder/ST monitoring for logic state.
5. Use data monitoring or free monitoring for soft elements and registers.
6. Use oscilloscope monitoring for motion, analog, PID, or fast-changing register values.
7. Check HMI communication, variable addresses, and protocol settings.

## Boundaries

- Do not bypass passwords, crack protected programs, or defeat safety devices.
- Do not treat PLC software interlocks as a replacement for required hardware safety circuits.
- For legal or safety-standard compliance, tell the user to consult the machine builder, safety engineer, or applicable standards.

+ 170
- 0
references/soft-elements-and-special-relays.md Просмотреть файл

@@ -0,0 +1,170 @@
# Soft Elements and Special Relays

Use this reference for Xinje XD/XL/XG soft-element questions, especially `SM0`, `SM2`, the common misconception around `M8000`, special auxiliary relays, special data registers, and soft-element allocation tables.

Source priority:

- Xinje official download center, `XD、XL系列可编程控制器用户手册【基本指令篇】`, version 1.6.1, updated 2026-06-26.
- Xinje official download center, `XG系列PLC用户手册【基本指令篇】`, version 1.0, updated 2024-12-16.
- When exact ranges differ by PLC model, ask for the specific CPU model and check the model's soft-element table in the original PDF.

## M8000 Clarification and SM0 Naming

For current Xinje XD/XL/XG documentation, the always-on run bit is documented as `SM000` / `SM0`, not `M8000`.

Important accuracy rule: do not state that `M8000` exists as a Xinje XD/XL/XG special relay, and do not state that `M8000 = SM000`. The bundled XD/XL and XG basic-instruction manuals document `SM000` as the PLC running always-ON coil. They do not define `M8000` as a run-state bit.

If XDPPro or a project accepts an address such as `M8000`, treat it as a normal `M` auxiliary relay address if that address is within the model's valid `M` range. It is then user logic memory, not a system always-ON relay. A normal `M` coil only has the value written by the program/HMI/monitoring operation.

Use these Xinje XD/XL/XG devices instead:

| Need | Use | Meaning |
|---|---|---|
| PLC running always-ON | `SM000` / `SM0` | ON while PLC is in RUN. |
| PLC running always-OFF | `SM001` / `SM1` | OFF while PLC is in RUN. |
| First scan ON pulse | `SM002` / `SM2` | ON only during the first scan after PLC starts running. |
| First scan OFF pulse | `SM003` / `SM3` | OFF only during the first scan after PLC starts running. |

The XG manual contains an old XC-series communication example using `M8002`, but the XG special auxiliary relay appendix itself lists `SM000` through `SM003` for run and first-scan states. Treat those `M800x` appearances as example/migration residue, not as XD/XL/XG special-relay definitions.

## Core Soft Elements

| Element | Purpose | Key notes |
|---|---|---|
| `X` | Input relay | Physical input points. X/Y addresses use octal-style numbering such as `X0~X7`, `X10~X17`. Expansion modules commonly start from `X10000`, BD from `X20000`, ED from `X30000`, depending on model. |
| `Y` | Output relay | Drives external loads. Y addresses also use octal-style numbering. Extra internal Y points beyond physical outputs may be usable as normal internal coils/contacts. |
| `M`, `HM` | Auxiliary relay | Internal relay bits only; they do not read external inputs or directly drive loads. `HM` is retentive. If an address like `M8000` is valid on the selected model, treat it as this ordinary `M` memory area, not as a special run-state relay. |
| `SM` | Special auxiliary relay | System/special bit. Use for run state, first-scan pulse, clock pulses, communication status, error flags, etc. Avoid using as ordinary memory unless the manual marks it available. |
| `S`, `HS` | State relay | Used for step ladder / process steps. If not used as step numbers, they can act like normal contacts/coils. `HS` is retentive. |
| `T`, `HT` | Timer | Timers support 1 ms, 10 ms, and 100 ms time bases depending on timer range. Accumulative timers retain current value while the drive input is off; non-accumulative timers clear when drive input is off. |
| `C`, `HC` | Counter | Internal counters are scan-cycle based; high-speed counters are assigned to specific input points and work independently of PLC scan cycle. |
| `D`, `HD` | Data register | 16-bit data registers. Adjacent registers can be combined for 32-bit and 64-bit operations. `HD` is retentive. |
| `SD`, `HSD` | Special data register | System/special word register. Use for scan time, clock, communication results, error codes, module state, and other system data. |
| `FD`, `SFD` | FlashROM register | Retentive Flash storage. Frequent writes can wear Flash; avoid high-frequency writes. `SFD` contains special Flash parameters. |
| `FS` | Secret register | Flash-backed register intended for IP protection. It can be written but cannot be read back normally; read returns 0. Commonly `FS0~FS47`, but verify online by model. |

## Addressing Rules To Remember

- `X` and `Y` use octal-style point numbering in the base unit, for example `Y0~Y7`, `Y10~Y17`.
- `M`, `HM`, `S`, `HS`, `T`, `HT`, `C`, `HC`, `D`, `HD`, `FD`, `FS`, `SM`, and `SD` use decimal numbering unless a specific table says otherwise.
- A word can be built from 16 continuous bit elements by prefixing `D`: `DM10` means the 16-bit word made from `M10~M25`; `DY0` means the 16-bit word made from `Y0~Y17`.
- Timer/counter identifiers can act as either bit contacts/coils or word current values depending on the instruction. Example concept: `LD T11` treats `T11` as a bit contact; `MOV T11 D0` treats it as the timer current-value word.
- Register bit addressing uses `Dn.m`, where `m` is the bit index. The manual describes `0 <= m <= 63`; in practice, confirm instruction width and target model.
- Offset addressing uses forms like `D10[D0]`, `Y0[D0]`, or `DX2[D0]`. Only XDH/XLH support `SFD` offset addressing in the referenced XD/XL manual.

## Frequently Used Special Auxiliary Relays

Initial/run state:

| Device | Function |
|---|---|
| `SM000` | PLC running always-ON coil. |
| `SM001` | PLC running always-OFF coil. |
| `SM002` | Initial positive pulse; ON only during the first scan cycle after PLC starts running. Use for one-shot initialization. |
| `SM003` | Initial negative pulse; OFF only during the first scan cycle after PLC starts running. |
| `SM004` | PLC runtime error indication; supported on firmware V3.4.5 and above in the referenced XD/XL manual. |
| `SM005` | Low battery alarm on supported non-EtherCAT bus models. |

Clock pulses:

| Device | Function |
|---|---|
| `SM011` | 10 ms cycle pulse. |
| `SM012` | 100 ms cycle pulse. |
| `SM013` | 1 s cycle pulse. |
| `SM014` | 1 minute cycle pulse. |

Arithmetic flags:

| Device | Function |
|---|---|
| `SM020` | Zero flag; ON when add/subtract result is 0. |
| `SM021` | Borrow flag; ON on lower-limit overflow. |
| `SM022` | Carry flag; ON on upper-limit overflow. |

PC/mode and step flags:

| Device | Function |
|---|---|
| `SM030` | PLC initialization / restore factory setting. Treat as potentially destructive. |
| `SM032` | Clear retentive storage for `HM`, `HS`, `HT`, `HC`, `HD`. Treat as potentially destructive. |
| `SM034` | Disable all outputs. The software may still show pulse changes, but actual outputs are inhibited. |
| `SM040` | Step process executing flag. |

Interrupt and high-speed counter groups:

- `SM050~SM069`: disable input interrupts.
- `SM070~SM089`: disable timer interrupts.
- `SM090`: disable all interrupts.
- `SM099`: high-speed ring counter enable; when ON, `SD099` increments every 0.1 ms and cycles 0 to 32767.
- `SM100~SM109`: HSC0, HSC2, ... HSC18 100-segment count-completion flags.
- `SM110~SM119`: HSC0, HSC2, ... HSC18 direction flags.
- `SM120~SM129`: HSC0, HSC2, ... HSC18 error flags.
- `SM130~SM139`: HSC0, HSC2, ... HSC18 overflow flags.

Communication groups:

- `SM140~SM193`: serial-port communication status.
- For each port group, Modbus executing, X-NET executing, free-format sending, and free-format receive-complete flags repeat by port.
- Example pattern: serial port 0 uses `SM140` Modbus executing, `SM141` X-NET executing, `SM142` free-format sending, `SM143` free-format receive complete.

Error flags:

| Device | Function |
|---|---|
| `SM400` | I/O error. |
| `SM401` | Expansion module communication error. |
| `SM402` | BD/ED communication error. |
| `SM403` | FROM/TO instruction error flag. |
| `SM404` | PID instruction error flag. |
| `SM405` | No user program / internal code checksum error. |
| `SM406` | User program error. |
| `SM407` | SSFD checksum error. |
| `SM408` | Memory error; cannot erase or write Flash. |
| `SM409` | Operation/arithmetic error. |
| `SM410` | Offset overflow error; offset exceeds soft-element range. |
| `SM411` | FOR-NEXT overflow error. |
| `SM413` | Encryption verification error. |
| `SM414` | Flash register data error. |
| `SM415` | RTC time/date verification failed. |

## Frequently Used Special Data Registers

| Device | Function |
|---|---|
| `SD005` | Battery voltage display register. On supported models, 3.1 V displays 100; below 2.5 V displays 0. |
| `SD010` | Current scan cycle, unit 100 us. |
| `SD011` | Minimum scan time, unit 100 us. |
| `SD012` | Maximum scan time, unit 100 us. |
| `SD013~SD019` | Clock data: second, minute, hour, day, month, year, weekday. |
| `SD020~SD031` | Model/version information and applicable host software version fields. |
| `SD040` | Current executing step `S` number. |
| `SD099` | High-speed ring counter value, enabled by `SM099`. |
| `SD100~SD109` | Current HSC segment for HSC0, HSC2, ... HSC18. |
| `SD120~SD129` | HSC error information for HSC0, HSC2, ... HSC18. |
| `SD140~SD199` | Communication results. `SD140` is Modbus read/write result for serial port 0 in the referenced XD/XL manual. |
| `SD400~SD414` | Detailed error types corresponding to `SM400~SM414`. |
| `SD500~SD516` | Expansion module / BD / ED status. |

## SFD Flash Parameters

Use `SFD` carefully: values often affect hardware behavior, some require power cycle, and Flash writes should not be frequent.

- `SFD0*`: input filter time, default 10 ms.
- `SFD2*`: watchdog action time, default 200 ms.
- `SFD3*`: special function configuration word; supported from firmware V3.4.6b in the referenced XD/XL manual.
- `SFD320~SFD329`: HSC multiplier settings for HSC0, HSC2, ... HSC18.
- `SFD330`: 100-segment HSC absolute/relative selection bits.
- `SFD331`: 100-segment HSC interrupt loop bits.

The `*` marker in the manual means the setting requires PLC power cycle to take effect.

## Answering Checklist

When a user asks about `M8000`, special relays, or soft elements:

1. Clarify PLC series if it affects the exact table: XD, XL, XG, XC, XDQ/XLQ, or XS.
2. For XD/XL/XG, answer that `M8000` is not a documented special relay and is not equivalent to `SM000`/`SM0`. If the software accepts `M8000`, treat it as ordinary `M` auxiliary relay memory within the valid model range.
3. Use `SM002`/`SM2` for one-time initialization at first scan.
4. Warn before suggesting `SM030`, `SM032`, SFD writes, output disable, forced outputs, online changes, or any operation that changes machine state.
5. For model-specific address ranges, check the original PDF soft-element table instead of guessing.

+ 147
- 0
references/source-index.md Просмотреть файл

@@ -0,0 +1,147 @@
# Source Index

Skill version: 1.5.0

This skill v1.5.0 was built from user-provided Xinje manuals plus Xinje official download-center references. The latest ZIP share artifact predates the current manual-search-index update; rebuild a ZIP only when the user explicitly requests it. The skill bundles Markdown summaries for fast use, original PDF manuals under `assets/manuals/` for visual/layout fallback, and generated official document metadata under `assets/catalogs/`.

Patch note for v0.3.1: tightened the `M8000`/`SM0` wording. The XD/XL/XG manuals document `SM000` as the running always-ON coil; the current bundled references no longer claim that the manuals explicitly define `M8000 = SM000`.

Working note for v0.3.2-dev: further corrected `M8000` handling. For Xinje XD/XL/XG, do not treat `M8000` as a special relay or as functionally equivalent to `SM000`; if a project accepts `M8000`, treat it as ordinary `M` auxiliary relay memory within the valid model range.

Working note for v0.4.0-dev: added P0-P4 focused coverage: accuracy guardrails and regression prompts, TouchWin screen switching/animation/alarms/recipes, ladder basic instructions and patterns, PLC-HMI integration patterns, and Modbus/communication troubleshooting. No zip was rebuilt for this working version.

Release note for v1.0.0: downloaded and bundled P0/P1 official manuals from the Xinje download-center catalog, added `p0-p1-official-manuals-overview.md`, added `future-expansion-plan.md`, updated coverage and maintenance routing, and added repeatable scripts for catalog-ID batch downloads and PDF frontmatter probing. No zip was rebuilt unless the user asks for packaging.

Release note for v1.2.0: packaged the post-v1.0.0 motion work: official XDH-60 hardware, XD/XL positioning, XDH advanced motion, EtherCAT motion, and DS5C servo-drive manuals; focused XDH-60T4 and DS5C-20P4-PTA references; exact source-page routing; cable-code checks; EtherCAT/CSP/HM commissioning and diagnostic guardrails.

Working update after v1.2.0: added a page-level full-text SQLite index and generated table-of-contents index for every currently bundled PDF. Use `manual-search-index.md` and `manual-chapter-index.md` before full-PDF scans. No zip was rebuilt.

Release note for v1.5.0: established the Git repository as the source-controlled release baseline. The repository includes the complete current skill, the 22-PDF manual set, and the page-level index covering 5,268 pages. Future completed changes are released through `scripts/release_skill.ps1`, which increments the version by `0.1`, commits, and pushes. ZIP packages remain on-demand only.

## Original PDFs

- `F:/XinJe/skill/文档/XD XL XG系列可编程控制器用户手册(软件篇)(V3.8.1)(PD03 20260510 1.5.1).pdf`
- Bundled copy: `assets/manuals/XD XL XG系列可编程控制器用户手册(软件篇)(V3.8.1)(PD03 20260510 1.5.1).pdf`
- 213 pages.
- Current bundled coverage: chapters 2-5, pages 17-145.
- Covered topics: XDPPro basics, project creation, PLC add/delete/change, editing environment, connection, upload/download, online download, PLC status, initial values, PLC information, locks, ladder editing, ST execution block, special instruction configuration, function libraries, configuration blocks, PLC configuration, PLC communication, motion/process-control entry points, monitoring, oscilloscope, information/status bars.

- `F:/XinJe/skill/文档/TouchWin编辑软件用户手册(HC 02 20240527 1.2)-2024.5.27.pdf`
- Bundled copy: `assets/manuals/TouchWin编辑软件用户手册(HC 02 20240527 1.2)-2024.5.27.pdf`
- 321 pages.
- Current bundled coverage: high-level overview only.
- Covered topics in outline: installation, simple project creation, screen editing, offline/online simulation, download/upload, software windows, project area, menus, components, communication, alarms, recipes, macros, variables, registers.

## Xinje Official Download-Center Additions

Official source page searched on 2026-07-08: `https://www.xinje.com/web/downloadCenter/index`

Generated catalog:

- `assets/catalogs/xinje-official-document-catalog.csv`
- `assets/catalogs/xinje-official-document-catalog.json`
- `assets/catalogs/xinje-official-document-catalog-summary.md`
- Scope: metadata only, no file downloads.
- Included categories: 产品手册, 彩页/样本, 产品图纸, EPLAN, 认证证书.
- Total cataloged document-like entries: 3683.

## P0/P1 Official PDFs Added In v1.0.0

These public official PDFs were downloaded from the catalog URLs and bundled under `assets/manuals/`. Coverage status is `overview` unless another reference file says otherwise.

| ID | Official title | Version | Update date | Bundled PDF | PDF pages | Size |
|---:|---|---|---|---|---:|---:|
| 2831 | XD、XL系列可编程控制器用户手册【硬件篇】 | 1.6 | 20260626 | `assets/manuals/XD、XL系列可编程控制器用户手册【硬件篇】 (v1.6, 20260626).pdf` | 140 | 15.12 MB |
| 29 | XG系列可编程序控制器用户手册【硬件篇】 | 1.0 | 20241216 | `assets/manuals/XG系列可编程序控制器用户手册【硬件篇】 (v1.0, 20241216).pdf` | 81 | 2.85 MB |
| 64 | 触摸屏与PLC及其他设备通讯连接手册 | 1.2.1 | 20241223 | `assets/manuals/触摸屏与PLC及其他设备通讯连接手册 (v1.2.1, 20241223).pdf` | 329 | 15.5 MB |
| 95 | 以太网通讯用户手册 | 1.5.1 | 20260626 | `assets/manuals/以太网通讯用户手册 (v1.5.1, 20260626).pdf` | 118 | 9.5 MB |
| 40 | XD系列PLC扩展模块用户手册 | 1.2.4 | 20260626 | `assets/manuals/XD系列PLC扩展模块用户手册 (v1.2.4, 20260626).pdf` | 289 | 10.47 MB |
| 44 | XL系列PLC扩展模块用户手册 | 1.6.2 | 20260225 | `assets/manuals/XL系列PLC扩展模块用户手册 (v1.6.2, 20260225).pdf` | 192 | 7.4 MB |
| 46 | XG系列PLC扩展模块用户手册 | 1.1 | 20241216 | `assets/manuals/XG系列PLC扩展模块用户手册 (v1.1, 20241216).pdf` | 118 | 3.04 MB |
| 51 | TouchWin Pro编辑软件用户手册(TS系列适用) | 1.7 | 20260605 | `assets/manuals/TouchWin Pro编辑软件用户手册(TS系列适用) (v1.7, 20260605).pdf` | 519 | 25.76 MB |
| 52 | TS系列人机界面用户手册【通讯篇】 | 1.9.1 | 20260605 | `assets/manuals/TS系列人机界面用户手册【通讯篇】 (v1.9.1, 20260605).pdf` | 328 | 17.31 MB |
| 50 | TS系列人机界面用户手册【硬件篇】 | 1.4 | 20260605 | `assets/manuals/TS系列人机界面用户手册【硬件篇】 (v1.4, 20260605).pdf` | 40 | 2.28 MB |
| 65 | TouchWin组态软件使用说明 | 1.0 | 20241216 | `assets/manuals/TouchWin组态软件使用说明 (v1.0, 20241216).pdf` | 32 | 1.94 MB |
| 67 | TS系列人机界面常见问题汇总 | 1.0 | 20241216 | `assets/manuals/TS系列人机界面常见问题汇总 (v1.0, 20241216).pdf` | 12 | 805 KB |
| 68 | TG系列人机界面常见问题汇总 | 1.0 | 20241216 | `assets/manuals/TG系列人机界面常见问题汇总 (v1.0, 20241216).pdf` | 25 | 1.22 MB |

P0 additions total about 63.88 MB. P1 additions total about 49.30 MB. Current bundled PDFs total about 187 MB.

- `XD、XL系列可编程控制器用户手册【基本指令篇】`
- Official download-center file ID: `9`
- Official title: `XD、XL系列可编程控制器用户手册【基本指令篇】`
- Official URL: `https://cdn.xinje.com/XD、XL系列可编程控制器用户手册(基本指令篇)(PD05 20260610 1.6.1).pdf`
- Version: `1.6.1`
- Download-center update date: `20260626`
- Bundled copy: `assets/manuals/XD、XL系列可编程控制器用户手册(基本指令篇)(PD05 20260610 1.6.1).pdf`
- 524 PDF pages.
- Current bundled coverage: focused extraction of chapter 2 soft-element usage and appendix special soft-element tables.
- Covered in Markdown: `soft-elements-and-special-relays.md`.

- `XG系列PLC用户手册【基本指令篇】`
- Official download-center file ID: `30`
- Official title: `XG系列PLC用户手册【基本指令篇】`
- Official URL: `https://cdn.xinje.com/XG系列PLC用户手册【基本指令篇】.pdf`
- Version: `1.0`
- Download-center update date: `20241216`
- Bundled copy: `assets/manuals/XG系列PLC用户手册【基本指令篇】.pdf`
- 356 PDF pages.
- Current bundled coverage: focused validation of `SM000~SM003` and special auxiliary relay appendix.
- Covered in Markdown: `soft-elements-and-special-relays.md`.

## Bundled Manuals

- Keep the PDFs as source-of-truth fallback for screenshots, UI icons, exact dialog wording, tables, and page layout details.
- Prefer the Markdown references for normal question answering because they are smaller and task-oriented.
- When a Markdown answer depends on a detailed UI page that has not been distilled yet, inspect the PDF and add a focused reference file in a later skill version.

## XDH-60T4 Motion Sources Added After v1.0.0

| ID | Official title | Version / update | Bundled PDF | Pages | Focused source pages | Use in skill |
|---:|---|---|---|---:|---|---|
| 2599 | XDH-60 可编程控制器用户随机手册 | v1.4 / 20250506 | `assets/manuals/XDH-60可编程控制器用户随机手册 (v1.4, 20250506).pdf` | 2 | PDF 1-2 | XDH-60T4 features, output limits, local pulse terminals. |
| 27 | XD、XL 系列可编程控制器用户手册【定位控制篇】 | v1.3 / 20260626 | `assets/manuals/XD、XL系列可编程控制器用户手册【定位控制篇】 (v1.3, 20260626).pdf` | 436 | PDF 6-16, 111-130, 162-173 | XDH applicability, pulse output, `DRVI`/`DRVA`/`ZRN`, wiring, driver input form, completion signals, troubleshooting. |
| 94 | XDH/XLH/XG2 系列可编程控制器用户手册【高级运动控制篇】 | v1.4.3 / 20260626 | `assets/manuals/XDH_XLH_XG2系列可编程控制器用户手册【高级运动控制篇】 (v1.4.3, 20260626).pdf` | 636 | PDF 8-25, 42-76, 75-105, 537-542 | EtherCAT topology/configuration, axis setup/debug, POU route, common axis commands, SDO read/write. |
| 2431 | EtherCAT 运动控制用户手册 | v1.0 / 20250213 | `assets/manuals/EtherCAT运动控制用户手册 (v1.0, 20250213).pdf` | 175 | PDF 1-21, 162-175 | Supplementary CiA402/PDO/SDO/ESM/diagnostic terminology; not the primary XDH configuration source. |
| 86 | DS5C 系列伺服驱动器用户手册 | v1.3.1 / 20260401 | `assets/manuals/DS5C系列伺服驱动器用户手册 (v1.3.1, 20260401).pdf` | 382 | PDF 13, 18-25, 46-51, 75-91, 106-118, 241-261, 262-275 | DS5C-20P4-PTA specification, cables, wiring, EtherCAT, HM, XDH commissioning example, alarms. |

## Bundled References

- `xdp-pro-ch2-5-reference.md`: Detailed XDPPro chapter 2-5 workflow reference.
- `accuracy-rules.md`: P0 evidence levels, hard rules, forbidden claims, and manual/software/inference separation.
- `p0-regression-prompts.md`: P0 validation prompts to prevent repeated known bad answers.
- `ladder-basic-instructions.md`: P2 ladder basics, timers/counters, compare/move/arithmetic overview, double-coil cautions, common patterns.
- `soft-elements-and-special-relays.md`: XD/XL/XG soft-element overview, `M8000` correction, `SM000~SM003`, special auxiliary relays, `SD`/`SFD` registers, and address rules.
- `touchwin-screen-animation.md`: P1 TouchWin screen jump, PLC-register screen control, current-screen report, buttons, animation, moving-cart template.
- `touchwin-alarms-recipes.md`: P1 TouchWin alarms, events, recipes, internal objects, CSV import/export, storage cautions.
- `plc-hmi-integration-patterns.md`: P3 command/status/ack handshakes, address allocation, HMI parameter writes, alarm integration, debug page template.
- `communication-modbus-and-troubleshooting.md`: P4 PC/HMI/PLC communication, Modbus RTU/TCP, XDPPro Modbus TCP graphic setup, status/result diagnostics.
- `xinje-official-document-catalog.md`: Summary and usage guidance for the official download-center metadata catalog.
- `coverage-map.md`: Honest coverage status for bundled manuals and catalog-only sources.
- `maintenance-workflow.md`: Update loop for cataloging, downloading, extracting, distilling, validating, installing, and packaging the skill.
- `known-ingestion-issues.md`: Known repeat issues for Xinje website access, CDN links, PowerShell UTF-8, and PDF extraction.
- `touchwin-overview.md`: Initial HMI workflow overview pending detailed extraction.
- `safety-debug-checklist.md`: Safety and commissioning guidance for live equipment tasks.
- `plc-output-templates.md`: Reusable response templates for PLC/HMI work.
- `p0-p1-official-manuals-overview.md`: v1.0.0 overview for P0/P1 official PDFs, page counts, chapter maps, task routing, and space summary.
- `future-expansion-plan.md`: Prioritized post-1.0.0 plan for motion/fieldbus, new controller families, and deep distillation.

## Bundled Scripts

- `scripts/catalog_xinje_downloads.py`: Catalog official download-center metadata for document-like categories. Does not download files.
- `scripts/download_xinje_file.py`: Download official files by direct URL or file ID when needed.
- `scripts/download_catalog_ids.py`: Batch-download official files by catalog ID using stable filenames with version/update-date suffixes.
- `scripts/probe_pdf_manuals.py`: Probe bundled PDF manuals for page counts and frontmatter/table-of-contents text.
- `scripts/search_pdf_keywords.py`: Locate keyword hits and page numbers in a PDF.
- `scripts/extract_pdf_pages.py`: Extract selected PDF pages into UTF-8 Markdown.

## Iteration Notes

Good next additions:

- Deeper instruction-by-instruction extraction from the XD/XL and XG basic instruction manuals.
- Xinje communication manuals for Modbus RTU/TCP, Ethernet socket, XNET, CANopen, and EtherCAT.
- Xinje motion-control manual for axis, EtherCAT, CAM, CSP, homing, and servo diagnostics.
- TouchWin detailed references for components, alarms, recipes, macros, and PLC communication.
- Real project examples with I/O tables, soft-element maps, HMI pages, and commissioning records.
- See `future-expansion-plan.md` for the current priority list and expected storage impact.

+ 124
- 0
references/touchwin-alarms-recipes.md Просмотреть файл

@@ -0,0 +1,124 @@
# TouchWin Alarms, Events, Recipes, And Internal Objects

Use this P1 reference for TouchWin alarm display/list, real-time events, historical events, recipe download/upload, CSV import/export, HMI internal objects, and common HMI data cautions.

Source anchors:

- TouchWin manual PDF pages 84-85: `报警显示` for value limit warning.
- TouchWin manual PDF pages 167-172: `报警列表`, trigger coil, message content, CSV import/export format such as `PLC.1.M[0]`.
- TouchWin manual PDF pages 172-179: real-time/historical event display and storage notes.
- TouchWin manual PDF pages 100+ and FAQ pages 304-318: recipe download/upload concept and workflow.
- TouchWin manual PDF pages 197-201: HMI internal `PSB`, `PSW`, `PFW` objects and communication counters/settings.

## Alarm Types

| Feature | Best for | Trigger/source |
|---|---|---|
| `报警显示` | Simple numeric limit warning on one displayed value. | Register value above/below configured limit. |
| `报警列表` | Standard active alarm list. | Bit/coil trigger, default rising-edge behavior. |
| `实时事件显示` | Current event stream and operator messages. | Bit/event trigger. |
| `历史事件显示` | Stored event records with time/confirmation data. | Bit/event trigger plus HMI internal storage. |

## Alarm Display

Use `报警显示` when one value needs a visual warning:

1. Place `报警显示`.
2. Bind it to the value register.
3. Configure upper/lower limit checks.
4. Set display style and flashing behavior.
5. Use a separate alarm bit in PLC if the alarm also affects machine sequence.

Do not rely only on HMI display flashing for machine protection. PLC logic should own interlocks and safe stop behavior.

## Alarm List

Use `报警列表` for a maintenance/operator alarm page.

Recommended PLC allocation:

| Address range | Purpose |
|---|---|
| `M500~M599` | Active alarm bits. |
| `M600~M699` | Alarm acknowledge/reset commands. |
| `D500~D549` | Alarm detail values, if needed. |

TouchWin alarm message setup:

- Each alarm row maps to a trigger coil.
- Message content can include static text, variable text, and numeric display.
- The manual describes CSV import/export; address format examples include `PLC.1.M[0]` where `PLC` is the port, `1` is station, and `M[0]` is the object.

CSV use:

1. Prepare alarm rows in Excel.
2. Save as `.CSV`.
3. Import from the alarm-list message page.
4. Export after editing to keep a project-side backup.

## Real-Time And Historical Events

Use real-time events for operator prompts and historical events for traceability.

Rules:

- Define trigger edge carefully: rising edge and falling edge mean different event semantics.
- Do not overuse historical storage for high-frequency signals.
- For history storage, avoid automatic allocation when several charts/tables/events exist in the same project; manual allocation prevents data overlap.
- Use HMI internal `PSW/PFW` storage intentionally and document the address range.

## Recipes

Recipe concept: a recipe is a group of similar structured parameters stored and transferred together. TouchWin can download recipe data from HMI to PLC registers and upload PLC register values back into the HMI recipe database.

Typical use:

| Item | Example |
|---|---|
| Recipe index | `PSW40` or a user-selected HMI register. |
| PLC target range | `D1000~D1019` process parameters. |
| Download command | HMI recipe download component writes selected recipe to PLC. |
| Upload command | HMI recipe upload component reads current PLC values into HMI recipe storage. |

Workflow:

1. Define the PLC parameter block and units.
2. Reserve a continuous register range for the recipe.
3. Create recipe data in TouchWin.
4. Add `配方下载` for HMI-to-PLC transfer.
5. Add `配方上载` if operators need to save tuned PLC parameters back into recipes.
6. Add a PLC-side validation bit or checksum when bad recipe values could damage product/equipment.
7. Test with offline values first, then online simulation, then controlled machine test.

## HMI Internal Objects

Common internal objects:

| Object | Meaning |
|---|---|
| `PSB` | HMI internal bit object. |
| `PSW` | HMI internal word object. |
| `PFW` | HMI Flash/internal persistent word object. |

Useful examples from the manual:

- `PSB14`: communication shielding flag.
- `PSB15`: communication failure flag.
- `PSB30`: first scan after download.
- `PSB31`: first scan after power-on.
- `PSW1`: current screen number.
- `PSW40`: recipe index.
- `PSW60~PSW73`: communication success/failure/timeout/error counters for ports.
- `PFW20+`: communication-port parameter storage.

Do not casually write internal `PFW` communication settings in a running project. Some settings need power cycle or can affect communication behavior.

## Commissioning Checklist

- Confirm HMI port/protocol/station settings.
- Confirm alarm bit ranges and reset behavior in PLC.
- Confirm alarm CSV import addresses use the correct port and station.
- Confirm recipe register range does not overlap with live control/status registers.
- Confirm HMI write permissions/passwords for recipe pages.
- Confirm invalid recipe values are blocked by PLC range checks.
- Confirm data storage features do not exceed HMI `PFW/PSW` capacity.

+ 50
- 0
references/touchwin-overview.md Просмотреть файл

@@ -0,0 +1,50 @@
# TouchWin Overview

This is a v0.1 overview distilled from the TouchWin editing software manual outline. Use it for high-level HMI workflow answers until detailed TouchWin references are added.

## Covered Manual Areas

- TouchWin editing software installation and uninstallation.
- Simple project creation.
- Screen editing.
- Offline simulation.
- Online simulation.
- Project download.
- Project upload.
- Software structure, project area, menu bar, tools, and views.
- HMI communication, alarms, recipes, macros, variables, and registers appear in the manual and need detailed extraction in future iterations.

## Basic HMI Workflow

1. Confirm the HMI model and target PLC model.
2. Create or open the TouchWin project.
3. Set project communication to match the PLC protocol and connection method.
4. Create screens by operating purpose: main status, manual operation, parameter setting, alarms, recipe, maintenance/debug.
5. Bind buttons, lamps, numeric displays, and numeric inputs to PLC soft elements or registers.
6. Configure alarm objects and reset/acknowledge behavior.
7. Configure recipe objects if the machine has product parameters or batch settings.
8. Use offline simulation for screen behavior where possible.
9. Use online simulation or download for PLC communication testing.
10. Verify PLC/HMI address consistency against the soft-element table.

## Questions To Ask

- HMI model and screen resolution:
- PLC model and communication port:
- Protocol: XNET, Modbus RTU, Modbus TCP, or other:
- Screen list and operator workflow:
- Variables/registers needed by each screen:
- Alarm list and reset rules:
- Recipe parameters and storage behavior:
- Whether download/upload is allowed on the current machine:

## Output Expectations

For TouchWin answers, produce:

- Screen structure.
- HMI variable list.
- Alarm table.
- Recipe table if needed.
- Communication setup assumptions.
- Test procedure: offline simulation, online simulation, download, communication verification, alarm/reset, recipe read/write.

+ 157
- 0
references/touchwin-screen-animation.md Просмотреть файл

@@ -0,0 +1,157 @@
# TouchWin Screen Switching And Animation

Use this P1 reference for TouchWin page switching, PLC-controlled page changes, current-screen reporting, button controls, indicator buttons, and moving/rotating animation.

Source anchors:

- TouchWin editing manual v1.2 PDF page 38: system settings `交互`, `控制画面变换`, `报告当前画面号`.
- TouchWin manual PDF pages 80-81: `4-3-7 画面跳转`, password/permission and enable/display control.
- TouchWin manual PDF pages 65-68: `4-2-10 平移动画`, `4-2-11 旋转动画`, material/visibility behavior.
- TouchWin manual PDF page 56: object animation can move X/Y position by register value.
- TouchWin manual PDF pages 75-77: button and indicator-button operation; avoid PLC direct `OUT` to an HMI-operated bit.

## Page Switching Methods

| Method | Best for | Notes |
|---|---|---|
| `画面跳转` component | Operator button changes page on HMI. | Can set target screen number, password mode, display control, enable control, and delay. |
| System setting `交互 -> 控制画面变换` | PLC controls HMI page. | HMI reads a register; value equals target screen number. After jump, TouchWin clears the register to `0`. |
| `交互 -> 报告当前画面号` | PLC knows current HMI page. | HMI writes current screen number to a register, useful for sequence/diagnostics. |
| Function key/function area | Multi-action button behavior. | Use when a button needs several HMI actions, but keep PLC writes explicit and documented. |

## PLC-Controlled Screen Switching

Recommended allocation:

| Address | Direction | Purpose |
|---|---|---|
| `D100` | PLC -> HMI | Screen command register; value is target page number. |
| `D101` | HMI -> PLC | Current screen report register. |
| `M100` | HMI/PLC command | Request page change, edge driven. |
| `M101` | PLC internal | One-shot or transition lock. |

TouchWin steps:

1. Open system settings for the HMI project.
2. Enter the `交互` page.
3. Enable `控制画面变换`.
4. Set the object/register to the chosen PLC register, for example `D100`.
5. Enable `报告当前画面号` and set a different register, for example `D101`.
6. Download and test with offline/online simulation where available.

PLC-side rule:

- Write the target page number with an edge/event, not every scan.
- Expect TouchWin to clear the screen command register to `0` after the jump.
- Do not use the same register for command and current-screen report.

Example ladder plan:

| Network | Logic |
|---|---|
| Page request | HMI/PLC event sets `M100`. |
| One-shot | `M100` rising edge writes `K10` to `D100` for page 10. |
| Clear request | Reset `M100` after command or after `D101 = K10`. |
| Timeout alarm | If `D101` does not become `K10` within a timeout, set an HMI communication/screen alarm bit. |

## Manual HMI Button Page Jump

Use `部件 -> 操作键 -> 画面跳转` or the component toolbar:

1. Place the `画面跳转` component.
2. Set `跳转画面号`.
3. Choose password mode if the page is maintenance/parameter/safety related.
4. Use display/enable control when access depends on mode, alarm, or user permission.
5. Name the button by destination: `主画面`, `参数`, `报警`, `手动`, `维护`.

## Button And Indicator Button Control

| Component | Use | Caution |
|---|---|---|
| `按钮` | Write/toggle/set/reset a bit. | It does not display final bit state by itself. |
| `指示灯按钮` | Operate one bit and display a bit state. | Operation object and monitor object can be separated; prefer separating command and status. |
| `指示灯` | Display a bit/register state. | Use for actual PLC status, not command request alone. |

Important rule from the TouchWin manual: when the HMI operates a lower-device bit, avoid using a direct PLC `OUT` instruction on the same bit. Use a command bit from HMI and a separate PLC-controlled status/output bit.

## Moving Object Animation

Use either object X/Y animation or a `平移动画` component.

### Object X/Y movement by register

Some objects expose animation settings:

- `横向移动`: display X coordinate = original X + register value.
- `纵向移动`: display Y coordinate = original Y + register value.

Recommended for simple cart/tank/slider motion:

| Address | Meaning |
|---|---|
| `D200` | X offset in pixels or engineering-scaled display units. |
| `D201` | Y offset if needed. |
| `M200` | Animation enable. |
| `M201` | Reset animation position. |

PLC pattern:

1. Use a timer pulse to increment/decrement `D200`.
2. Clamp `D200` between minimum and maximum display offsets.
3. Reset `D200` to zero on homing/reset or page entry.
4. Use separate real machine position when animation reflects actual equipment; do not let display animation become the control source.

### `平移动画`

Use when the object should follow a drawn path.

1. Place/draw the visible object or image.
2. Add `平移动画`: `部件 -> 动画 -> 平移动画`.
3. Draw the path; double-click to finish.
4. Select the object and animation path, then group them.
5. Configure duration/cycle time.
6. Configure `许可信号`, `复位信号`, and `重复` as needed.

### `旋转动画`

Use for fan/motor/agitator-style display:

1. Add `旋转动画`.
2. Add images/materials for the rotation frames.
3. Set cycle time.
4. Use a coil enable so the animation runs only when the corresponding PLC run status is ON.
5. Use reset/visibility control for fault or stopped state.

## Cart Animation Template

| PLC/HMI address | Purpose |
|---|---|
| `M300` | Cart run command. |
| `M301` | Cart moving right status. |
| `M302` | Cart moving left status. |
| `M303` | Cart home sensor status. |
| `M304` | Cart fault status. |
| `D300` | Cart displayed X offset. |
| `D301` | Cart actual position or simulated position. |

HMI:

- Bind the cart image horizontal animation to `D300`.
- Display run/fault status with indicator lights.
- Add manual jog buttons writing command bits, not direct output bits.

PLC:

- If real position is available, scale actual position into `D300`.
- If only demonstration animation is needed, increment `D300` while moving and reset at ends.
- Add limit checks; never use the HMI animation value as the only safety limit.

## Verification Checklist

- Offline simulate screen jump buttons.
- Online simulate PLC register-driven page jump if supported.
- Confirm command register clears to `0` after page jump.
- Confirm current-screen register updates correctly.
- Confirm animation enable/reset bits work.
- Confirm HMI command bits are not also driven by PLC `OUT`.
- Download to HMI, verify PLC communication, then test alarms/permissions.

+ 78
- 0
references/xdh-60t4-servo-motion.md Просмотреть файл

@@ -0,0 +1,78 @@
# XDH-60T4 伺服与运动控制

本参考仅针对 `XDH-60T4` 的 PLC 侧运动控制。先确认轴是接在本体晶体管脉冲口,还是接在 EtherCAT 总线上;两条路径的参数、接线、使能和诊断方式不同,不能混用。项目使用 `DS5C-20P4-PTA` 时,同时读取 `ds5c-20p4-pta-drive.md`;其他伺服驱动器仍必须以其型号手册为准。

## 已确认的机型能力

| 项目 | 官方资料确认 | 工程含义 |
|---|---|---|
| 本体类型 | XDH-60T4 是 XDH-60 系列的 T4 型 | 使用晶体管输出,不是继电器脉冲输出。 |
| 本地高速脉冲轴 | `Y0~Y3`,4 路 | 每一轴可作为脉冲输出端;方向端从其余晶体管输出中分配并在配置中明确指定。 |
| 本地脉冲规格 | DC5~30V、最大 50mA、最大 100kHz | 驱动器脉冲输入必须与 OC 脉冲加方向方式兼容;不能只按“有脉冲口”判断兼容。 |
| EtherCAT | XDH 有两个以太网口,EtherCAT 使用 `LAN2` | PLC 到第一个伺服 LAN1,再从该伺服的另一口串到下一台,采用线型拓扑。 |
| 高级运动 | 高级运动篇适用于 XDH | 可用 EtherCAT 轴配置、轴调试、单轴/轴组/CAM/POU 功能;具体指令和版本条件逐项查原手册。 |

来源:XDH-60 随机手册 PDF 1-2;定位控制篇 PDF 13-14;高级运动控制篇 PDF 8-10、42-45。

## 路径选择

### 本体脉冲加方向

适用于驱动器提供脉冲输入,且项目需要 1-4 条独立本地轴的情形。

1. 将轴脉冲输出分配到 `Y0~Y3`,每轴另外分配未被占用的晶体管输出作为方向端,避免多个轴复用同一方向端。
2. 在 XDPPro 的脉冲参数/定位指令配置中设定脉冲端、方向端、方向极性、脉冲单位、每转脉冲数和机械单位换算。
3. 在驱动器中把指令输入配置为与 PLC 相符的集电极开路、脉冲加方向、负逻辑输入形式;若驱动器仅接受差分输入,使用合适的 OC-Diff 转换方案并以驱动器接线图为准。
4. 先做低速点动或小距离 `DRVI`,确认方向和实际位移;再做 `ZRN`,最后才允许绝对定位 `DRVA`。

XDH-60T4 的脉冲输出属于 OC 脉冲加方向。定位控制篇指出定位用脉冲输出负载电流应为 DC5~24V、10~100mA;控制线应与动力线分开,并使用外部急停、正反转/上下限硬件互锁。不要从本体 I/O 名称推测具体伺服的 PUL/DIR 端子或 NPN/PNP 接法。

来源:定位控制篇 PDF 13-14、162-168;XDH-60 随机手册 PDF 2。

### EtherCAT 总线轴

适用于需要总线伺服、多轴同步、插补、电子凸轮、追剪或飞剪的项目。本地 4 路脉冲轴数不等于 EtherCAT 从站轴数,后者应以 PLC 型号配置、固件、驱动器和通讯周期实际核定。

1. 在停机、断能状态完成 `LAN2 -> 第一台伺服 LAN1 -> 下一台伺服` 的线型接线,使用屏蔽工业以太网线并核对每个从站顺序。
2. 在工程树的 PLC 配置中打开 EtherCAT;先扫描从站或手工添加匹配的 XML。`StationID 0` 是第一台从站,列表顺序必须与物理拓扑一致。
3. 设定主站同步周期。高级运动篇给出的推荐值为:16 轴及以下 1000us,17-32 轴 2000us,33-64 轴 4000us;满足固件条件时,4 轴及以下可设 250us、8 轴及以下可设 500us。先以保守周期调通,再评估缩短周期。
4. 将从站设置为 Servo Module,并把功能映射号与轴配置的从站号对应。不要把“站号”和程序使用的逻辑轴号混为一谈。
5. 先配置并写入,随后激活。激活会让从站经历 `Init -> PreOP -> SafeOP -> OP`,其效果近似停机后重新运行,必须在设备可安全动作时执行。
6. 在轴配置中选择 EtherCAT 指令通道,设置单位换算、电子齿轮/每圈脉冲数、正负限位、回原参数;轴调试前关闭程序里已有的轴使能。

来源:高级运动控制篇 PDF 8-25、42-52。

## 脉冲定位指令路由

| 目标 | 指令 | 必要认识 | 主要来源 |
|---|---|---|---|
| 相对移动 | `DRVI S0 S1 S2 D0 D1` | 上升/下降沿触发;`S0` 为脉冲数,负数反向;`S1` 为频率;`S2` 为 0 加速到设定频率的时间;`D0` 脉冲端、`D1` 方向端。 | 定位控制篇 PDF 111-116 |
| 绝对移动 | `DRVA S0 S1 S2 D0 D1` | 目标以机械原点为基准,依赖累计脉冲位置;没有完成可靠回零前,不要把它作为真实机械绝对位置。 | 定位控制篇 PDF 117-122 |
| 机械回零 | `ZRN S D` | 上升/下降沿触发;原点、极限、方向、爬行速度和可选 Z 相由参数配置。该指令不支持软限位和原点辅助信号功能。 | 定位控制篇 PDF 123-130 |
| 发送过程判断 | `SM1000` / `SM1020` / `SM1040` / `SM1060` | 分别对应 Y0/Y1/Y2/Y3 正在发脉冲。其下降沿表示 PLC 已发完脉冲,不等于机械已真正停止到位。 | 定位控制篇 PDF 169-170 |

同一脉冲端口在脉冲发送期间,新的定位指令不会被响应。为每轴建立独立的“请求、忙、完成、故障、到位”状态机,完成条件至少组合 PLC 脉冲发送结束、驱动器报警正常、驱动器到位或机械反馈条件,不能只靠 `SM1000` 的下降沿。

## EtherCAT 单轴和 POU 路由

高级运动篇的原梯形图单轴指令包括 `A_PWR`(使能)、`A_RST`(清错)、`A_STOP`(停止)、`A_HALT`(暂停)、`A_MOVEA`(绝对位置)、`A_MOVER`(相对位置)、`A_VELMOVE`(速度)和 `A_HOME`(HM 回原)。它们与脉冲 `DRVI`/`DRVA`/`ZRN` 是两套不同控制层,不要对同一个轴同时交叉下令。

需要 POU 时,XDPPro 可在运动 POU 库中使用带 `BMC_` 前缀的指令,例如 `BMC_A_POWER`。轴配置添加轴后会生成轴结构体变量;使用前在系统变量表中勾选“引用”。POU 引脚必须关联类型匹配的变量,不能直接把寄存器或线圈接到 POU 引脚。

来源:高级运动控制篇 PDF 64-75。

## 调试与诊断顺序

1. 备份工程、核对急停/防护门/STO、外部正负限位、机械区域清空;先停止主运动并解除负载风险。
2. 先监控,不先强制输出。脉冲轴核查 `Y0~Y3` LED、方向输出、累计脉冲寄存器和对应发送标志;总线轴核查从站状态、故障和轴反馈。
3. 脉冲轴不动作时依次核查接线、PLC 端 LED/方向、累计脉冲是否变化、驱动器输入形式是否匹配。停止位置不准时优先核查电子齿轮、原点/爬行速度、编码器 Z 相和机械背隙。
4. EtherCAT 轴先确认实际从站顺序、StationID、功能映射号、PDO 映射和是否到 OP;状态可从 `SD[8021+20*i]` 观察,状态切换错误可从 `SD[8028+20*i]` 查阅。
5. 仅在确知对象、停机状态和恢复方案时修改 CoE-Online、SDO 或 ESC 寄存器。部分对象或寄存器的在线写入会造成通讯中断。

来源:定位控制篇 PDF 171-173;高级运动控制篇 PDF 13-25、46-52;EtherCAT 运动控制用户手册 PDF 162-175(补充)。

## 版本与未决信息

- 定位控制篇列出 XDH 需要 XDPPro V3.7.4 及以上;高级运动中的具体功能还会各自要求固件和软件版本,实施前逐条核对。
- `XDH-60T4` 已能确认本地 4 路脉冲输出;EtherCAT 的实际可用从站数、周期和控制模式应以当前 PLC 固件、驱动器 XML、驱动器型号和工程配置为准。
- 当前 DS5C-20P4-PTA 的驱动器侧资料见 `ds5c-20p4-pta-drive.md`。获得电机完整型号、机械传动数据、限位/原点传感器和当前 XDPPro 版本后,可继续生成这套设备的接线表、参数表、软元件分配和梯形图/POU 顺序。

+ 882
- 0
references/xdp-pro-ch2-5-reference.md Просмотреть файл

@@ -0,0 +1,882 @@
# XDPPro 第 2-5 章整理参考

资料来源:`XD XL XG系列可编程控制器用户手册(软件篇)(V3.8.1)(PD03 20260510 1.5.1).pdf`,整理范围 p.17-p.145。

用途:作为 `xinje-plc-programming` skill 的 reference,用于回答 XDPPro 基本操作、工程建立、联机、上传下载、梯形图编辑、配置、通讯、运动控制和监控调试类问题。

## 使用原则

- 回答 XDPPro 操作问题时,优先先确认 PLC 系列/型号、软件版本、固件版本、连接方式、当前 PLC 状态。
- 涉及下载、在线下载、初始化、保密下载、写入配置、运动控制、强制修改软元件状态时,必须提醒用户评估设备安全和现场动作风险。
- 遇到细节依赖机型或固件版本的功能,例如在线下载、Modbus TCP 图形化配置、Ethernet/IP、EtherCAT、运动控制、过程控制,应要求用户确认型号和固件版本。
- 本整理只覆盖软件篇第 2-5 章。指令语义、BLOCK 深入用法、EtherCAT/高级运动、以太网通讯、CAN 通讯、G-BOX/4GBOX 等需继续查对应专项手册。

## 第 2 章:基本操作

### 打开与关闭 XDPPro

- 打开:双击桌面快捷图标启动 XDPPro。源:p.17。
- 关闭:通过菜单 `文件 -> 退出` 或窗口关闭按钮退出。源:p.17。

### 创建新工程

流程:

1. 选择 `文件 -> 创建新工程`,或点击新建工程图标。
2. 在“机型选择”窗口按实际 PLC 机型选择工程机型。
3. 点击确定,完成新工程建立。

注意:

- 创建工程时机型必须和现场 PLC 尽量一致,否则后续下载、配置、特殊功能可能不匹配。
- 若用户不确定机型,应先让用户读取 PLC 本体标签,或联机后查看 PLC 本体信息。

源:p.18。

### 打开已有工程

- 通过 `文件 -> 打开工程` 或打开图标进入已有工程。
- 若工程来自现场设备上传,建议先另存备份,再修改。

源:p.19。

### 添加、删除和更换 PLC

添加 PLC 的两种入口:

- `文件 -> 添加PLC`
- 左侧工程栏右键 `PLC1 -> 添加PLC`

用途:

- 同一个工控系统中有多个 PLC 时,可把多个 PLC 程序放在同一工程文件内。
- 添加成功后默认命名类似 `PLC2`,可切换不同 PLC 进行编辑。

注意:

- PLC 名称不能包含 `< > : " / \ | ? *`,否则可能导致程序不能正常下载。
- 多 PLC 工程中,回答问题时要确认用户当前操作的是哪个 PLC 节点。
- 更换机型前要提醒用户核对 I/O、特殊模块、通讯和运动控制配置是否兼容。

源:p.20-p.22。

## 第 3 章:编辑环境

### 主界面区域

XDPPro 界面通常包含:

- 标题栏:显示当前梯形图程序文件名和路径。
- 菜单栏:文件、编辑、查找/替换、显示、PLC 操作、PLC 设置、选项、窗口、帮助等。
- 常规工具栏:复制、查找等常用功能。
- PLC 操作栏:上传、下载、运行、监控等常用 PLC 操作。
- 梯形图输入栏:输入接点、线圈、线、节点、ST 执行块等。
- 窗口切换栏:切换梯形图、软元件注释、已使用软元件等窗口。
- 工程栏:显示工程目录、PLC 配置、PLC 信息、通讯、运动控制、监控等入口。
- 工具箱:显示 LD/ST 支持的指令和收藏夹。
- 编辑区:梯形图和程序编辑区域。
- 信息栏:显示错误列表和输出。
- 状态栏:显示 PLC 型号、通讯方式、运行状态、光标位置、步数等。

源:p.23。

### 常用菜单入口

- `文件`:新建、打开、保存、下载工程数据、完整下载、在线/离线相关入口、导出工程/画面等。源:p.27。
- `编辑`:复制、粘贴、撤销、查找替换相关编辑动作。源:p.27-p.28。
- `显示`:梯形图显示、注释显示、监控显示等。源:p.30。
- `PLC操作`:联机、上传、下载、运行、停止、语法检查、监控等。源:p.30。
- `PLC设置`:与 PLC 参数或配置相关。源:p.32。
- `选项`:通讯方式、下载设置、梯形图编辑器配置、ST/C 编辑器设置等。源:p.32、p.122-p.128。

### 工程栏与工具箱

- 工程栏是多数配置入口所在位置,包括 PLC 信息、PLC 配置、PLC 通讯、运动控制、监控等。
- 工具箱用于查找和插入 LD/ST 支持的指令,适合回答“某功能在哪里配置/插入”的问题。

源:p.34。

## 第 4 章:简单功能实现

### 联机方式总览

XD/XL/XG 系列 PLC 支持通过 RS232、USB、RJ45 以太网口联机。

- RS232:使用 DVP/XVP 线连接 PLC 与电脑。
- USB:使用打印机线连接 PLC 与电脑。
- RJ45:使用网线连接 PLC 与电脑。

源:p.38。

### USB 联机流程

流程:

1. 进入 `选项 -> 软件串口设置`。
2. 在通信配置中点击“新建”。
3. 通信接口选 `USB`,通信协议选 `Xnet`,查找方式选设备类型。
4. 重启服务后确认配置。
5. 将使用状态改为“使用中”并确认。
6. 出现“成功连接到本地 PLC”表示连接成功。

排查:

- 若提示 `xnet 服务未安装`,说明 XNetConfigTool 可能未安装好,手册建议关闭杀毒软件和防火墙后重新安装配置工具。

源:p.38-p.40。

### 串口联机流程

流程:

1. 进入 `选项 -> 软件串口设置`。
2. 新建或编辑通信配置。
3. 通信接口选串口相关项。
4. 设置端口号、通信协议、波特率、数据位、停止位、校验等参数。
5. 确认后设为使用中。

注意:

- 串口联机失败时,优先检查 COM 口、驱动、线缆、PLC 通讯参数、端口占用。
- X-NET 通讯参数需通过 XINJEConfig 配置工具配置;Modbus/自由格式通讯参数主要在 XDPPro 的 PLC 串口设置中配置。

源:p.40-p.42、p.101。

### 以太网联机流程

先设置 PLC IP:

1. 左侧工程栏进入 `PLC配置 -> 以太网口`。
2. 网口 PLC 默认 IP 为 `192.168.6.6`。
3. 修改 IP 后写入 PLC。
4. PLC 断电重启后新 IP 生效。

再设置电脑 IP:

- 电脑网卡 IP 要与 PLC 在同一网段,尤其使用局域网查找或设备 ID 查找时。

XDPPro 连接方式:

- 指定 IP 地址连接。
- 局域网口按设备类型或设备 ID 查找。
- 远程连接。

指定 IP 方式:

1. 进入 `软件串口设置`。
2. 通信接口选 `Ethernet`。
3. 协议可选 `XNET` 或 `Modbus-TCP`。
4. 选择 PLC IP。
5. 若用 XNET,执行配置服务/重启服务后确认。

局域网查找方式:

- 通信接口选 `Ethernet`,协议选 `XNET`。
- 连接方式选局域网口。
- 查找方式可选设备类型或设备 ID。
- 使用设备 ID 时,可从 PLC 标签或联机后的 PLC 本体信息查看 ID。

注意:

- PLC IP 与电脑 IP 要在同一网段。
- 一台电脑有多个网卡时,建议只使用一个网卡,且该网卡只配置一个 IP。
- 修改 PLC IP 后要写入 PLC 并重启 PLC 才生效。

源:p.43-p.46。

### 远程连接

流程:

1. 在左侧 `PLC配置 -> 以太网口` 中进入远程通信设置。
2. 参数写入 PLC 后重新上电使配置生效。
3. 在 `软件串口设置` 中通信接口选 `Ethernet`。
4. 通讯协议选 `XNET`。
5. 连接方式选“远程连接”。
6. 填入设备 ID 和密码后确认。

注意:远程通信参数细节需查《X-NET通讯用户手册》。

源:p.49。

### 程序下载

下载类型:

- 下载用户程序。
- 保密下载用户程序。

重要风险:

- 使用保密下载后,PLC 中的程序和数据将无法上传,适合保护知识产权,但必须谨慎使用。

普通下载流程:

1. 确认已联机。
2. 点击 `PLC操作 -> 下载用户程序`,或使用工具栏下载图标。
3. 若 PLC 正在运行,按机型是否支持在线下载会出现不同提示。
4. 非在线下载机型通常需要停止 PLC 后下载。
5. 在线下载机型可选择停止 PLC 继续下载,或数据保持继续下载。

运行中下载选项理解:

- 停止 PLC 继续下载:停止当前程序,下载新程序。下载后可选择是否自动运行 PLC。
- 数据保持继续下载:下载过程中 PLC 保持运行状态相关数据,下载完成后执行新程序。使用前必须评估现场动作风险。

下载设置:

- 下载前可通过 `选项 -> 下载设置` 选择是否移除软元件注释、是否对 C 语言加密。

源:p.53-p.55。

### 在线下载

定义:

- 在线下载是在 PLC 运行中写入程序或数据,避免把 PLC 切到停止状态。
- 新程序编译下载后,原有继电器状态、I/O 状态和寄存器数据保持不变。

使用条件:

- PLC 机型支持在线下载。
- 在线下载规则满足。
- 软件版本和固件版本匹配,软件版本向下兼容。
- 手册列出在线下载软件版本为 XDPPro V3.7.4a 及以上。

典型支持范围:

- XDH/XLH、XL5H、XG2、XA310、部分 XD5E/XDME/XL5E/XL5N/XLME 等机型,具体受固件/硬件版本影响。

风险提醒:

- 新程序生效后可能影响正在运行的控制系统。
- 改动运动控制、通讯、输出相关逻辑时要特别谨慎。
- 若工程有口令密码,在线下载前需要先解锁。

源:p.55-p.58。

### 程序上传

上传类型:

- 上传用户程序。
- 上传用户程序及配置。

区别:

- 区别在于是否把 PLC 中的数据/配置一起上传到编程软件。

流程:

1. 联机成功。
2. 点击 `PLC操作 -> 上传用户程序`,或工具栏上传图标。
3. 上传完成后通过 `文件 -> 保存工程` 保存。

注意:

- 若 PLC 或工程有密码保护,上传时需输入正确密码。
- 若提示“程序不存在”,通常表示程序是保密下载到 PLC 中的,无法上传。

源:p.58。

### PLC 状态控制

- 联机后可通过 PLC 操作栏运行 PLC。
- 联机后可通过 PLC 操作栏停止 PLC。

风险:

- 运行/停止 PLC 会直接影响现场设备动作或停机,必须确认现场状态。

源:p.58。

### 导入导出下载文件

用途:

- 对整个工程生成下载文件。
- 下载文件中的程序为保密状态,无源文件,无法查看和修改,但可以正常下载。

导出类型:

- 供电脑下载。
- 仅供专用下载器下载。
- 仅供 TS 触摸屏下载。

源:p.58-p.61。

### 软元件初值设定和数据读写

功能:

- 可对 HD、FD、HT 等停电保持寄存器或线圈设置初始值并下载到 PLC。
- 可在 PLC 运行时批量读写保持型软元件状态。

入口:

- 左侧工程栏 `设置软元件初值`。

操作要点:

- 添加:选择软元件类型、起始软元件、结束软元件。
- 修改:修改软元件类型和范围。
- 寄存器初值支持十进制、二进制、十六进制等显示/输入方式。
- 读取/写入:处理指定范围。
- 批量读取/批量写入:处理列表中的全部寄存器。
- 默认值:批量设置指定寄存器初始值。
- 线圈可设置起始状态为 ON 或 OFF。

风险:

- 运行中写入保持寄存器或线圈可能改变设备动作,应确认软元件含义和现场状态。

源:p.62。

### PLC 及模块信息查询

入口:

- 左侧工程栏 `PLC信息`。

可查内容:

- PLC 本体信息:系列、机型、下位机版本、适合的上位机版本。
- PLC 工程信息。
- 模块组态信息。
- 扫描周期。
- 时钟信息。
- 错误信息。

用途:

- 解决联机、版本、固件、在线下载支持、模块配置、运行异常问题时优先查看。

源:p.63-p.65。

### 工程和程序加锁/解锁

范围:

- 工程加锁/解锁。
- 程序加锁/解锁。
- 默认解密密码设置。

注意:

- 密码相关操作会影响上传、在线下载、程序保护和维护权限。
- 回答此类问题时只说明正规操作流程,不协助绕过未知密码或破解保护。

源:p.66-p.68。

### 其他功能

- 上电停止 PLC。
- PLC 初始化。
- 打印。
- 记录。

风险:

- PLC 初始化和上电停止会影响设备运行状态,执行前必须备份工程并确认现场允许。

源:p.69-p.70。

## 第 5 章:编程操作

### 编程方式

XDPPro 支持:

- 梯形图编程:直观,适合多数 PLC 编程和维护人员。
- 命令语编程:适合熟悉 PLC 和逻辑编程的人员。

梯形图和命令语可互相转换,可通过梯形图转换图标把梯形图转换成命令语显示。

源:p.71。

### 梯形图输入快捷键

接点类:

- 常开节点:F5。
- 常闭节点:F6。
- 上升沿:Shift+F5。
- 下降沿:Shift+F6。
- 多条件上升沿:Ctrl+F5。
- 多条件下降沿:Ctrl+F6。
- 取反:Alt+F6。

输出类:

- 输出线圈、计时、计数:F7。
- 置位线圈:Shift+F7。
- 复位线圈:Shift+F8。
- ST 执行块:F9。

连线类:

- 插入横线:F11。
- 插入竖线:F12。
- 删除横线:Shift+F11。
- 删除竖线:Shift+F12。

节点/行:

- 插入节点:Ins。
- 插入行:Shift+Ins。
- 删除节点:Del。
- 删除行:Shift+Del。

源:p.71-p.76。

### 梯形图编辑注意事项

- 选中梯形图某个接点时,虚线框表示当前输入位置。
- 输入完成后按 Enter 确认。
- 输入错误时,接点会显示为红色;可双击重新编辑。
- 梯形图注释可通过 `显示 -> 梯形图显示节点注释` 开关。
- 软元件注释可在接点处右键添加或编辑;相同指令的注释会随显示规则显示。
- 可拖动选择区域后复制、剪切、粘贴;可按 Ctrl 多选节点。
- 长程序可使用语句折叠/展开帮助阅读流程、循环等语句段。

源:p.71-p.81。

### ST 执行块

用途:

- 在梯形图语言编程时,可在主程序、子程序、中断程序、FB、FC 中添加 ST 执行块 `EXECUTE`。

操作:

- 添加:点击梯形图输入栏 ST 执行块图标,或按 F9。
- 编辑:双击进入内部文本编辑。
- 删除:删除节点可删除节点及内容;只删除节点内容不会删除节点。
- 监控:梯形图监控开启时,ST 执行框中的全局变量和寄存器可监控。
- 可通过右键菜单把 ST 执行框中全部全局变量和寄存器加入自由监控或示波器监控。

适用场景:

- 局部算法、计算逻辑、批量赋值、复杂表达式更适合放入 ST 执行块。
- 现场维护人员不熟悉 ST 时,关键互锁和安全动作仍建议保持梯形图可读性。

源:p.83-p.84。

### 特殊指令写法

部分参数多、配置复杂的指令建议通过配置面板完成:

- PID 指令。
- 脉冲控制指令。
- 高速计数指令。

PID:

- 在指令输入点打开 PID 配置。
- 设置地址、常用 PID 参数、模式、超调、方向等。
- 修改地址可右键指令修改,其他参数可通过自由监控手动修改。

脉冲:

- 打开脉冲配置面板。
- DRVA、DRVI 需在梯形图中按指令要求直接输入。
- 多段脉冲输出可配置指令种类、位数、段数、频率、加减速时间、地址等。
- 参数可写入 PLC,修改时可右键指令或通过自由监控修改相关参数。

高速计数:

- 打开高速计数配置面板。
- 设置高速计数器、比较值、相对/绝对、100 段中断基地址等。

注意:

- 脉冲、PID、高速计数配置的值在用户数据下载时写入 PLC。

源:p.85-p.87。

### 函数功能库

分类:

- 项目库。
- 全局库。

用途:

- 管理可复用函数/功能块。
- 可新建库、文件夹,导入导出库,进行库管理。
- 函数编辑并编译通过后可在程序中调用。

适用建议:

- 项目专用功能放项目库。
- 多项目复用功能放全局库。
- 维护时要区分源文件、头文件和库版本。

源:p.88-p.92。

### 配置功能块

短信配置:

- G-BOX、4GBOX 短信配置通过 PLC 指令输入栏进入。
- 具体应用需查 G-BOX 或 4GBOX 手册。

自由格式通讯:

- RCV、SEND 可按指令格式直接在梯形图中输入,也可通过配置面板书写。
- 适合自定义串口通讯协议。

源:p.93-p.95。

### 顺序功能块 BLOCK

用途:

- 适用于顺序执行程序。
- 常见场景包括多个脉冲输出、读写模块等。
- BLOCK 内部程序按条件成立的先后顺序执行。

操作:

- 从指令栏进入 BLOCK 配置界面。
- 可添加命令语列表、脉冲配置、Wait 指令、读写模块 FROM/TO、G 指令、读写 SD 模块等。
- 生成后可在梯形图中看到顺序功能块指令。
- 双击 `SBLOCK` 或内部指令可重新打开配置面板。

注意:

- BLOCK 深入使用需要查《XD/XL 系列可编程控制器用户手册【基本指令篇】》。

源:p.96-p.97。

### PLC 配置

入口:

- 左侧工程栏 `PLC配置`。

I/O 配置:

- 输入滤波时间:输入端子信号持续超过滤波时间后才作为有效信号;默认值为 10ms。
- 输入/输出点映射:用于调整 I/O 点映射关系。
- 输入属性:设置输入正/负逻辑。
- STOP 下输出状态:设置 PLC 停止时输出状态。

串口设置:

- 入口:`PLC配置 -> PLC串口设置`。
- 可添加 Modbus 通讯或自由格式通讯。
- 端口号可分别设置。
- Modbus 模式支持 Modbus-RTU 和 Modbus-ASCII。
- 可读取 PLC 默认通讯参数,也可写入当前参数到 PLC。
- 写入 PLC 后需重新上电。
- X-NET 通讯参数需通过 XINJEConfig 配置工具配置。

以太网口设置:

- 入口:`PLC配置 -> 以太网口`。
- 可设置 PLC IP、远程通信等。
- 修改后通常需要写入 PLC 并重启。

脉冲参数:

- 入口:`PLC配置 -> 脉冲参数`。
- 用于相关脉冲输出参数设置,具体还要结合脉冲指令和运动控制要求。

模块组态:

- 入口:`PLC配置 -> 模块组态`。
- 用于配置扩展模块、总线模块等。

4GBOX、WBOX、系统设置:

- 入口同在 PLC 配置下,具体功能需结合无线模块或系统设置要求。

源:p.97-p.109。

### PLC 通讯

Modbus TCP 图形化设置:

- 入口:`PLC 通讯 -> Modbus TCP`。
- 适合与 Modbus-TCP 设备做通讯数据交互。
- 支持机型和连接数量与机型/固件相关。
- 图形化配置建立连接数与 Socket 建立连接不冲突。

Modbus-TCP 主站配置基本流程:

1. 在左侧任务导航栏找到 `工程 -> PLC 通讯 -> Modbus TCP`。
2. 双击进入配置界面。
3. 添加 Modbus-TCP 连接。
4. 设置从站、功能码、地址空间、数量、映射地址等。

常见功能码能力:

- 读线圈 01H:读 0X 地址,最大数量 2000。
- 读输入线圈 02H:读 1X 地址,最大数量 2000。
- 读寄存器 03H:读 4X 地址,最大数量 125。
- 读输入寄存器 04H:读 3X 地址,最大数量 125。
- 写单个线圈 05H。
- 写单个寄存器 06H。
- 写多个线圈 0FH:最大数量 1960。
- 写多个寄存器 10H:最大数量 122。

从站为信捷 PLC 时,地址空间下拉参考:

- 线圈类:M、X、Y、HM、S、SM、T、C、ET、SEM、HS、HT、HC、HSC。
- 寄存器类:D、HD、ID、QD、SD、TD、CD、ETD、HSD、HTD、HCD、HSCD、FD、SFD、FS。

Ethernet/IP:

- 入口:`PLC 通讯 -> Ethernet IP`。
- 可配置 EipScanner、EipAdapter、EipExplicit。
- 适用机型、固件、软件版本有要求;除手册列出机型外暂不支持。
- 具体配置需查《以太网通讯用户手册》。

CANopen:

- 入口:`PLC 通讯 -> CANopen`。
- 具体配置需查《CAN 通讯用户手册》。

EtherCAT:

- 入口:`PLC 通讯 -> EtherCATMaster`。
- 具体配置需查高级运动控制篇。

源:p.110-p.116。

### 运动控制

运控指令显示:

- 默认以条状输出节点显示。
- 可右击输出节点或通过菜单图标改成块状显示。
- 块状显示时输入输出参数默认全部显示,可通过指令参数配置选择显示内容。
- 可恢复出厂设置,让输入输出参数恢复默认全部显示。

轴配置:

- 入口:`运动控制 -> 轴配置`。
- EtherCAT 总线机型在 V3.7.3 及以上固件使用运控指令时需勾选自动映射。
- 若下载轴/轴组配置提示 PDO 参数下载失败,应检查 PLC 固件版本是否低于 V3.7.3;该范围 PLC 不支持下载自动映射 PDO 参数,但手册说明不影响使用。

轴调试、轴组配置、CAM:

- 分别从 `运动控制 -> 轴调试`、`轴组配置`、`CAM` 进入。
- 具体操作需查高级运动控制篇。

源:p.117-p.120。

### 过程控制

支持范围:

- XD5E/XL5E 系列 PLC 固件 3.7.3 及以上支持 `BPC_TEMP_PID` 函数块。

使用前提:

- 在系统库勾选 `XJBasicProcessControl`。
- 在 `_SYS_PID` 中生成对应实例。

入口:

- `过程控制 -> 温度PID配置`。
- `过程控制 -> 温度PID调试`。

细节需查《XD/XL 系列可编程控制器用户手册【基本指令篇】》。

源:p.121。

### 其他设置

通讯方式设置:

- 入口:`选项 -> 通讯方式设置`。
- 用于设置电脑与连接设备的通讯方式,包括本体 PLC、网络模块等。
- 默认通讯方式为串口。
- TCP/IP 设备配置完成后可激活 UDP 通讯方式。
- 也可在工程栏中右键 PLC 名称,选择“编辑 PLC 通讯模式”。

下载设置:

- 入口:`选项 -> 下载设置`。
- 可选择是否移除注释、是否 C 语言加密。
- C 语言加密后可继续调用,但无法查看 C 语言内容。

工程其他设置:

- 涉及工程层面参数,具体根据界面项确认。

梯形图编辑器配置:

- 入口:`选项 -> 梯形图编辑器配置`。
- 可设置梯形图、中断块、Group 指令块、函数块、For Next 块、顺序功能块、流程等元素背景色。
- 可设置线条颜色、软元件/变量注释颜色、监控状态颜色。
- 可设置指令提示、气泡提示、编辑指令后是否进入注释框、换行行数等。

ST 编辑器设置:

- XDPPro 3.8.1 及以上支持赋值操作符补全。
- 一般输入 `:` 后自动补全 `=`,默认启用。
- 输入 `:` 前为空白、关键字或数字时不触发补全。
- 文本声明变量区域不支持赋值操作符补全。

源:p.122-p.128。

### 监控与调试

软元件注释/使用情况:

- 显示 PLC 中全部软元件注释,包括系统内部软元件和用户添加注释。
- 可导出客户标注软元件及注释为 CSV。
- 可从 CSV 导入注释。
- 可初始化系统元件注释,例如 SM0。
- 可查看已使用软元件及注释,也可按 X、Y、M 等类别筛选。

自由监控:

- 联机状态下,从 PLC 操作栏打开自由监控。
- 支持监视器 1 到监视器 4 共 4 张自由监控表。
- 添加监控节点时设置首地址、连续监控个数、监控模式、显示模式。

数据监控:

- 联机状态下打开数据监控。
- 以列表形式监视线圈状态和寄存器值。
- 双击线圈可取反状态。
- 双击寄存器可修改值,按 Enter 确认。
- 搜索栏输入软元件编号可定位。

梯形图/ST 监控:

- PLC 成功连接且运行时,可打开监控查看梯形图和 ST 程序状态。
- ON 状态一般以绿底白字显示。
- 寄存器、计数器、定时器实时数据可显示在梯形图上。
- 可右键软元件改变当前状态用于调试。

风险:

- 强制改变线圈或寄存器状态会影响设备动作,必须确认现场安全。

源:p.130-p.132。

### 示波器监控

使用条件:

- XDPPro 3.7.16 及以上版本全系列支持示波器功能。

用途:

- 观察寄存器变量随时间或变量关系变化,适合运动控制、位置、速度、模拟量、PID 等调试。

显示类型:

- YT:横坐标为时间变量,纵坐标为单个寄存器变量。
- XY:横坐标和纵坐标都是寄存器变量,需要配置两个寄存器变量。

数据特点:

- 界面显示超过一分钟后,一分钟前的数据曲线会清空,但数据仍存在。
- 可通过右键菜单导出数据查看全部保存数据。
- 示例中可把数据以 Excel 表格形式保存 1 小时以内数据。

触发器:

- 可配置对象、条件、触发边沿、阈值、触发后的行为、使能。
- 触发边沿包括 Risingedge 和 Fallingedge。
- 行为包括停止显示和重新开始显示。
- 多触发条件中,AND 表示都触发才停止,OR 表示任意触发即可停止;若同组存在 OR,则按 OR 逻辑判断。

源:p.133-p.143。

### 信息栏与状态栏

信息栏:

- 包括错误信息和输出。
- 梯形图语句有误时,按 Enter 后会以红色标示,并在错误信息栏显示。
- 语法检查可通过 `PLC操作 -> 语法检查`。
- 双击错误信息可定位到错误点。
- 输出栏通常在 PLC 运行异常时显示相关错误提示。

状态栏:

- 显示当前激活 PLC 的信息。
- 可双击状态显示快速打开并修改 PLC 属性。
- 双击右下角 PLC 运行状态可停止所有监控并释放串口占用,再次双击恢复监控。
- 左侧显示光标所在指令行数、列数和当前梯形图步数。
- 双击“覆盖”可切换为“插入”,影响梯形图编辑粘贴模式。

源:p.144-p.145。

## 面向 skill 的问答模板

### 用户问“怎么联机”

先问:

- PLC 型号和系列。
- 准备用 USB、串口还是以太网连接。
- 电脑系统、线缆类型、是否安装驱动/XNetConfigTool。
- PLC 当前 IP 或通讯参数。

再答:

- USB 按 XNET/USB 配置。
- 串口检查 COM 和参数。
- 以太网检查 PLC IP、电脑同网段、XNET/Modbus-TCP、网卡数量。
- 失败时让用户提供错误提示、通信配置截图、PLC 标签/本体信息。

### 用户问“怎么上传/下载”

先问:

- 是否已经联机。
- PLC 是否运行中。
- 是否要普通下载、保密下载、在线下载。
- 是否需要保留寄存器/线圈状态。
- 是否有密码保护。

必须提醒:

- 保密下载后无法上传。
- 在线下载会让新程序在运行中生效,必须评估现场风险。
- 初始化、停止、运行 PLC 前确认设备安全。

### 用户问“怎么写梯形图”

建议输出:

- 先列 I/O 表和软元件表。
- 再给梯形图网络结构。
- 对常开/常闭、线圈、置位/复位、定时器/计数器说明快捷键。
- 复杂计算可建议 ST 执行块,但关键安全互锁保持梯形图可读。
- 最后给监控和调试步骤。

### 用户问“通讯怎么做”

先问:

- 是电脑联机通讯、PLC 串口通讯、Modbus TCP、Ethernet/IP、CANopen、EtherCAT,还是 HMI 通讯。
- 主站/从站角色。
- 设备型号、协议、IP/站号、寄存器地址、功能码。

再答:

- Modbus RTU/ASCII 从 PLC 串口设置入手。
- Modbus TCP 从 `PLC 通讯 -> Modbus TCP` 图形化配置入手。
- Ethernet/IP、CANopen、EtherCAT 只给入口和前置条件,细节查专项手册。

### 用户问“怎么调试”

建议顺序:

1. 先查 PLC 本体信息、工程信息、错误信息、扫描周期。
2. 做语法检查,处理信息栏错误。
3. 用梯形图/ST 监控看逻辑状态。
4. 用数据监控或自由监控看软元件和寄存器。
5. 对运动、PID、模拟量等变化量,用示波器监控。
6. 任何强制写值或改状态前确认现场设备安全。


+ 75
- 0
references/xinje-official-document-catalog.md Просмотреть файл

@@ -0,0 +1,75 @@
# Xinje Official Document Catalog

Use this reference when a user asks whether Xinje has an official manual, drawing, certificate, sample sheet, or document before downloading files.

The full catalog is stored as generated metadata:

- `assets/catalogs/xinje-official-document-catalog.csv`
- `assets/catalogs/xinje-official-document-catalog.json`
- `assets/catalogs/xinje-official-document-catalog-summary.md`

Catalog scope:

- Official source: `https://www.xinje.com/web/downloadCenter/index`
- Cataloged date: 2026-07-08
- Scope: metadata only; no files were downloaded by the catalog script.
- Included download-center categories: `产品手册`, `彩页/样本`, `产品图纸`, `EPLAN`, `认证证书`.
- Excluded by default: `软件工具`, `样例程序`; include these only when the task needs software installers or program examples.

## Current Counts

| Category | Count |
|---|---:|
| 产品图纸 | 2501 |
| EPLAN | 726 |
| 产品手册 | 330 |
| 彩页/样本 | 69 |
| 认证证书 | 57 |
| Total | 3683 |

## File-Type Counts

| File type | Count |
|---|---:|
| `dwg` | 1019 |
| `pdf` | 822 |
| `zip` | 753 |
| `edz` | 553 |
| `stp` | 459 |
| `rar` | 62 |
| `step` | 12 |
| `sldprt` | 2 |
| `igs` | 1 |

## How To Use

1. Search the CSV/JSON by title, product family, file ID, category, update date, or file type.
2. Prefer official `id` and `url` from the catalog when deciding what to download.
3. Before downloading a new PDF into `assets/manuals/`, read `coverage-map.md` and `maintenance-workflow.md`.
4. If a file is only needed once, download it to the workspace first, inspect and summarize it, then decide whether it belongs in the skill package.

## Known PLC/HMI Manual IDs

| ID | Title | Type | Version | Update date |
|---|---|---|---|---|
| `8` | XD/XL/XG系列可编程控制器用户手册【软件篇】XDPPro V3.8.1 | pdf | 1.5.1 | 20260626 |
| `9` | XD、XL系列可编程控制器用户手册【基本指令篇】 | pdf | 1.6.1 | 20260626 |
| `30` | XG系列PLC用户手册【基本指令篇】 | pdf | 1.0 | 20241216 |
| `40` | XD系列PLC扩展模块用户手册 | pdf | 1.2.4 | 20260626 |
| `44` | XL系列PLC扩展模块用户手册 | pdf | 1.6.2 | 20260225 |
| `46` | XG系列PLC扩展模块用户手册 | pdf | 1.1 | 20241216 |
| `50` | TS系列人机界面用户手册【硬件篇】 | pdf | 1.4 | 20260605 |
| `51` | TouchWin Pro编辑软件用户手册(TS系列适用) | pdf | 1.7 | 20260605 |
| `52` | TS系列人机界面用户手册【通讯篇】 | pdf | 1.9.1 | 20260605 |
| `63` | TouchWin编辑软件用户手册 | pdf | 1.2 | 20251021 |
| `64` | 触摸屏与PLC及其他设备通讯连接手册 | pdf | 1.2.1 | 20241223 |
| `65` | TouchWin组态软件使用说明 | pdf | 1.0 | 20241216 |
| `67` | TS系列人机界面常见问题汇总 | pdf | 1.0 | 20241216 |
| `68` | TG系列人机界面常见问题汇总 | pdf | 1.0 | 20241216 |
| `95` | 以太网通讯用户手册 | pdf | 1.5.1 | 20260626 |
| `2729` | XDQ、XLQ系列可编程控制器用户手册【基本指令篇】 | pdf | 1.0 | 20250515 |
| `2730` | XDQ、XLQ系列可编程控制器用户手册【硬件篇】 | pdf | 1.0 | 20250515 |
| `2737` | XSFQ7系列可编程控制器用户手册【硬件篇】 | pdf | 1.2 | 20260629 |
| `2831` | XD、XL系列可编程控制器用户手册【硬件篇】 | pdf | 1.6 | 20260626 |

Use the catalog files for the complete list and exact official URLs.

+ 173
- 0
scripts/build_pdf_search_index.py Просмотреть файл

@@ -0,0 +1,173 @@
import argparse
import datetime as dt
import json
import pathlib
import re
import sqlite3
import sys

from pypdf import PdfReader


TOC_MARKERS = ("目录", "目 录", "contents", "table of contents")
TOC_LINE = re.compile(r"^(?P<title>.{2,160}?)(?:[..·…]{2,}|\s{2,})(?P<page>-?\d{1,4})\s*$")


def compact(value: str) -> str:
return re.sub(r"\s+", " ", value or "").strip()


def text_lines(value: str) -> list[str]:
return [compact(line) for line in (value or "").splitlines() if compact(line)]


def is_toc_page(text: str) -> bool:
lowered = text.lower()
if any(marker in lowered for marker in TOC_MARKERS):
return True
return sum(1 for line in text_lines(text) if TOC_LINE.match(line)) >= 4


def parse_toc_entries(text: str, pdf_page: int) -> list[dict[str, object]]:
entries = []
for line in text_lines(text):
match = TOC_LINE.match(line)
if not match:
continue
title = compact(match.group("title")).strip("..·… ")
if len(title) < 2 or title in TOC_MARKERS:
continue
entries.append(
{
"title": title,
"printed_page": int(match.group("page")),
"toc_pdf_page": pdf_page,
}
)
return entries


def open_index(path: pathlib.Path) -> sqlite3.Connection:
path.parent.mkdir(parents=True, exist_ok=True)
if path.exists():
path.unlink()
connection = sqlite3.connect(path)
connection.execute("PRAGMA journal_mode=OFF")
connection.execute("PRAGMA synchronous=OFF")
connection.execute("PRAGMA temp_store=MEMORY")
connection.execute(
"CREATE TABLE manuals ("
"filename TEXT PRIMARY KEY, page_count INTEGER NOT NULL, size_bytes INTEGER NOT NULL, "
"toc_pdf_pages TEXT NOT NULL)"
)
connection.execute(
"CREATE VIRTUAL TABLE page_search USING fts5("
"manual UNINDEXED, filename UNINDEXED, pdf_page UNINDEXED, text, tokenize='trigram')"
)
return connection


def build_index(manual_dir: pathlib.Path, database_path: pathlib.Path, toc_scan_pages: int) -> dict:
connection = open_index(database_path)
manuals = []
page_total = 0
try:
for pdf_path in sorted(manual_dir.glob("*.pdf"), key=lambda item: item.name.casefold()):
reader = PdfReader(str(pdf_path))
toc_pages = []
toc_entries = []
print(f"indexing {pdf_path.name}: {len(reader.pages)} pages", flush=True)
for page_number, page in enumerate(reader.pages, start=1):
text = page.extract_text() or ""
normalized = compact(text)
connection.execute(
"INSERT INTO page_search(manual, filename, pdf_page, text) VALUES (?, ?, ?, ?)",
(pdf_path.stem, pdf_path.name, page_number, normalized),
)
if page_number <= toc_scan_pages and is_toc_page(text):
toc_pages.append(page_number)
toc_entries.extend(parse_toc_entries(text, page_number))
toc_entries = toc_entries[:300]
connection.execute(
"INSERT INTO manuals(filename, page_count, size_bytes, toc_pdf_pages) VALUES (?, ?, ?, ?)",
(pdf_path.name, len(reader.pages), pdf_path.stat().st_size, json.dumps(toc_pages)),
)
manuals.append(
{
"filename": pdf_path.name,
"page_count": len(reader.pages),
"size_bytes": pdf_path.stat().st_size,
"toc_pdf_pages": toc_pages,
"toc_entries": toc_entries,
}
)
page_total += len(reader.pages)
connection.commit()
connection.execute("VACUUM")
finally:
connection.close()
return {
"generated_at": dt.datetime.now(dt.timezone.utc).replace(microsecond=0).isoformat(),
"manual_count": len(manuals),
"page_count": page_total,
"manuals": manuals,
}


def write_toc_markdown(index: dict, path: pathlib.Path) -> None:
lines = [
"# Manual Chapter Index",
"",
"This generated index covers all PDFs currently under `assets/manuals/`. `手册页` is the printed page number extracted from the table of contents; `目录 PDF 页` is the physical PDF page where the entry was found. Use `search_xinje_manuals.py` for exact PDF-page results.",
"",
f"Generated: `{index['generated_at']}`. Manuals: `{index['manual_count']}`. PDF pages: `{index['page_count']}`.",
"",
]
for manual in index["manuals"]:
lines.append(f"## {manual['filename']}")
toc_pages = ", ".join(str(item) for item in manual["toc_pdf_pages"]) or "not detected"
lines.append("")
lines.append(f"PDF pages: `{manual['page_count']}`. Detected TOC PDF pages: `{toc_pages}`.")
entries = manual["toc_entries"]
if not entries:
lines.extend(["", "No reliable TOC lines were extracted. Use the full-text index or inspect the first 40 PDF pages.", ""])
continue
lines.extend(["", "| 手册页 | 章节/条目 | 目录 PDF 页 |", "|---:|---|---:|"])
seen = set()
for entry in entries:
key = (entry["title"], entry["printed_page"])
if key in seen:
continue
seen.add(key)
title = str(entry["title"]).replace("|", "\\|")
lines.append(f"| {entry['printed_page']} | {title} | {entry['toc_pdf_page']} |")
lines.append("")
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text("\n".join(lines), encoding="utf-8")


def main() -> None:
parser = argparse.ArgumentParser(description="Build a page-level full-text and table-of-contents index for Xinje manuals.")
parser.add_argument("--manual-dir", required=True, type=pathlib.Path)
parser.add_argument("--output-db", required=True, type=pathlib.Path)
parser.add_argument("--output-toc-json", required=True, type=pathlib.Path)
parser.add_argument("--output-toc-md", required=True, type=pathlib.Path)
parser.add_argument("--toc-scan-pages", type=int, default=40)
args = parser.parse_args()
if args.toc_scan_pages < 1:
raise SystemExit("--toc-scan-pages must be positive")
index = build_index(args.manual_dir, args.output_db, args.toc_scan_pages)
args.output_toc_json.parent.mkdir(parents=True, exist_ok=True)
args.output_toc_json.write_text(json.dumps(index, ensure_ascii=False, indent=2), encoding="utf-8")
write_toc_markdown(index, args.output_toc_md)
print(
f"indexed {index['manual_count']} manuals and {index['page_count']} pages; "
f"database: {args.output_db}",
flush=True,
)


if __name__ == "__main__":
if hasattr(sys.stdout, "reconfigure"):
sys.stdout.reconfigure(encoding="utf-8")
main()

+ 240
- 0
scripts/catalog_xinje_downloads.py Просмотреть файл

@@ -0,0 +1,240 @@
import argparse
import csv
import datetime as dt
import html
import json
import pathlib
import re
import time
import urllib.parse
import urllib.request
from collections import Counter


BASE = "https://www.xinje.com"
DOWNLOAD_ENDPOINT = "/web/downloadCenter/file"

DOCUMENT_CATEGORIES = {
16: "产品手册",
19: "彩页/样本",
31: "产品图纸",
33: "EPLAN",
49: "认证证书",
}

PLC_HMI_KEYWORDS = [
"PLC",
"可编程",
"控制器",
"XDP",
"XDPPro",
"TouchWin",
"人机界面",
"HMI",
"XD",
"XL",
"XG",
"XC",
"XS",
"TS",
"TG",
]


def fetch(params: dict[str, str | int]) -> str:
query = urllib.parse.urlencode(params)
url = f"{BASE}{DOWNLOAD_ENDPOINT}?{query}"
request = urllib.request.Request(
url,
headers={
"User-Agent": "Mozilla/5.0 (Codex Xinje catalog)",
"X-Requested-With": "XMLHttpRequest",
},
)
with urllib.request.urlopen(request, timeout=40) as response:
return response.read().decode("utf-8", "ignore")


def clean_text(value: str) -> str:
value = re.sub(r"<[^>]+>", "", value)
return html.unescape(re.sub(r"\s+", " ", value).strip())


def text_between(pattern: str, block: str) -> str:
match = re.search(pattern, block, flags=re.I | re.S)
return clean_text(match.group(1)) if match else ""


def parse_results(markup: str) -> list[dict[str, str]]:
blocks = re.findall(r"(<li>\s*<div class=\"con\">.*?</li>)", markup, flags=re.I | re.S)
results = []
for block in blocks:
href_match = re.search(r'href=["\']([^"\']+)["\']', block, flags=re.I)
href = html.unescape(href_match.group(1)) if href_match else ""
title = text_between(r"<h3[^>]*>(.*?)</h3>", block)
download_name = text_between(r'download=["\']([^"\']+)["\']', block)
results.append(
{
"id": text_between(r'id=["\']file-(\d+)["\']', block),
"title": title or download_name,
"download_name": download_name,
"url": href,
"size": text_between(r'class=["\']filesize["\'][^>]*>.*?<em>(.*?)</em>', block),
"version": text_between(r'class=["\']filever["\'][^>]*>.*?<em>(.*?)</em>', block),
"file_type": text_between(r'class=["\']filetype["\'][^>]*>.*?<em>(.*?)</em>', block),
"update_date": text_between(r'class=["\']filedate["\'][^>]*>.*?<em>(.*?)</em>', block),
}
)
return results


def parse_max_page(markup: str, one_id: int) -> int:
pages = [1]
pattern = rf"changePage\((\d+),\s*0,\s*{one_id},\s*0\)"
pages.extend(int(value) for value in re.findall(pattern, markup))
jump_match = re.search(r'id=["\']pageJump["\'][^>]+max=["\'](\d+)["\']', markup, flags=re.I)
if jump_match:
pages.append(int(jump_match.group(1)))
return max(pages)


def collect_category(one_id: int, delay: float) -> list[dict[str, str]]:
first_markup = fetch({"seriesId": 0, "oneId": one_id, "twoId": 0, "page": 1, "fileName": ""})
max_page = parse_max_page(first_markup, one_id)
items = []
for page in range(1, max_page + 1):
markup = first_markup if page == 1 else fetch(
{"seriesId": 0, "oneId": one_id, "twoId": 0, "page": page, "fileName": ""}
)
for item in parse_results(markup):
item["category_id"] = str(one_id)
item["category"] = DOCUMENT_CATEGORIES.get(one_id, str(one_id))
item["source"] = f"{BASE}/web/downloadCenter/index"
items.append(item)
if delay:
time.sleep(delay)
return items


def write_csv(path: pathlib.Path, rows: list[dict[str, str]]) -> None:
fieldnames = [
"id",
"category_id",
"category",
"title",
"download_name",
"file_type",
"size",
"version",
"update_date",
"url",
"source",
]
with path.open("w", encoding="utf-8-sig", newline="") as handle:
writer = csv.DictWriter(handle, fieldnames=fieldnames)
writer.writeheader()
for row in rows:
writer.writerow({field: row.get(field, "") for field in fieldnames})


def write_json(path: pathlib.Path, rows: list[dict[str, str]]) -> None:
payload = {
"cataloged_at": dt.datetime.now(dt.timezone.utc).isoformat(),
"source": f"{BASE}/web/downloadCenter/index",
"scope": "Xinje download-center document-like categories; metadata only, no file downloads",
"categories": DOCUMENT_CATEGORIES,
"total_items": len(rows),
"items": rows,
}
path.write_text(json.dumps(payload, ensure_ascii=False, indent=2), encoding="utf-8")


def write_markdown(path: pathlib.Path, rows: list[dict[str, str]]) -> None:
by_category = Counter(row["category"] for row in rows)
by_type = Counter((row.get("file_type") or "unknown").lower() for row in rows)
plc_hmi = [
row for row in rows
if any(keyword.lower() in (row.get("title", "") + row.get("download_name", "")).lower()
for keyword in PLC_HMI_KEYWORDS)
]
recent = sorted(rows, key=lambda row: row.get("update_date", ""), reverse=True)[:20]

lines = [
"# Xinje Official Document Catalog",
"",
f"Cataloged at: {dt.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}",
"",
"Scope: metadata from Xinje download-center document-like categories. Files are not downloaded by this script.",
"",
"## Counts By Category",
"",
"| Category | Count |",
"|---|---:|",
]
for category, count in by_category.most_common():
lines.append(f"| {category} | {count} |")

lines.extend(["", "## Counts By File Type", "", "| File type | Count |", "|---|---:|"])
for file_type, count in by_type.most_common():
lines.append(f"| {file_type} | {count} |")

lines.extend([
"",
"## Recent Items",
"",
"| ID | Category | Title | Type | Version | Update date |",
"|---|---|---|---|---|---|",
])
for row in recent:
lines.append(
f"| {row.get('id','')} | {row.get('category','')} | {row.get('title','')} | "
f"{row.get('file_type','')} | {row.get('version','')} | {row.get('update_date','')} |"
)

lines.extend([
"",
"## PLC/HMI Candidates",
"",
"Use the full CSV/JSON catalog for exact URLs. This section highlights likely PLC/HMI-related entries.",
"",
"| ID | Category | Title | Type | Version | Update date |",
"|---|---|---|---|---|---|",
])
for row in plc_hmi[:120]:
lines.append(
f"| {row.get('id','')} | {row.get('category','')} | {row.get('title','')} | "
f"{row.get('file_type','')} | {row.get('version','')} | {row.get('update_date','')} |"
)

path.write_text("\n".join(lines) + "\n", encoding="utf-8")


def main() -> None:
parser = argparse.ArgumentParser(description="Catalog Xinje download-center document metadata.")
parser.add_argument("--output-dir", default="assets/catalogs", help="Directory for JSON/CSV/MD outputs.")
parser.add_argument("--delay", type=float, default=0.15, help="Delay between page requests.")
parser.add_argument("--categories", default=",".join(str(key) for key in DOCUMENT_CATEGORIES))
args = parser.parse_args()

rows = []
seen = set()
for one_id in [int(value) for value in args.categories.split(",") if value.strip()]:
for item in collect_category(one_id, args.delay):
key = item.get("id") or item.get("url")
if key in seen:
continue
seen.add(key)
rows.append(item)

rows.sort(key=lambda row: (row.get("category_id", ""), row.get("update_date", ""), row.get("id", "")), reverse=True)

output_dir = pathlib.Path(args.output_dir)
output_dir.mkdir(parents=True, exist_ok=True)
write_json(output_dir / "xinje-official-document-catalog.json", rows)
write_csv(output_dir / "xinje-official-document-catalog.csv", rows)
write_markdown(output_dir / "xinje-official-document-catalog-summary.md", rows)
print(f"cataloged {len(rows)} items into {output_dir}")


if __name__ == "__main__":
main()

+ 72
- 0
scripts/download_catalog_ids.py Просмотреть файл

@@ -0,0 +1,72 @@
import argparse
import csv
import pathlib
import re
import sys

from download_xinje_file import request, quote_url
import urllib.request


INVALID_FILENAME_CHARS = r'<>:"/\|?*'


def clean_filename(value: str) -> str:
value = "".join("_" if ch in INVALID_FILENAME_CHARS else ch for ch in value)
value = re.sub(r"\s+", " ", value).strip(" .")
return value or "xinje-download"


def build_filename(row: dict[str, str]) -> str:
base = row.get("download_name") or row.get("title") or row["id"]
base = clean_filename(base)
version = clean_filename(row.get("version") or "")
update_date = clean_filename(row.get("update_date") or "")
suffix_parts = []
if version:
suffix_parts.append(f"v{version}")
if update_date:
suffix_parts.append(update_date)
suffix = f" ({', '.join(suffix_parts)})" if suffix_parts else ""
extension = (row.get("file_type") or "pdf").lower().lstrip(".")
return f"{base}{suffix}.{extension}"


def load_rows(catalog: pathlib.Path) -> dict[str, dict[str, str]]:
with catalog.open("r", encoding="utf-8-sig", newline="") as handle:
return {row["id"]: row for row in csv.DictReader(handle)}


def download(row: dict[str, str], output_dir: pathlib.Path, skip_existing: bool) -> pathlib.Path:
output = output_dir / build_filename(row)
if output.exists() and skip_existing:
print(f"skip existing {row['id']}: {output}")
return output

url = quote_url(row["url"])
output.parent.mkdir(parents=True, exist_ok=True)
with urllib.request.urlopen(request(url), timeout=120) as response:
output.write_bytes(response.read())
print(f"downloaded {row['id']}: {output} ({output.stat().st_size} bytes)")
return output


def main() -> None:
parser = argparse.ArgumentParser(description="Download Xinje catalog files by ID.")
parser.add_argument("--catalog", required=True, type=pathlib.Path)
parser.add_argument("--output-dir", required=True, type=pathlib.Path)
parser.add_argument("--ids", required=True, nargs="+")
parser.add_argument("--overwrite", action="store_true")
args = parser.parse_args()

rows = load_rows(args.catalog)
missing = [item for item in args.ids if item not in rows]
if missing:
raise SystemExit(f"catalog IDs not found: {', '.join(missing)}")

for item in args.ids:
download(rows[item], args.output_dir, skip_existing=not args.overwrite)


if __name__ == "__main__":
sys.exit(main())

+ 52
- 0
scripts/download_xinje_file.py Просмотреть файл

@@ -0,0 +1,52 @@
import pathlib
import sys
import urllib.parse
import urllib.request


BASE = "https://www.xinje.com"


def request(url: str) -> urllib.request.Request:
return urllib.request.Request(
url,
headers={
"User-Agent": "Mozilla/5.0 (Codex Xinje download)",
"Referer": f"{BASE}/web/downloadCenter/index",
"X-Requested-With": "XMLHttpRequest",
},
)


def quote_url(url: str) -> str:
parts = urllib.parse.urlsplit(url)
path = urllib.parse.quote(parts.path, safe="/%")
query = urllib.parse.quote(parts.query, safe="=&%")
return urllib.parse.urlunsplit((parts.scheme, parts.netloc, path, query, parts.fragment))


def resolve_source(source: str) -> str:
if source.isdigit():
req = request(f"{BASE}/web/file-download/down/{source}")
with urllib.request.urlopen(req, timeout=30) as response:
signed_url = response.read().decode("utf-8", "ignore").strip()
# The site may return a signed OSS URL. In some environments CDN auth
# conflicts with query-string signatures, so direct catalog URLs may be
# more reliable. Keep the signed URL untouched when using file IDs.
return signed_url
return quote_url(source)


def main() -> None:
if len(sys.argv) != 3:
raise SystemExit("usage: download_xinje_file.py <url-or-file-id> <output-path>")
url = resolve_source(sys.argv[1])
output = pathlib.Path(sys.argv[2])
output.parent.mkdir(parents=True, exist_ok=True)
with urllib.request.urlopen(request(url), timeout=120) as response:
output.write_bytes(response.read())
print(f"downloaded {output} ({output.stat().st_size} bytes)")


if __name__ == "__main__":
main()

+ 29
- 0
scripts/extract_pdf_pages.py Просмотреть файл

@@ -0,0 +1,29 @@
import pathlib
import sys

import pdfplumber


def main() -> None:
if len(sys.argv) != 5:
raise SystemExit("usage: extract_pdf_pages.py <pdf-path> <start-page> <end-page> <output-md>")
pdf_path = pathlib.Path(sys.argv[1])
start = int(sys.argv[2])
end = int(sys.argv[3])
output = pathlib.Path(sys.argv[4])
output.parent.mkdir(parents=True, exist_ok=True)

chunks = [f"# Extracted PDF Pages\n\nSource: `{pdf_path}`\n\nPages: {start}-{end}\n"]
with pdfplumber.open(str(pdf_path)) as pdf:
for page_number in range(start, end + 1):
page = pdf.pages[page_number - 1]
text = page.extract_text(x_tolerance=1, y_tolerance=3) or ""
chunks.append(f"\n\n## PDF Page {page_number}\n\n{text.strip()}\n")
output.write_text("\n".join(chunks), encoding="utf-8")
print(f"wrote {output}")


if __name__ == "__main__":
if hasattr(sys.stdout, "reconfigure"):
sys.stdout.reconfigure(encoding="utf-8")
main()

+ 40
- 0
scripts/probe_pdf_manuals.py Просмотреть файл

@@ -0,0 +1,40 @@
import argparse
import pathlib

import pdfplumber
from pypdf import PdfReader


def extract_frontmatter(pdf_path: pathlib.Path, pages: int) -> str:
chunks: list[str] = []
with pdfplumber.open(str(pdf_path)) as pdf:
max_page = min(pages, len(pdf.pages))
for index in range(max_page):
text = pdf.pages[index].extract_text(x_tolerance=1, y_tolerance=3) or ""
chunks.append(f"\n## Page {index + 1}\n\n{text.strip()}\n")
return "\n".join(chunks)


def main() -> None:
parser = argparse.ArgumentParser(description="Probe Xinje PDF manuals for page counts and frontmatter text.")
parser.add_argument("--manual-dir", required=True, type=pathlib.Path)
parser.add_argument("--output", required=True, type=pathlib.Path)
parser.add_argument("--pages", type=int, default=12)
args = parser.parse_args()

args.output.parent.mkdir(parents=True, exist_ok=True)
chunks: list[str] = ["# PDF Manual Probe\n"]
for pdf_path in sorted(args.manual_dir.glob("*.pdf")):
reader = PdfReader(str(pdf_path))
chunks.append(f"\n# {pdf_path.name}\n")
chunks.append(f"- Path: `{pdf_path}`")
chunks.append(f"- Size bytes: {pdf_path.stat().st_size}")
chunks.append(f"- PDF pages: {len(reader.pages)}")
chunks.append(extract_frontmatter(pdf_path, args.pages))

args.output.write_text("\n".join(chunks), encoding="utf-8")
print(f"wrote {args.output}")


if __name__ == "__main__":
main()

+ 59
- 0
scripts/release_skill.ps1 Просмотреть файл

@@ -0,0 +1,59 @@
[CmdletBinding()]
param(
[switch]$NoPush
)

$ErrorActionPreference = 'Stop'

$repositoryRoot = Split-Path -Parent $PSScriptRoot
$skillFile = Join-Path $repositoryRoot 'SKILL.md'

Set-Location -LiteralPath $repositoryRoot

$pendingChanges = git status --porcelain
if (-not $pendingChanges) {
throw 'No skill changes are pending. Update the skill before creating a release.'
}

$content = Get-Content -LiteralPath $skillFile -Raw -Encoding UTF8
$match = [regex]::Match($content, '(?m)^Version:\s*(?<version>\d+\.\d+\.\d+)\s*$')
if (-not $match.Success) {
throw "Could not find a 'Version: x.y.z' line in $skillFile."
}

$currentVersion = [version]$match.Groups['version'].Value
$nextVersion = '{0}.{1}.0' -f $currentVersion.Major, ($currentVersion.Minor + 1)
$updatedContent = [regex]::Replace(
$content,
'(?m)^Version:\s*\d+\.\d+\.\d+\s*$',
"Version: $nextVersion",
1
)
Set-Content -LiteralPath $skillFile -Value $updatedContent -Encoding UTF8

git add --all
if ($LASTEXITCODE -ne 0) {
throw 'git add failed.'
}

git diff --cached --quiet
if ($LASTEXITCODE -eq 0) {
throw 'No staged changes found after version update.'
}
if ($LASTEXITCODE -ne 1) {
throw 'Could not inspect the staged Git diff.'
}

git commit -m "release: xinje-plc-programming v$nextVersion"
if ($LASTEXITCODE -ne 0) {
throw 'git commit failed.'
}

if (-not $NoPush) {
git push origin HEAD
if ($LASTEXITCODE -ne 0) {
throw 'Release commit was created, but git push failed. Resolve the remote issue and push the existing commit.'
}
}

Write-Output "Released xinje-plc-programming v$nextVersion"

+ 36
- 0
scripts/search_pdf_keywords.py Просмотреть файл

@@ -0,0 +1,36 @@
import pathlib
import re
import sys

from pypdf import PdfReader


def compact(text: str) -> str:
return re.sub(r"\s+", " ", text or "").strip()


def main() -> None:
if len(sys.argv) < 3:
raise SystemExit("usage: search_pdf_keywords.py <pdf-path> <keyword> [keyword...]")
pdf_path = pathlib.Path(sys.argv[1])
keywords = sys.argv[2:]
reader = PdfReader(str(pdf_path))
print(f"PDF: {pdf_path}")
print(f"PAGES: {len(reader.pages)}")
for page_index, page in enumerate(reader.pages, start=1):
text = compact(page.extract_text() or "")
if not text:
continue
for keyword in keywords:
if keyword in text:
pos = text.find(keyword)
start = max(0, pos - 160)
end = min(len(text), pos + len(keyword) + 260)
print(f"\nPAGE {page_index} KEYWORD {keyword}")
print(text[start:end])


if __name__ == "__main__":
if hasattr(sys.stdout, "reconfigure"):
sys.stdout.reconfigure(encoding="utf-8")
main()

+ 56
- 0
scripts/search_xinje_manuals.py Просмотреть файл

@@ -0,0 +1,56 @@
import argparse
import pathlib
import sqlite3
import sys


def quoted_phrase(value: str) -> str:
return '"' + value.replace('"', '""') + '"'


def main() -> None:
parser = argparse.ArgumentParser(description="Search the Xinje manual page index without scanning PDFs.")
parser.add_argument("--index", required=True, type=pathlib.Path)
parser.add_argument("--manual", help="Case-insensitive filename substring filter")
parser.add_argument("--limit", type=int, default=12)
parser.add_argument("query", nargs="+")
args = parser.parse_args()
query = " ".join(args.query).strip()
if not query:
raise SystemExit("query cannot be empty")
if args.limit < 1:
raise SystemExit("--limit must be positive")
connection = sqlite3.connect(args.index)
try:
where = ""
parameters = []
if args.manual:
where = " AND lower(filename) LIKE ?"
parameters.append(f"%{args.manual.lower()}%")
try:
rows = connection.execute(
"SELECT filename, pdf_page, snippet(page_search, 3, '[', ']', ' ... ', 18) "
"FROM page_search WHERE page_search MATCH ?" + where + " ORDER BY bm25(page_search) LIMIT ?",
[quoted_phrase(query), *parameters, args.limit],
).fetchall()
except sqlite3.OperationalError:
rows = []
if not rows:
rows = connection.execute(
"SELECT filename, pdf_page, substr(text, max(1, instr(text, ?) - 120), 420) "
"FROM page_search WHERE instr(text, ?) > 0" + where + " LIMIT ?",
[query, query, *parameters, args.limit],
).fetchall()
print(f"query: {query}")
print(f"hits: {len(rows)}")
for filename, page, excerpt in rows:
print(f"\n[{filename}] PDF page {page}")
print(excerpt)
finally:
connection.close()


if __name__ == "__main__":
if hasattr(sys.stdout, "reconfigure"):
sys.stdout.reconfigure(encoding="utf-8")
main()

Загрузка…
Отмена
Сохранить