====== Simatic S7 SCL reference: move / memory ====== Back to reference overview: [[de:s7:scl_reference|Simatic S7 SCL reference with examples]] ===== 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. See: [[de:s7:scl_reference#move_ops|move operations]] |< 100% 15% 15% 15%>| |[[de:s7:tia_knowhow#fb|_FB_]] **Retval :=** **BLKMOV (**| |[[de:s7:tia_datatypes#int|INT]]|If there is no error, **Retval** is 0. Otherwise: a summary table of the "retVal" codes can be found here: [[de:s7:errorcodes|Simatic S7 error- and statuscodes]] | | |**SRCBLK :=** [[de:s7:tia_datatypes#variant|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 =>** [[de:s7:tia_datatypes#variant|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: [[de:s7:tia_knowhow#db_opt|Switch off "optimization" attribute of DBs]] === BLKMOV call example 2 === [[de:s7:tia_knowhow#fc|_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 [[de:s7:tia_datatypes#dt|DT]] and splits the variable into [[de:s7:tia_datatypes#byte|BYTE]]s. A more complete version of this program can be found here, which converts the [[de:s7:tia_datatypes#dt|DT]] type to a [[de:s7:tia_datatypes#string|STRING]]: [[de:project_s7:dt_to_string|TIA typeconversion: date_and_time to string]]. This feature can be important for text-based communication solutions, such as SMTP. The example program below can be downloaded here: {{ :de:s7:blkmov_example_1.scl |blkmov_example_1.scl}}. \\ \\ Here is a description of how to import the downloaded program to the TIA Portal: [[de:s7:tia_knowhow#import|Import source code to the TIA portal]]. 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: {{:de:s7:blkmov_example_1.png|BLKMOV}} ===== MOVE_BLK ===== Copy arrays in memory blocks. See: [[de:s7:scl_reference#move_ops|move operations]] [[de:s7:tia_knowhow#fc|_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: [[de:s7:scl_reference_move#blkmov|BLKMOV]]. Example of moving ARRAY with MOVE_BLK (ENO OK): {{:de:s7:move_blk_example_1.png|MOVE_BLK}} Example of moving ARRAY with MOVE_BLK (ENO error!): \\ I overrated the source area with COUNT: = 3. {{:de:s7:move_blk_example_2.png|MOVE_BLK}} The example MOVE_BLK program below can be downloaded here: {{ :de:s7:move_blk_example.scl |move_blk_example.scl}}. \\ \\ Here is a description of how to import the downloaded program to the TIA Portal: [[de:s7:tia_knowhow#import|Import source code to the TIA portal]]. ==== End of site ==== ~~NOCACHE~~ Post views: {{counter|total}} {{page>de:s7:foot}}