plc.myforum.ro Forum Index plc.myforum.ro
PLCs users www.plc.myforum.ro!
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Calculate the distance "D" between two points TIA

 
Post new topic   Reply to topic    plc.myforum.ro Forum Index -> Simatic Automation Systems
View previous topic :: View next topic  
Author Message
gert
Member 3
Member 3
gert

Joined: 02 Jan 2015
Posts: 645

PostPosted: 19/05/2017 12:39    Post subject: Calculate the distance "D" between two points TIA Reply with quote

How do you calculate in STEP 7 (TIA Portal) the distance "D" between two points in a rectangular coordinate system?
https://support.industry.siemens.com/cs/document/43664720/

The SCL program in the FB "SaveDistance" calculates the distances between two points in a Cartesian coordinate system and saves the values one after the other in a data block.
To calculate the distances between the two points, the FB "SaveDistance" expects the coordinates "x1" and "y1" for Point 1 and the coordinates "x2" and "y2" for Point 2 at the input parameters. At the output parameter "distance" you get the calculated distances between the two points. You can save the results consecutively in a data block until they are deleted by a reset.
Fig. 1 shows the definition for calculating the distance between two points in a Cartesian coordinate system.

Calculate the distance "D" between two points TIA Calculate the distance "D" between two points TIA
Fig. 1

Parameterize the output parameter of the FB "SaveDistance" with a DB tag of the data type "Array[1..10] of Real". You can also extend this sample SCL program with other array elements. The calculated distances are stored one after the other in the array elements.
Before starting the distance calculations, you have to reset the array elements to zero with the "reset" parameter.
A value can only be stored in an array element when the value of the array element is zero.
After each new calculation, a query is run in the FB "SaveDistance" to determine the next free array element that is available.
Each array element is reserved for one value. If an array element is already occupied with a value (apart from zero), the new (changed) value is entered in the next array element.
If all the array elements are occupied by a value, the last array element is overwritten with each additional distance calculation.
You have to do a reset to be able to store new values in the other array elements.
Note:If the distance calculation has the value 0, the value "-1" is written to the array element.

Calculate the distance "D" between two points TIA Calculate the distance "D" between two points TIA
Fig. 2

The FB "SaveDistance" was created in the SCL programming language and includes German and English comments. The table below describes the block parameters.

Calculate the distance "D" between two points TIA Calculate the distance "D" between two points TIA

Library with STEP 7 (TIA Portal)
For STEP 7 (TIA Portal) V13:
https://support.industry.siemens.com/cs/attachments/43664720/43664720_SaveDistance_Lib_STEP7_TIA_Portal_V13.zip
For STEP 7 (TIA Portal) V14
https://support.industry.siemens.com/cs/attachments/43664720/43664720_SaveDistance_Lib_STEP7_TIA_Portal_V14.zip

How do you open libraries in STEP 7 (TIA Portal)?
https://support.industry.siemens.com/cs/document/37364723/

When starting TIA Portal V13 onwards, how do you get a global library to open automatically and use it as corporate library, for example?
https://support.industry.siemens.com/cs/document/100451450/
Automation Tasks in 10 minutes or less TIA Portal: Time Savers - Global Libraries
https://support.industry.siemens.com/cs/document/78529894/
Creating a global library
https://support.industry.siemens.com/cs/mdm/109011420?c=64381499019&lc=en-WW
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    plc.myforum.ro Forum Index -> Simatic Automation Systems All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Fa-ti si tu propriul forum GRATUIT, pe www.myforum.ro