Resolving CMND(490) Parameter Errors on Omron CS/CJ PLCs

James Nishida11 min read
CJ/CP SeriesOmronTechnical Reference
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Overview

The CMND(490) instruction on Omron CS/CJ-series PLCs routinely causes confusion when programmers try to use it for what looks like a simple block-compare between the DM area and a Compact Flash (CF) file created by FWRIT(701). CMND(490) does not perform a memory-to-memory comparison. It is a wrapper that emits a FINS command frame on the host port, and writes the response into the DM area starting at the operand D. The "S+2" the operator could not find in the manual is not a separate parameter; it is the third word of the user-built command block that lives in DM starting at the operand S. This reference documents the operand model, exposes the more efficient alternatives (MCMP and FREAD(700)), provides a turnkey ladder implementation for the canonical "120 words at DM0 vs. 120 words at DM300" requirement, and lists the main/sub error codes you will see when CMND(490) is misused for that job.

CMND(490) Operand Structure

The mnemonic and operand layout for CMND(490) on a CJ1-H or CJ2M CPU is defined in the SYSMAC CS/CJ/NSJ Series Programming Manual:

Operand Symbol Meaning Constraint
1 S First word of the FINS command block resident in I/O, DM, EM, or HR area Word address; entire command including frame must fit in the area
2 D First word of the response storage area Must be sized to receive the response (see C)
3 C Control word. Low byte = number of command words, high byte = number of response words Command 0–1000 hex (max 4096 bytes), response 0–1000 hex

The "S+2" the user could not locate is simply the third word inside the S buffer. The FINS command block the operator assembles follows the standard FINS header:

Word Field Typical content for an FINS command
S Command Code Low (MRC) Main request code (e.g., 0x01)
S+1 Command Code High (SRC) Sub request code (e.g., 0x01 for RUN)
S+2 FINS parameter 1 Begin parameter block (node number, file name, area code, etc.)
S+3 FINS parameter 2 ...
S+n FINS parameter n Final command word before C count is reached

CMND(490) does not interpret S+2. It just copies the C count of 16-bit words out to the FINS port and back. The interpretation of S+2 is defined entirely by the FINS service code you put in S/S+1. There is no 4th operand in CX-Programmer.

Why CMND(490) Does Not Suit DM-to-File Block Compare

The purpose of CMND(490) is to send a FINS frame to a remote (or local) node. Looking at the use case — "compare 120 words of DM with 120 words already on the CF card written by FWRIT(701)" — CMND(490) is the wrong primitive because:

  1. No FINS service exists that compares an in-CPU DM range to a Compact Flash file. The Programming Manual defines CMND(490) only as a transport for predefined FINS commands (RUN/STOP, file transfers, area reads/writes, etc.).
  2. Even if you wrapped a "FILE AREA COMPARE" pseudo-command, the CJ1 family returns a status code only. It does not deliver byte-level mismatch data, so you could not identify which of the 120 words differ — you would only learn that the file is or is not equal.
  3. The TRANSMIT area in the CJ1/CJ2 memory map (CIO 0000–CIO 0063 with 240 words buffer control) holds the FINS frame. Misusing CMND(490) for block equality requires you to manually write the file to DM via FREAD(700) and then compare in ladder logic anyway.

MCMP Block Comparison Specification

The dedicated block comparator for the CS/CJ family is MCMP (Multiple Compare). Always verify the function number against your CPU firmware in CX-Programmer's Instruction Reference, but on CJ1-H (ver 4.0+), CJ2M, and CS1-H units it operates as follows:

Operand Meaning Notes
S1 First word of block 1 (e.g., DM0) Word address in I/O, DM, EM, HR, or AR
S2 First word of block 2 (e.g., DM300) Word address; can be in any same-sized area
N Number of consecutive words Fixed at 16 (constant or indirect via CIO)
D Result word — 16 bits, one bit per word pair Bit 15 = mismatch in S1 vs S2 for first word; bit 0 for the 16th

If any word in the 16-word range differs, the corresponding bit in D turns ON. This is far cheaper than CMND(490) for compare tasks: a single MCMP rung executes in a microsecond-scale scan versus the millisecond-scale FINS round trip.

FREAD(700) / FWRIT(701) File-Backed Comparison Workflow

The most universal answer for "DM vs. CF file" is to read the file back into a DM scratch area and then run MCMP. FREAD(700) reads from a Memory Card or Compact Flash file into the destination DM area:

Operand Meaning
S Specifies file/source offset. Byte 0–7 = filename 1 (8 ASCII chars, padded with 0x20), byte 8–15 = filename 2 (chained read), byte 16+ = offset in words within filename 1
D First destination word in DM (or CIO, WR, HR, EM)
C Control word. Low byte = destination area code, high byte/lower bits = number of words to read (max 65,535)

