Instructions: This entry shows how you can use SFB37 (AR_SEND) to transfer one process value into a WinCC process value archive. This entry follows the procedure described in Entry ID 23629327.
| No. |
Procedure |
| 1 |
Defining the data format of the data to be archived Archiving using the AR_SEND block supports different versions regarding the structure of the data to be transferred. Choose one of the possible data formats. A detailed description of the structure of the data block to be transferred is available in the WinCC Online Help under "WinCC Information System > Communication > SIMATIC S7 Protocol Suite > Special functions > Data exchange with the S7 function block AR_SEND".
The following format has been chosen for this example in which one value of a process tag is transferred:
| Header Type (INT := 9) |
| Year |
Month |
| Day |
Hours |
| Minutes |
Seconds |
| 1/10s |
1/100s |
1/1000s |
Weekday |
| Cycle (DINT := 1) |
| Unit (Type) (BYTE := B#16#1) |
Unit (Range) (BYTE := B#16#1) |
| AR_ID Subnumber (INT := 1) |
| Process data - data type (INT := 5) |
| Number of process values (INT := 1) |
| Process value (REAL) |
Description of the data structure elements:
- Header Type = 9
Header with time stamp and AR_ID subnummer.
- Date and Time (Year, Month, Day, Hours, Minutes, Seconds, ...)
The time stamp is filled with current system time during runtime.
- Cycle= 1
The process values are read out equidistantly. The starting time point is specified in the header's time stamp and is absolutely necessary. The time units of Unit (Range) and "Cycle" factor are valid for the time intervals between process values.
- Unit (Type)= 1
The time stamp entered in the header is valid for the process value.
- Unit (Range)= 1
Reserved.
- AR_ID subnumber= 1
Defines the assignment between the PLC process value and the WinCC archive tag.
- Process data - data type= 5
S7 data type = REAL.
WinCC data type = float.
- Number of process values = 1
Only one process value is transferred.
- Process value
The process value is filled with the current value during runtime. |
| 2 |
Configuring the AR_SEND send block in the STEP 7 project For this example a function block (FB) has been created, which only realizes the core functionality of data exchange using the AR_SEND block. The data structure defined in Step 1 is filled with values and the AR_SEND block transferred for "Sending". The SFB37 (AR_SEND) is called as a multi-instance. The relevant inputs and outputs of the AR_SEND block are run on the interface of the newly created FB. In practice, depending on the case in question, you might have to program more functionalities, for example:
- To ensure data consistency when transferring, you should not change the data during the transfer procedure. For example, you may only write to the Send area again for this purpose when the "DONE" output of the AR_SEND block has the value "1".
- In order to reduce the communication load it is also possible to transfer data to WinCC only when there is a change in the process value. It is also possible to collect the process data upon change of value in the data structure to be transferred and then send it upon the occurrence of an event that you define. For example, the data could be sent only after expiry of a maximum time or upon exceeding a defined value change (hysteresis).
- Since you can only call the AR_SEND block a limited number of times in the S7 program, you should select a different version of data transfer using the AR_SEND block if there is a large number of measuring points to be archived. You can also transfer multiple values of different measuring points within one data block.
More information:
- The block has been created in the SCL language. The procedure is identical if you use a different language (STL).
- The data structure for the data to be transferred has been defined as UDT and is used in the FB's interface.

Fig. 01
You parameterize the length of the data block to be transferred with the LEN parameter of the AR_SEND block. You can determine the length of the data area to be transferred by opening the UDT directly from the STEP 7 program's block container. In the STL editor, the length of the structure (UDT) is then shown in bytes in the last line.

Fig. 02
- You run the input AR_ID AR_SEND block externally and assign the system attributes S7_server:='alarm_archiv' and S7_a_type:='ar_send'. In this way STEP 7 assigns a unique, continuous AR_ID when incorporating the FB in the program. The following two figures show the block for the languages SCL and STL.
- The following two figures show the block call in the CFC chart and in STL.
If you use the block in the STEP 7 program, you can determine the current system time via SFC1 (READCLK Read System Clock) and store it in a global data block. You can interconnect this data with the block's "Time Stamp" input.
You can download the block as SCL and STL source.
WinCC_ArSendOnePV.zip ( 3 KB )
You can use Copy/Paste to insert the relevant source in the SCL or STL editor. In order to compile this source successfully, you should define the the numbers for the UDT and the FB beforehand in the symbol table.

Fig. 07
|
| 3 |
Configuring process-driven archiving in WinCC Configuration of this step is described in detail in the Entry ID 23629327 mentioned above and in the WinCC Online Help. For the sake of completeness we will list the major steps again:
- WinCC Tag Manager: set up connection in the SIMATIC S7 Protocol Suite
- WinCC Tag Manager: create the raw data tag of the raw data type "Archive Data Link"
- WinCC Tag Logging: create process-controlled archive tag
|
|