de:s7:scl_reference_move

Simatic S7 SCL reference: move / memory

Back to reference overview: Simatic S7 SCL reference with examples

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: move operations

_FB_ Retval := BLKMOV ( INTIf 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 ,inputSource 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 , outputDestination 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.

A more complete version of this program can be found here, which converts the DT type to a 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: blkmov_example_1.scl.

Here is a description of how to import the downloaded program to the TIA Portal: 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:

BLKMOV

Copy arrays in memory blocks.

See: move operations

_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):

MOVE_BLK

Example of moving ARRAY with MOVE_BLK (ENO error!):
I overrated the source area with COUNT: = 3.

MOVE_BLK

The example MOVE_BLK program below can be downloaded here: move_blk_example.scl.

Here is a description of how to import the downloaded program to the TIA Portal: Import source code to the TIA portal.

Post views: 153

Donate

2022/04/21 15:01
  • de/s7/scl_reference_move.txt
  • Utolsó módosítás: 2022/04/21 21:09
  • szerkesztette: sndvmo