Principios básicos (S7-1500T)
3.8 Transformación de la cinemática (S7-1500T)
Ejemplo de programa
A continuación se resume el ejemplo de programa con comentarios:
SCL
//Caste of the variant "TransformationParameters" to the referenced datatype
//"TO_Struct_TransformationParameter_V1".
//This has to be done in order to access the variant pointer, which references
//the "TransformationParameters" where the "AxisData" and "CartesianData" for
//the calculation of user transformation are stored.
#P ?= #TransformationParameters;
//Check if cast of "TransformationParameters" was successfull. Otherwise abort calcula-
tion.
IF #P = NULL THEN
#FunctionResult := #InvalidCast;
RETURN;
END_IF;
//Check if "KinematicsUserDefined2D" needs transformation.
IF #KinematicsObject = "KinematicsUserDefined2D" THEN
//Read the user defined cartesian parameters.
#GearRatioA1 := "KinematicsUserDefined2D".Kinematics.Parameter[1];
#GearRatioA2 := "KinematicsUserDefined2D".Kinematics.Parameter[2];
//Calculate the forward transformation "AxisData" -> "CartesianData".
//The system fills the "AxisData" of "TransformationParameters" with values.
//To calculate the "CartesianData" evaluate "AxisData".
IF #TransformationType = 0 THEN
//Calculate the position, velocity and acceleration component for the x-vector.
#P^.CartesianData.xPosition := #P^.AxisData.a1Position * #GearRatioA1;
#P^.CartesianData.xVelocity := #P^.AxisData.a1Velocity * #GearRatioA1;
#P^.CartesianData.xAcceleration := #P^.AxisData.a1Acceleration * #GearRatioA1;
//Calculate the position, velocity and acceleration component for the z-vector.
#P^.CartesianData.zPosition := #P^.AxisData.a2Position * #GearRatioA2;
#P^.CartesianData.zVelocity := #P^.AxisData.a2Velocity * #GearRatioA2;
#P^.CartesianData.zAcceleration := #P^.AxisData.a2Acceleration * #GearRatioA2;
//Link constellation can be set to 0 here, hence it is not needed.
#P^.CartesianData.LinkConstellation := 16#0000;
//Transformation was successfull.
#FunctionResult := 0;
//Calculate the backward transformation "CartesianData" -> "AxisData".
//The system fills the "CartesianData" of "TransformationParameters" with values.
//To calculate the "AxisData" evaluate "CartesianData".
ELSIF #TransformationType = 1 THEN
150
S7-1500T Funciones de cinemática V6.0 STEP 7 V17 o superior
Manual de funciones, 05/2021, A5E42063028-AC