show the entry list
STEP 7 (TIA Portal) -- Creating S7 programs -- Creating program sequences
How can you migrate alarms in the TIA Portal from the S7-300/400 to the S7-1500?
In STEP 7 (TIA Portal) V12, why do you have to insert a SET instruction after a jump command in order to ensure a first scan?
Where in STEP 7 (TIA Portal) V11 is there a program for the S7-1200 that lets different bit patterns rotate or flash under time control?
Recommended programming for S7-1200 and S7-1500 with STEP 7 (TIA Portal) V12
In STEP 7 (TIA Portal) V11, how do you calculate a current arithmetic average value from any number of values read in?
In STEP 7 (TIA Portal) V11, how do you calculate the minimum and maximum limit values for a temperature range?
How do you convert degrees into radians and vice versa in STEP 7 (TIA Portal) V11?
In STEP 7 (TIA Portal) V11, how can you buffer the return values from the "RETVAL" parameter consecutively in a DB?
How do you calculate in STEP 7 (TIA Portal) V11 the distance "D" between two points in a rectangular coordinate system?
How do you define a setpoint value with ramp function in STEP 7 (TIA Portal) V11?
How do you establish a MODBUS-RTU communication with STEP 7 (TIA Portal) for the SIMATIC S7-1200?
In STEP 7 (TIA Portal) V11 how can you invert an output signal of the "Bool" data type after each positive edge?
In STEP 7 (TIA Portal) V11, how can you count forwards and backwards in a bandwidth between -2147483648 and +2147483647?
How can you process 64-bit floating-point numbers in STEP 7 V11 with a SIMATIC S7-300/400 CPU?
How do you calculate in STEP 7 (TIA Portal) V11 the distance "D" between two points in a rectangular coordinate system?
Part number:

Description
The attached sample program shows how to calculate distance "D" between two points in a rectangular coordinate system. The calculated distances are stored one after the other in a data block. The program in the "Save_Value" functions consists of two parts:

  1. To calculate the distances between the two points, the "Save_Value" function expects the coordinates X1 and Y1 for Point 1 and coordinates X2 and Y2 for Point 2 at the input parameters. The output parameter "D" returns the calculated distance between the two points. The input variables X1, X2, Y1 and Y2 and the output variable "D" are of the "Real" data type.

Fig. 01

  1. After calculation, the values (calculated distances) are saved in the global data block "Save". The data block "Save" includes the array variable "Value" with 10 array elements of the "Real" data type. Each array element is reserved for one value. If an array element is already occupied by a value, the new (changed) value is entered in the next array element. In the "Save_Value" function there is then the query as to the next available free array element. Once this has been determined, the latest new value (except for value zero) is saved and the program closed. Only the last array element is overwritten. When the "Reset" parameter receives the "True" signal, all the array elements are reset to zero.

Fig. 02

The "Save_Value" function is called in OB1 "Main" and contains German and English comments. The attached download contains an archived STEP 7 (TIA Portal) V11 project with the STEP 7 program described above.

Download
Copy the "STEP7_V11_Different_coor.zip" file into a separate directory and then start the file with a double-click. The STEP 7 (TIA Portal) V11 project is now unpacked automatically with all the associated subdirectories. You can then use STEP 7 (TIA Portal) V11 to open and process the extracted project.

STEP7_V11_Different_coor.zip ( 6084 KB )  

Creation environment
The figures and download in this FAQ were created with STEP 7 (TIA Portal) V11+SP2. The following table lists the components that have been used to create this entry and verify the functions described.
 
Test environment Version
PC platform Intel(R) Core(TM)2 Duo CPU P8700 2.53 GHz
PC operating system MS Windows XP SP3
STEP 7 (TIA Portal) V11 + SP2
CPU 1214C (6ES7214-1AE30-0XB0) Firmware V12.1

 Entry ID:43664720   Date:2012-04-04 
I regard this article....as helpfulas not helpful                                 
mySupport
My Documentation Manager 
Newsletter 
CAx-Download-Manager 
Support Request
To this entry
Print
Create PDF 
Send to a friend
QuickLinks
Compatibility tool 
Help
Online Help
Guided Tour