meta data for this page
LamaPLC: Simatic S7 SCL commands: Move / memory operations
BLKMOV
You can use the “Move block” instruction to move the content of a memory area (source area) to another memory area (destination area). The move operation takes place in the direction of ascending addresses. You use ANY pointer to define the source and destination area.
_FB_ Retval := BLKMOV ( | INT | If there is no error, Retval is 0. Otherwise: a summary table of the “retVal” codes can be found here: Simatic S7 error- and statuscodes | |
SRCBLK := VARIANT , | input | Source block: this block will be copied. The feature does not scan data types, only the size of the area should match the size of the target. | |
DSTBLK ⇒ VARIANT , | output | Destination block: the first block is copied here (overwrites everything). | |
); |
It is important to disable optimization in the DBs used by BLKMOV!
Check: Switch off "optimization" attribute of DBs
BLKMOV call example 2
_FB_ RetVal := BLKMOV (SRCBLK := P#M12.0 BYTE 10, DSTBLK ⇒ P#DB1.DBX0.0 BYTE 10);
BLKMOV call example 1
The sample program reads the local time in DT and splits the variable into BYTEs.
The example program below can be downloaded here: blkmov_example_1.scl.
The code:
// author OB121 / Sandor Vamos // ob121.com; 2022.04.11. // BLKMOV example: read local time and convert byte array // // More information: // https://www.ob121.com/doku.php?id=de:s7:scl_reference#blkmov // read local time to date_and_time #state := RD_LOC_T("BLKMOV_DB".datum_dt); // move date_and_time to byte array #state := BLKMOV (SRCBLK := P#db4.dbx0.0 BYTE 8, DSTBLK => P#db4.dbx8.0 BYTE 8, ENO => ENO);
The DB:
MOVE_BLK
Copy arrays in memory blocks.
_FC_ MOVE_BLK (IN:= source block; OUT:= target block; COUNT:= number of elements; ENO ⇒ operation enable );
The MOVE_BLK command can be used to move a memory area (IN) to another memory area (OUT) by a specified length (COUNT). The command does not implicitly monitor for irregular addresses, so it is worth monitoring the (ENO) output.
The operation can be performed with the ARRAY types (in which case COUNT determines the number of items). In case of over-addressing, ENO indicates.
For pointer memory area move check: BLKMOV.
Example of moving ARRAY with MOVE_BLK (ENO OK):
Example of moving ARRAY with MOVE_BLK (ENO error!):
I overrated the source area with COUNT: = 3.
The example MOVE_BLK program below can be downloaded here: move_blk_example.scl.
FILL_BLK / UFILL_BLK
Fill a memory area (ARRAY) (target range) with a value.
UFILL_BLK: In the case of the UFILL_BLK instruction, the difference is that the operation cannot be interrupted, it must be executed in the same call-cycle.
The instruction can only be executed if the source range and the target range have the same data type.
_FB_ FILL_BLK ( | |||
IN := 5 , | input: Binary numbers, integers, floating-point numbers, timers, TOD, LTOD, DATE, CHAR, WCHAR | fill a memory area (target range) with the value of the IN input. | |
COUNT := 4 , | input: USINT, UINT, UDINT, ULINT | The number of repeated copy operations is specified with the COUNT parameter | |
OUT ⇒ “db_prog”.intArray[2] | output:Binary numbers, integers, floating-point numbers, timers, TOD, LTOD, DATE, CHAR, WCHAR | The target range is filled beginning with the address specified at the OUT output. When the instruction is executed, the value at the input IN is moved to the target range as often as specified by the value of the COUNT parameter. | |
); |
>> Back to LamaPLC main menu (SCL commands)
This page has been accessed for: Today: 2, Until now: 223