Procedure: FWRIT(701) writes DM0..DM119 to a CF file under name "BLOCK1". On compare, FREAD(700) pulls the same 120 words from "BLOCK1" starting at file offset 0 into DM200..DM319, then 8 MCMP calls (each covering 16 words) walk DM0..DM119 against DM200..DM319. The result pattern is OR-folded into a single mismatch flag.

Comparison Method Selection

Method Best for Data returned Scan cost CPU support
MCMP (16-word) DM-to-DM, EM-to-DM, HR-to-CIO equality 16-bit per-word mismatch map Tens of microseconds per call CS1/CJ1/CJ2 all units
FREAD(700) + MCMP DM vs. CF file 16-bit per-word mismatch map 1 FINS-level cycle per read + microseconds per MCMP CS1/CJ1/CJ2 with CF slot
CMND(490) wrapping FILE TRANSFER 22 0C UM program area vs. file only Bytes-equal / bytes-not-equal flag only (per FINS protocol) Multiple scans (FINS turnaround) CJ1 only; UM transfer blocked on CS1
FREAD(700) + bytewise CMP(020) Sub-word mismatches inside a DWORD (rare) Any bit-level flag you design 120 rungs worst case All units

Step-by-Step: 120-Word Compare DM0..DM119 vs DM300..DM419

  1. Reserve scratch in DM1000..DM1199 to hold the file image (120 words). Confirm DM size supports this on your CPU (CJ1-H = 32K DM, CJ2M = 32K DM, verify in project properties).
  2. Add a normally-open contact B_MatchReq and the FREAD(700) rung reading "BLOCK1" starting at file offset 0 into DM1000 with control word 0x00 0078 (120 words) using DM-area destination code 0x00 (per CX-Programmer area code table).
  3. Add a NOT-first-cycle interlock (P_FirstCycle) so FREAD runs once per request, gated by the A200.15 first-scan bit. Use a latching self-hold coil B_Run cleared by the FREAD completion flag (A343.07 or equivalent per CPU; verify on the Peripheral Service conditional flags).
  4. Once F_READ_OK comes on, drop eight MCMP calls in sequence covering each 16-word slice:
MCMP  DM0   DM300  DM1000   ; result word DM1200, bits match  DM0…DM15 vs DM300…DM315
MCMP  DM16  DM316  DM1201   ; DM16…DM31 vs DM316…DM331
MCMP  DM32  DM332  DM1202
MCMP  DM48  DM348  DM1203
MCMP  DM64  DM364  DM1204
MCMP  DM80  DM380  DM1205
MCMP  DM96  DM396  DM1206
MCMP  DM112 DM412  DM1207   ; DM112…DM119 vs DM412…DM419 (last slice is partial 8 words; MCMP N=16 still compares 16 — restrict source lengths accordingly)
  1. OR-merge the eight result words into a single mismatch flag. The cleanest way is to copy each result word to a single OR-collector using ORW(035):
ORW(035)  DM1200  DM1201  DM1300
ORW(035)  DM1300  DM1202  DM1300
ORW(035)  DM1300  DM1203  DM1300
ORW(035)  DM1300  DM1204  DM1300
ORW(035)  DM1300  DM1205  DM1300
ORW(035)  DM1300  DM1206  DM1300
ORW(035)  DM1300  DM1207  DM1300
; DM1300 == 0 means every word pair matched (no bit set)

The last 16-word MCMP above maps an 8-word real block into a 16-word compare. Always clip the trailing calls to N=8 (or whatever remainder remains) by pointing them at partial regions, or split the file into 120 words deliberately padded in advance by FWRIT to keep MCMP N==16 constant. Otherwise, MCMP reads 8 words of valid data plus 8 words of unrelated DM and flags false mismatches.

Programmatic CMND(490) for UM Area File Compare

If the goal really is to compare two program-area files (the operator explicitly mentioned "PROGRAM Area File TRANSFER 22 0C"), then CMND(490) is the correct primitive, but only for UM area compare — not DM. The FINS frame to invoke the file compare service 22 0C is constructed in DM starting at S. A complete frame assembly looks like:

Word Hex Purpose
S 0x22 MRC for FILE services
S+1 0x0C SRC for FILE COMPARE
S+2 0x00 Reserved / file number high byte
S+3 0x10 File 1 number (e.g., file 0016 = program file)
S+4 0x00 Reserved
S+5 0x20 File 2 number
C 0x0006 6 command words, response length set in upper byte

The Programming Manual explicitly states that versioned instructions including certain CMND variants are "supported by the CJ1-H-R CPU Units only." If you are targeting file-equality in the UM area, you must use a CJ1-H-R CPU (e.g., CJ1H-CPU66H-R). CS1, CJ2M, and standard CJ1 units reject the call with the corresponding service-not-supported main error.

CMND(490) Main / Sub Error Code Reference

When CMND(490) reports a non-zero status, the failure is two-tier: the main code indicates the FINS service class; the sub code gives the specific failure reason. The PTC Kepware OMRON FINS Ethernet error table documents the canonical KEPServer-exercised codes, and the values below mirror what you see from CX-Integrator's "FINS Command Test":

