Device Code 對照表
在不同協定 / 工具下,Keyence KV 的同一個記憶體區會有不同的命名與編碼。 本表整理出 KV native(KV STUDIO 顯示)↔ MC Protocol(Mitsubishi 標準)↔ Host Link Protocol 三方對照。
完整對照矩陣
| 概念名稱 | KV native | Host Link 用法 | MC Protocol Device | MC ASCII | MC Binary | 範圍(KV-7/8000) |
|---|---|---|---|---|---|---|
| Relay(含 input/output) | R | R00000-R199915 | X 或 Y | X* / Y* | 9C / 9D | R0-R199915 |
| Link relay | B | B0000-B7FFF | B | B* | A0 | 0-7FFF (hex) |
| Internal auxiliary relay | MR | MR00000-MR399915 | M | M* | 90 | 0-63999 |
| Latch relay | LR | LR00000-LR99915 | L | L* | 92 | 0-15999 |
| Control relay | CR | CR0000-CR7915 | SM | SM | 91 | 0-1279 |
| Control memory | CM | CM0000-CM7599 | SD | SD | A9 | 0-7599 |
| Data memory | DM | DM00000-DM65534 | D | D* | A8 | 0-65534 |
| Extended data memory | EM | EM00000-EM65534 | D (offset +100000) | D* | A8 | 0-65534 (映射 D100000-D165534) |
| File register | FM | FM00000-FM32767 | R | R* | AF | 0-32767 |
| File register (extended) | ZF | ZF000000-ZF524287 | ZR | ZR | B0 | 0-524287 (hex) |
| Link register | W | W0000-W7FFF | W | W* | B4 | 0-7FFF (hex) |
| Temporary data memory | TM | TM000-TM511 | — | — | — | 0-511 |
| Index register | Z | Z01-Z12 | — | — | — | KV-7/8000: Z01-Z12 |
| Timer current value | TC | T0000-T3999 | TN | TN | C2 | 0-3999 |
| Timer set value | TS | T0000-T3999 | — | — | — | 0-3999(僅 Host Link 用 TS) |
| Timer contact (boolean) | T | T0000-T3999 | TS | TS | C1 | 0-3999 |
| Counter current value | CC | C0000-C3999 | CN | CN | C5 | 0-3999 |
| Counter set value | CS | C0000-C3999 | — | — | — | 0-3999 |
| Counter contact (boolean) | C | C0000-C3999 | CS | CS | C4 | 0-3999 |
| Work relay (KV-7/8000) | VB | VB0000-VBF9FF | — | — | — | 0-F9FF (hex) |
| Work memory (KV-7/8000) | VM | VM00000-VM589823 | — | — | — | 0-589823 |
| Digital trimmer (KV-7/8000) | AT | AT0-AT7 | — | — | — | 0-7 |
重要對照(最常用)
McpX 函式庫對應(Prefix enum)
McpX 函式庫使用 Mitsubishi 標準命名,對應到 KV:
McpXLib.Enums.Prefix.M → KV `MR` (Internal auxiliary relay)
McpXLib.Enums.Prefix.D → KV `DM` (Data memory)
McpXLib.Enums.Prefix.X → KV `R` (Input relay)
McpXLib.Enums.Prefix.Y → KV `R` (Output relay)
McpXLib.Enums.Prefix.B → KV `B` (Link relay)
McpXLib.Enums.Prefix.W → KV `W` (Link register)
McpXLib.Enums.Prefix.L → KV `LR` (Latch relay)
McpXLib.Enums.Prefix.SM → KV `CR` (Control relay)
McpXLib.Enums.Prefix.SD → KV `CM` (Control memory)
McpXLib.Enums.Prefix.R → KV `FM` (File register)
McpXLib.Enums.Prefix.ZR → KV `ZF` (File register extended)
McpXLib.Enums.Prefix.TN → KV `TC` (Timer current)
McpXLib.Enums.Prefix.TS → KV `T` (Timer contact)
McpXLib.Enums.Prefix.CN → KV `CC` (Counter current)
McpXLib.Enums.Prefix.CS → KV `C` (Counter contact)
範例:
// 讀 KV DM0 一個 word
short value = mcpx.Read<short>(Prefix.D, "0");
// 寫 KV MR100 = ON
mcpx.Write<bool>(Prefix.M, "100", true);
// 讀 KV R200..R207(8 個 input/output bit)
bool[] inputs = mcpx.BatchRead<bool>(Prefix.X, "200", 8);
XYM Expression(Mitsubishi-style 表達)
某些 KV STUDIO 工具或第三方軟體使用 XYM 表達式 — 這是 Keyence 官方提供的 Mitsubishi 相容寫法:
| KV Native | XYM | XYM 範圍 |
|---|---|---|
R (Relay) | X 或 Y | 0000-1999F (KV-7/8000) |
MR (Internal aux) | M | 00000-63999 |
LR (Latch) | L | 0000-999F |
DM (Data memory) | D | 00000-65534 |
EM (Extended DM) | E | 00000-65534 |
FM (File register) | F | 00000-32767 |
抽象 [B] [W] notation(規格書常用)
某些客戶 / 供應商在規格書內用抽象命名 [B] 與 [W]:
| 抽象 | KV native(最常見對應) | KV native(替代可能) |
|---|---|---|
[B] (Bit memory) | MR | B 或 R |
[W] (Word memory) | DM | EM 或 W |
⚠ 抽象命名
[B][W]不是 MC Protocol / Host Link 的標準寫法,僅出現在某些第三方規格書(例如 Hirata EFEM PLC-PC Interface V1.15)。 真實對應需與 PLC ladder 工程師確認。
Address 進位制
不同 device 用不同進位:
| Device 類型 | 進位制 | 例 |
|---|---|---|
R, MR, LR, CR, CM, DM, EM, FM, TM, T, C, VM | decimal | DM0 / DM65534 |
B, W, ZF, VB | hexadecimal | B7FFF / W7FFF / ZF7FFFF |
MC Protocol 的 Address 在 binary frame 中永遠是 hex(不論 device 原生進位)。在 ASCII frame 中按 device 原生進位顯示。
32-bit Atomicity 規則
讀寫 32-bit 資料(.D / .L 或 word-pair):
- 兩個連續 word 構成 32-bit
- 只有 leading device No. 為偶數時,保證上下 16-bit 同時更新
- 奇數 leading 可能讀到「下半 word 是新的,上半 word 是舊的」
範例:
DM10 (low) + DM11 (high) → ✅ atomic(10 偶數)
DM11 (low) + DM12 (high) → ❌ 不保證 atomic
參考
- KV-XCM02 User's Manual:Chapter 5 §5-5(Host Link)、Chapter 6 §6-5(MC Protocol)
- Keyence ladder reference manual(XYM 對照詳細版本)
- 相關文件: