IMDHMIControls LibraryShop main store

Troubleshooting

CX-Programmer invalid argument in function blocks on Windows 11

PLC programming Published 5 min read By IMDHMI controls team

Short answer

CX-Programmer throws "An invalid argument was encountered" on Windows 11 when a function block contains a signed or comma-decimal constant, because the block compiler parses such literals through the Windows regional decimal symbol. Rewrite the literal as an unsigned decimal constant or as a REAL variable with an initial value, set a period-decimal regional format, install the current CX-One update, and recompile the block offline before any transfer.

On this page
  1. Confirm it is a compile failure, not a transfer fault
  2. Rewrite the constants that fail
  3. Set the regional format so the compiler reads a period
  4. Update CX-One before rewriting a large project
  5. Port the logic to structured text
  6. Verify before you download
  7. Questions asked

The message "An invalid argument was encountered" from CX-Programmer on Windows 11 is a compile failure inside a function block, not a transfer or connection fault. The function block compiler parses signed and floating-point constants — a set value typed as +25, for example — through the Windows regional decimal symbol, and on a machine where that symbol is a comma the parse throws this error. The fix is to rewrite the offending literals in unsigned decimal form or move the values into REAL variables with initial values, set the regional format so the compiler reads a period, and install the current CX-One update, which Omron issued for exactly this Windows 11 behavior. This article walks the isolation, the rewrite, and the verification.

Confirm it is a compile failure, not a transfer fault #

The error is thrown when the function block compiler builds block instances into ladder, and that compilation runs both when you compile and again at the start of every transfer to the PLC, which is why it looks like a download problem. Prove where the failure lives before touching anything:

  1. Go offline and disconnect from the PLC.
  2. Run Project > Compile All Programs.
  3. If the same message appears with no PLC connected, the serial or USB path, the driver stack and the CP1H itself are all out of scope; the defect is in the project source.
  4. In the project tree, compile each function block individually and record the first one that throws.
  5. Open that block's ladder body and inspect every operand that is a typed constant rather than a variable reference. Signed and exponent-form numbers are the suspects.

Do not move on until you have the block name and the rung. If instead the connection itself will not go online, that is a different failure mode on the serial path, which the guide to fixing an Omron CJ1M serial connection covers.

Rewrite the constants that fail #

Inside a function block, the ladder compiler routes signed and IEEE floating-point literals through a locale-dependent conversion. Unsigned decimal constants bypass that conversion entirely, which is why notation alone decides whether the block builds:

Constant as typed What the compiler sees Result
&25 unsigned decimal constant compiles
+25 signed decimal constant invalid argument
+2,5E+1 comma-decimal exponent form invalid argument

Correct the block as follows:

  1. Replace every integer set value written with a sign by the unsigned & form.
  2. Where a genuine REAL constant is required, do not type it inline: declare an internal variable of type REAL in the block's variable table, put the number in its Initial Value column, and reference the variable in the rung.
  3. Leave hexadecimal # operands alone; substituting one for a decimal set value silently changes the arithmetic.
  4. Recompile that block alone. Zero errors on the individual build is the check, and repeat for each sibling block — the notation problem is usually copy-pasted across a family of blocks.

Set the regional format so the compiler reads a period #

CX-Programmer is a Win32 application that reads the user locale once, at process start, and converts numeric literals with its decimal symbol. Windows 11 exposes that locale through two front ends, and the newer one can overwrite custom values, so set the regional format first and the legacy values second:

  1. In the Settings app under Time & language, choose a regional format whose decimal symbol is a period, for example English (United States).
  2. In Control Panel > Clock and Region > Change date, time or number formats > Additional settings, confirm the decimal symbol is a period and the list separator is a comma.
  3. Copy the settings to welcome screen and system accounts on the Administrative tab, then reboot. Closing CX-Programmer is not enough while CX-Server components stay resident.
  4. The sample line in the Numbers tab must read 123,456,789.00.

Verify from a command prompt after the reboot:

reg query "HKCU\Control Panel\International" /v sDecimal
reg query "HKCU\Control Panel\International" /v sThousand
reg query "HKCU\Control Panel\International" /v sList

The value of sDecimal must report the period character. If the locale is clean and the compile still fails, the literal itself is bad — go back to the rewrite above.

Update CX-One before rewriting a large project #

Install the current CX-One update first. Omron's CX-One Ver.4 update notes record a fix for an error that occurred when a decimal was set in Properties on some Windows 11 computers, so updating can clear the failure on projects where the locale alone was the trigger. Update, reboot, and recompile before editing constants: projects with genuinely malformed literals still need the rewrite, but you should not hand-edit a dozen blocks to fix what a patch already fixes.

Port the logic to structured text #

A structured text function block removes the dependency altogether, because the ST compiler type-checks expressions instead of parsing locale-dependent constants. The same division written as an expression:

(* Function block variable table:
   LENGTH : REAL, input, example value 100.0
   RESULT : REAL, output *)
RESULT := LENGTH / INT_TO_REAL(25);

The expression only type-checks if LENGTH is declared REAL. If the source value arrives as an integer word, convert both operands: RESULT := INT_TO_REAL(LENGTH) / INT_TO_REAL(25);.

The test that proves the result: force LENGTH to 100.0 and monitor RESULT. The arithmetic is 100.0 / 25 = 4.0, so RESULT must read 4.0; a result of 0 or any other value means the constant did not land in the operand you edited. Delete the ladder version only after the ST block compiles clean and the offline test passes.

Verify before you download #

Set the check level and CPU unit version in Program Check Options to match the CP1H in the panel, so the checker validates against the right instruction set. Then:

  1. Run Project > Compile All Programs and require zero errors; fix warnings too, because duplicate output coil warnings hide behind a passing build.
  2. Open the function block memory allocation and confirm the instance area does not overlap DM words the application already uses; a rewritten or substituted block can change its instance footprint.
  3. Transfer from a safe machine state, and confirm before the download that the notation fix changed no operand value — a constant rewrite must not alter how the machine behaves.
  4. After the transfer, run PLC > Transfer > Compare with PLC and confirm the project and the CPU are identical.
  5. Monitor the block instance with the arithmetic test from the structured text section, and read the task cycle time after a few minutes of RUN, since a substituted block changes scan load.

A clean compile offline, an identical compare online, and the monitored result of 4.0 together close the fault: the source was the defect, not the machine, and the project now compiles on any Windows 11 station with a period-decimal locale.

Questions asked

Why does the same project compile on Windows 10 but fail on Windows 11?

Windows 11 applies the regional format through the Settings app and can leave the legacy Additional settings values inconsistent with the chosen format. CX-Programmer reads the decimal symbol once at start and parses signed and floating-point function block constants with it, so a comma-decimal machine throws the error where a period-decimal Windows 10 machine compiles. Omron recorded this Windows 11 behavior in the CX-One Ver.4 update notes and shipped a fix.

Does changing the regional format repair the project file?

No. The literal is stored in the project exactly as typed, so a file containing a comma-decimal constant fails again on any machine whose decimal symbol differs from the authoring machine. Rewrite the constant in unsigned decimal form or as a REAL variable, then compile the saved file on both the Windows 10 and the Windows 11 machine. Zero errors on both is the proof the defect is out of the source.

Why does the error appear during a download rather than at compile time?

CX-Programmer compiles all programs again at the start of every transfer to the PLC, so the parse failure surfaces in the download dialog. Nothing reaches the CPU, which is why the connection, the driver and the CP1H itself are all healthy. Work offline, compile first, and fix the constants before you attempt the transfer again.

Does moving the block to structured text have any cost?

Structured text removes the locale-dependent literal parse because the ST compiler type-checks expressions, but an ST function block still occupies function block instance memory in the CPU, so treat the swap as a memory-map change. Confirm the instance area does not overlap data memory the application already uses, and re-check cycle time after the change, since an ST body can load the scan differently than the ladder it replaced.

Keep reading

  • Troubleshooting

    Why CODESYS rejects an array of derived function blocks

    CODESYS and TwinCAT 3 refuse ARRAY OF BasicValve on a parameter typed ARRAY[*] OF AValve because the array itself is a value type: its storage is element size times element count, and inheritance is checked per object, never between array types. Convert each element into an array of the base interface, or build an array of POINTER TO the base function block, and pass that instead.

    PLC programming

  • How-to

    EL3314 status word error handling in TwinCAT PLCs

    Declare the EL3314's four channels as one array of value-and-status structures with AT %I*, link each element through an index-to-member assignment in the TcLinkTo attribute, and decode the status WORD with three AND masks: 16#0001 underrange, 16#0002 overrange, 16#0040 error. Dividing the raw integer by 10.0 gives degrees Celsius at 0.1 °C resolution; one function block instance per channel packages scale and decode so four indexed calls replace copy-pasted rungs.

    PLC programming

  • How-to

    Program startup, flasher and digital-use analog inputs on an M172

    Declare a BOOL, set it TRUE in an ST program assigned to the Init Task, compute the flasher as x1Sec := TO_BOOL((sysTimer/1000) MOD 2) in cyclic code, and convert each of AI5-AI8 with TO_BOOL before ladder accepts it as a contact. The object not found error means the example names were never declared.

    PLC programming

Fix ctrlX PLC license invalid exceptions on download