+(86)0752-5103606 E-mail:info@hytech-cn.com

How do you copy memory areas and structured data in STEP 7 (TIA Portal)?

Last Updated on 2021-09-09 Hits:5071
With S7-1200/S7-1500, if you want to copy memory areas, in STEP 7 (TIA Portal) you use the instructions "MOVE_BLK", "MOVE", "Serialize" and "Deserialize".






The following examples show how to copy the contents of a source memory area into a target memory area. You can also copy structured data with the "MOVE" instruction. Information about this is available in Entry ID 78678760.

Description

Example 1: Copy contents of array variables from one data block to another

If you have to copy data areas from one data block to another, you create the data blocks with variables of the "Array" data type. Using the Array variables and the "MOVE_BLK" instruction, for example, you can move parts or the complete memory area from one data block to another. With the "COUNT" parameter you define the number of the elements from which you wish to move data from the source area to the target area.


Fig. 1

Fig. 1 shows the call and parameterization of the "MOVE_BLK" instruction with two DB variables.

  • The formal parameter "IN" is parameterized with the array element of the DB variable "Block.send[5]".
  • The formal parameter "OUT" is parameterized with the array element of the DB variable "Data.receive[10]".
  • The actual parameter "Control.count" provides with the value "5" the number of copy repeats.

In this way the data is copied from "Block.send[5]...Block.send[9]" into the memory area "Data.receive[10]...Data.receive[14]".



Fig. 2

Example 2: Copy structured data from one data block to another each with a different PLC data type

The "Copy" function copies from the "Source" data block the contents of the structured variable "variable" (PLC data type: "Speed") into the structured variable "value" (PLC data type: "Drive") of the "Target" data block. The two memory areas do not have the same PLC data type.

Fig. 3

Fig. 4 shows the program in the "Copy" function with the call and parameterization of the two instructions "Serialize" and "Deserialize". The "Serialize" instruction converts a PLC data type into a sequential display type and stores the structured data in the buffer memory "tempStore". In the second network the "Deserialize" instruction converts the sequential data from the buffer memory "tempStore" back into a PLC data type.



Fig. 4

Note on the two instructions "Serialize" and "Deserialize"
To use the two instructions "Serialize" and "Deserialize" in blocks with optimized block access, you need the firmware V4.0 or higher for the S7-1200 and the firmware V2.0 or higher for the S7-1500. Furthermore, the project engineering of the block version V2.0 and higher is required for the two instructions "Serialize" and "Deserialize" if you also program the instruction "MOVE" as in the example described above.

 If there are any deviations, we recommend one of the following two remedies:  

Remedy 1

  1. In the project tree you right-click the block.

  2. In the pop-up menu you select "Properties".

  3. Switch to the "Attributes" tab.

  4. Disable the option "Optimized block access".

Remedy 2

  1. Configure an FB instead of an FC.

  2. Save the array ("tempStore") as a static variable.

  3. For the array ("tempStore"), in the "Retain" column you enable the function "Set in IDB ".



Example 3: Copy structured data from an input module into a data block
In the example below (Fig. 5), the input areas (IB0, IB1) and output areas (data block "DBrange") are defined with the PLC data type "DataRange". This structured grouping of the input and output addresses in a higher-level PCL variable makes it easier to program your program.

Fig. 5

Using this method you can also copy input areas larger than 64 bytes into a data block. You need firmware V4.1 or higher for the S7-1200 CPU modules.

Notes
The above-mentioned instructions are available in the "Basic Instructions" task card:

  • Either in the "Move" folder;
  • Or you drag-and-drop the "Empty box" from the "General" folder into your network. Then move the cursor on the yellow triangle in the empty box until the symbol for opening the drop-down list appears. In the drop-down list box you select the command.

Further Information
More information is also available in the STEP 7 (TIA Portal) Online Help.
Information on the topic of "Pointer addressing" is available in Entry ID 42603286.

Creation Environment
The screens in this FAQ response were created with STEP 7 (TIA Portal) V13 SP1.

Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about cyber security, please visit







友情链接: 广州到上海物流 集运系统 情趣家具 猎酷网 物流网站 展会运输 淘宝集运