Main (hex) Sub (hex) Meaning Typical trigger in CMND(490)
0x00 0x00 Normal completion Reply successfully received into D buffer
0x01 0x02 Data length error — C count inconsistent with S or D size Number of command words > C, or D buffer too small for response
0x02 0x01 Local node busy Serial port engaged by another command
0x02 0x02 Send node busy Previous CMND still in flight
0x03 0x02 Send destination node address out of range — third node field mis-set Broadcasting specified where only single-node is allowed
0x04 0x01 Routing error — no path to target node Wrong network address in command
0x10 0x00 Command too long Command word count exceeds 1000 hex
0x10 0x03 Command frame length field vs. actual mismatch S buffer contains more data than C declares
0x22 0x0C sub-errors FILE COMPARE service errors File does not exist; file size mismatch
Field tip: code 0x0302 is the most common CMND(490) error after a botched first implementation. It almost always means the destination node byte was set to 0xFF (broadcast) on a service that does not allow broadcast. Set the third node byte (typically S+2 of the command frame in conjunction with the node in the FINS frame header) to a valid single address, e.g., 0x01 for local, or the actual remote node number.

CJ1-H-R CPU Ver-Instruction Constraints

The SYSMAC Programming Manual states that CMND(@CMND) 490 versioned instruction forms are supported on CJ1-H-R CPU Units only. Versioned functions use the ver suffix (e.g., CMND(490)@ in some references) and allow execution on every I/O refresh rather than only on differentiated (differentiate-up) execution. Practical implications:

  • On a non-H-R CPU, attempting to enable the ver attribute for CMND(490) raises a function code compile error in CX-Programmer.
  • If file-equal programming is mandatory, replace the CJ1 base with a CJ1H-CPU67H-R or equivalent — not a CJ2M.
  • Verify firmware version in CX-Programmer under PLC Information — CPU Information — Unit Version. Unit version 4.0 or higher is the typical minimum for variant instructions on the H-R family.

Verification and Commissioning Checklist

  1. Use CX-Programmer's Online — Watch Window to monitor DM1000..DM1199 during a controlled run; confirm FREAD(700) populates exactly 120 words within one scan.
  2. Force a deliberate mismatch at DM50 (write 0x0001 over the expected value) and confirm DM1300 OR-collector shows a non-zero bit pattern with bit position 3 active (50 - 48 = offset 2 from DM48 slice, so result word DM1203, bit 13).
  3. Force the entire 120-word DM0..DM119 mirror onto DM300..DM419 with a block fill (BSET(071)) and confirm DM1300 collapses to 0x0000. Then force a 1-bit difference and confirm DM1300 shows exactly that one bit's position.
  4. Disconnect the CF card and confirm FREAD(700) sets the file-not-found error flag (verify A343 status on CJ1, or the equivalent EM allocated status flag on CJ2M — consult the Peripheral Service conditional flags table in CX-Programmer).
  5. Save the project to the PLC and run a power-cycle test to confirm FREAD(700) re-initializes the file handle (some CF cards require PLC scan-time-mode restart; verify with card maker documentation if a low-cost industrial card is in use).
  6. For CMND(490) framings used in production, log the response with CAPTURE(263) into a 32-word ring buffer and confirm the FINS reply header's destination node matches the local node (it is the only way to catch swapped source/destination node addresses in the frame).

FAQ

What is the S+2 parameter in CMND(490)?

S is a word address pointing into a buffer you assemble in DM, EM, CIO, HR, or AR. S, S+1, S+2... are successive words of that FINS command frame; there is no fourth operand. The PLC has no internal "S+2" parameter — it is whatever you write into the third word of your command buffer.

Can CMND(490) directly compare a DM block to a Compact Flash file?

No. CMND(490) only transports FINS service requests. To compare DM to a CF file, read the file with FREAD(700) into a DM scratch area and then call MCMP for every 16-word slice. Use CMND(490) only when the comparison target is a UM area program file transferred via FINS service 22 0C.

How many MCMP instructions do I need to compare 120 words?

Because MCMP compares exactly 16 words per call, you need ceil(120/16) = 8 calls. To keep N=16 valid for every call, pad the file with 16 - (120 mod 16) = 8 dummy words during the FWRIT(701) step; otherwise, restrict the trailing MCMP to the actual remainder by replacing it with multiple CMP(020) calls.

Which Omron CPUs support versioned CMND(490) instructions?

Versioned CMND variants are supported on CJ1-H-R CPU Units only, per the SYSMAC CS/CJ/NSJ Series Programming Manual. CS1 and standard CJ1/CJ2 units reject the ver attribute at compile time.

What does CMND(490) main/sub error 0302 indicate?

Main code 0x03 sub code 0x02 means the destination node address in the FINS frame is out of range or used broadcast where single-node is required. Reset the third node field to a valid single-node address (e.g., 0x01 for local) and re-issue.

Back to blog