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