A ladder written for a larger PLC tests bit 6 of a data register directly, and on an FX3S the compiler throws the address straight back. Nothing is wrong with the logic: the FX3S family gives D registers no bit numbering, so bit-level work takes a short detour through an M block. You move the word in with one MOV rung, test or set the M bits, and move the word back out. This guide gives you the two rungs, the digit arithmetic behind K4M0, a worked decode of a code reader status word, the bench checks that prove the mapping, and the wiring checks to make first when the scanner sits silent. It is written for anyone feeding a fixed barcode reader's result word, or a smart camera's, into a compact PLC.
Why the FX3S rejects D20.6
On the FX3S, FX3G and FX3U, a data register is a word device with no bit form: the address D20.6 is not in the device table, so the project fails at compile time, before the PLC runs a scan. The same address works on the larger L series, which is why the borrowed program looked right and the FX3S refused it.
The family's own way in is digit specification: a K prefix on a bit device sets how many 4-bit digits the block spans, as the FX3S/FX3G/FX3U programming manual for the FX3U series documents. Four digits cover exactly one 16-bit word:
MOV copies 16 bits, so its bit-device destination needs a K4 block; DMOV moves 32 and needs K8.
What you need
- The project open in the programming software (GX Works in the setup described here), able to go online in monitor mode.
- 16 spare M devices per word you want to split. M0-M15 is the obvious block, but an unused offset such as M100-M115 keeps you clear of existing coils; the device usage list shows what is taken.
- The register and bit map of your reader or camera: which D registers hold its result word and what each bit means.
- A test code you can present on the bench, and a way to trigger the reader while you watch.
Step 1: prove the words are arriving
In the line that prompted this guide, the scanner produced no beam at all, and the cause turned out to be a serial plug that was not fully seated — a hardware fault hiding under a logic question. Check the physical layer before rewriting anything: seat every connector, confirm the reader powers up and fires its read beam on a test code, and match baud rate, stop bits and parity on both ends of the link. A reader that sends nothing looks exactly like a program that decodes nothing.
Then watch the data land. Go online with the device monitor, present a code, and confirm the result word (D20 in the borrowed program) changes value on each read. If it never moves, the fault sits upstream of the ladder: the checks in barcode scanner not sending data to your HMI: fix the serial link and the trade-offs in barcode scanner input methods to a PLC cover that path. Where an HMI sits between reader and PLC over RS-422, the words still end up in D registers that the HMI writes; reading a barcode scanner into a PLC CPU module over serial walks that layout.
Step 2: move the word into the M block
- Reserve the block. Take K4M0 (M0-M15) or an unused offset such as K4M100 (M100-M115). Two words need two blocks that do not overlap.
-
Copy the word in. Put
MOV D20 K4M0above any rung that reads those M bits, so every scan judges fresh bits. Hang it off the reader's new-data strobe with the pulse formMOVP D20 K4M0when the word updates in bursts rather than every scan. -
Swap the illegal addresses for M bits. Every
D20.6becomes a contact onM6; a flag in bit 0 becomesM0; the nibble in bits 0-3 is the block M0-M3 read as a number. -
Keep the logic itself unchanged. Contacts,
SET,RSTand outputs work on M exactly as they would have on the D bits. -
Write back only when the handshake needs it.
MOV K4M0 D20, placed after the last rung that touched the block, returns your edits to the register; a read-only split skips this rung.
On the bench the rungs read like this, with X000 as the family's input-device letter for a strobe (illustrative here) and Y000 as an accept output:
LD X000 new-data strobe from the reader (illustrative input)
MOVP D20 K4M0 result word D20 now readable as M0-M15
LD M6 data-valid flag, bit 6 of the example map
SET Y000 accept the part (illustrative output)
Worked example: decode a code reader status word
Take a map that is common in shape: bit 6 is the data-valid flag and bits 0-3 carry the number of codes decoded in the frame. The reader finds 3 good codes, so the word in D20 is worth 3 plus the flag at bit 6:
The bench test proves the map both ways. Scan exactly one code: the word reads 65 = 64 + 1, so M0 and M6 alone are ON. Present no code: M6 stays OFF. If M3 lights up for a single code, either the bit map or the block start is wrong — reread the reader's register table before touching the ladder. The count nibble climbs 1, 2, 3 as you add codes, which gives a fast visual check on the monitor.
Write the bits back when the handshake needs it
Some handshakes want the PLC to answer inside the word itself: clear the valid flag to re-arm the exchange, or set an acknowledge bit a panel polls. Edit the bit in the block, then move the block back:
RST M6 clear the valid flag in the block
MOVP K4M0 D20 write the edited word back to D20
Place the write-back below the last rung that touches the block and keep both directions inside one scan, so the register never carries a half-edited value past the cycle end. If the register belongs to the HMI rather than the reader, the same move serves — the panel sees the edited word on its next poll. The flag discipline that keeps two sides from racing is the subject of copy barcode data to a string only on a new read handshake, and the register-handshake pattern generalises in send vision coordinates to a PLC through a register handshake.
Verify it on the bench
- With the line stopped, put a known value into the register: write 67 into D20 from the device monitor, or drop a one-shot
MOV K67 D20into a test rung. - Watch the M block in monitor mode. 67 = 64 + 2 + 1, so M6, M1 and M0 must be the only ON bits — anything else means the block start or the digit count is off.
- Edit and return: force M6 OFF, run the write-back, and read D20 back as 67 − 64 = 3.
- Go live with one code: the word should read 65, with M0 and M6 ON and the rest OFF.
- Add codes one at a time and watch the count nibble climb 1, 2, 3 in M0-M3; a jump straight to 8 or 13 means you are reading a different nibble than the map says.
Common mistakes
- K2 where K4 belongs. K2M0 spans 8 bits; a 16-bit MOV needs four digits, and DMOV needs eight.
- Overlapping blocks. K4M10 covers M10-M25 and K4M20 covers M20-M35, so both moves write M20-M25. Keep start addresses 16 or more apart.
- Colliding with live coils. Picking M0-M15 when the existing ladder already uses M0 rewrites someone else's logic; the device usage list catches this in one look.
- The write-back above the read-move. Read at the top, act in the middle, write back at the bottom; any other order delivers edits or data a scan late.
- MOV on 32-bit data. A double register holds 32 bits; MOV moves 16, so use DMOV with a K8 block.
- Debugging logic over wiring. The silent scanner in Step 1 was a plug, not a program; always clear the physical layer first.
When a move is not the best tool
If only the panel needs the bits, the HMI's own scripting can split the word — the alternative raised alongside the move by the engineer who answered the original question. Keep the decision in the PLC whenever the PLC acts on it: one place owns the logic. If you only need to know whether particular bits are ON, a logical-AND word instruction against a mask keeps everything in D registers with no extra block.
The data side matters as much as the logic. A reader that reports one compact status word plus the payload maps cleanly onto this scheme; if the reader talks straight into the PLC rather than through an HMI, the fixed code readers catalog lists 28 models with a serial interface, filterable in the code reader finder. For line-side reading in batches, the LS-CRD-0028 pairs a 5 MP sensor and an 8 mm lens with a 60 codes/s read rate over Fast Ethernet.
- Interface
- Fast Ethernet
- Resolution
- 5 MP
- Sensor format
- 1/1.7"
- Shutter
- Global
For tighter mounts and for inspection that runs on the device itself:
- Interface
- GigE
- Resolution
- Up to 3 MP
- Resolution
- Up to 3 MP
- Shutter
- Global
- Interface
- GigE
- Resolution
- 6-10 MP
The MV-ID813M-05S-WBN-SR and the LS-CRD-0052 are code readers for compact mounts; the MV-SC5060XM-08M-WBN is the smart camera route, with the inspection and its result word on one device. Whichever you pick, the two MOV rungs stay identical — only the bit map changes.
To settle reader, trigger gear and comms in one pass, step through the system configurator; if the handoff stalls, the contact page reaches us — free expert support comes with every order.
Questions
Why does D20.6 compile on one PLC and fail on the FX3S?
Bit numbering on a word device is a feature of the larger families, and the FX3S device table has no bit form of D, so the address is rejected when the project compiles, before the PLC runs a scan. The same address is legal on the L series the code came from, which is why the file moved between colleagues without a warning. The fix is the bit block: MOV D20 K4M0, and M6 then plays the role the borrowed code gave D20.6.
How many M devices does one D register need?
Sixteen for a 16-bit register: K4M0 or any K4 start address covers four digits of four bits each, and the block runs from the start device to start+15. A 32-bit double register needs K8 and 32 devices. Pick start addresses at least 16 apart so two blocks never overlap, for example M0-M15 and M20-M35.
Can I test a single bit of a word without the move?
Not in FX3S ladder: the compiler accepts no bit operand on a D register, so there is nothing to address directly. The nearest shortcuts are to keep the decision in word logic with a mask, or to move only the low byte into an 8-bit K2 block when the flag lives in bits 0 to 7. Anything that reads bit n of a word goes through a bit block.
What if the reader word updates while the PLC is copying it?
A word rebuilt byte by byte can be half-old when the move reads it, and the decode mixes two frames. Tie the move to the reader's data-available strobe and use the pulse-executed form so the copy runs once per new word, not every scan. The same discipline applies to ASCII payload framing, where a complete message is copied only when its terminator arrives.
Does this technique change how I wire the reader to the PLC?
No. The move works on whatever word reaches a D register, whether the reader writes it over its own serial or Ethernet link or an HMI passes it through and writes the register itself. On serial links, match baud rate, stop bits and parity on both ends first, and follow the hardware manual for wiring and grounding; the bit-block technique lives entirely in the ladder.



