Moving a block of data from one place to another on an S7-1200 can be done in more than one way. Pick the wrong one and the code becomes either long-winded or liable to fail at runtime when a length changes. The sections below set out the common block-move methods by data shape and scenario, with the basis for choosing between them.
Use MOVE for a single value, MOVE_BLK for a fixed-length array, and MOVE_BLK_VARIANT when the length or the source/destination type is only known at runtime, together with a VARIANT and an array index. First decide whether the data is "one value" or "a stretch", then whether the length changes at runtime.
FILL fills an array or a memory area with a single value, which suits clearing to zero, setting defaults and writing one pattern into a whole stretch. It works in the opposite direction to MOVE: MOVE brings data across, FILL spreads one value out. For initialising an array it is far clearer than assigning element by element, and harder to leave a gap in.
On an S7-1200, the classic BLKMOV (SFC20) is not directly available and is normally replaced by MOVE_BLK or MOVE_BLK_VARIANT. Programs ported from S7-300/400 have to be rewritten to these two instructions, and you must watch the parameter order and the way overlapping source and destination are handled, otherwise the move may not match the original behaviour.
When an area has to be copied by variable address, use PEEK/POKE to access it byte by byte, word by word or double word by double word, or use a VARIANT with the array start index and length. This is flexible, but the boundaries are yours to work out; running past them reads unrelated data or raises an error, so validate the index and length first.
If a batch of data is exchanged with a remote station or a VFD, reading and writing several records in one communication call is far more efficient than moving each one. Watch the length of each record and the response time of the station, though: if a batch is too large it may exceed the time available in one scan and time the communication out.
| Method | Data shape | Use case | Note |
|---|---|---|---|
| MOVE | Single value | Parameter passing, setting a value | No type conversion |
| MOVE_BLK | Fixed-length array | Block move of a known length | Element type must match |
| MOVE_BLK_VARIANT | Dynamic-length array | Length changes at runtime | Needs a VARIANT and index |
| FILL | Whole stretch, one value | Clearing, initialising | Fills one value only |
| PEEK/POKE | Access by address | Non-structured area access | Check boundaries yourself |
| VARIANT plus index | Type not fixed | Inside a generic subroutine | Test the type before calling |
| Communication read | Remote station data | Distributed I/O, VFDs | Limit the batch size |
| Whole data block copy | DB to DB | Recipes, parameter backup | Watch optimised block access |
| Loop element by element | Small blocks | Every element is processed | Keep the loop count under control |
To choose a block-move method, ask three questions first: how much is moved at once, does the length change, and must every element be processed. Once answered, the method is almost settled. Fixed length means MOVE_BLK, variable length means MOVE_BLK_VARIANT, and per-element work means an honest loop.
Instruction semantics and the definitions of arrays and data types follow GB/T 15969.3, Programmable controllers, Part 3: Programming languages (equivalent to IEC 61131-3). The communication-related device descriptions follow GB/T 25105 (PROFINET, equivalent to IEC 61158). The exact instruction names and availability depend on the manual of the CPU version in use.
Confirm that source and destination lengths match before a block move, and verify key elements afterwards. Debug large cross-device reads and writes during a shutdown or a light-load period so real-time tasks are not affected.