accVectorToAngles (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Firmware version:

2.40 / 1.40.00


This function will take the applied values and calculate the angles of the axis relative to acceleration forces.

 

When mode is ABSOLUTE (see accOpen) and not moving, the angles returned will represent the tilt of each axis relative to the earth surface.

 

 

Input:

inX : DINT

The acceleration force (mg) measured on the X-axis.

 

inY : DINT

The acceleration force (mg) measured on the Y-axis.

 

inZ : DINT

The acceleration force (mg) measured on the Z-axis.

 

Output:

x : INT

Angle of the X-axis relative to acceleration forces in 0.01 degrees.

 

y : INT

Angle of the Y-axis relative to acceleration forces in 0.01 degrees.

 

z : INT

Angle of the Z-axis  relative to acceleration forces in 0.01 degrees.

 

Returns: INT

0

-

Ok.

 

Declaration:

FUNCTION accVectorToAngles : INT;
VAR_INPUT
   inX   : DINT;
   inY   : DINT;
   inZ   : DINT;
 
   x     : ACCESS INT;
   y     : ACCESS INT;
   z     : ACCESS INT;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
PROGRAM example;
VAR
   x,y,z : DINT;
   pitch INT;
   roll  INT;
   yaw   INT;
END_VAR;
accOpen(mode := 2);
BEGIN
  accVector(x := xy := yz := z);
  accVectorToAngles(inX := xinY := yinZ := z, x := pitchy := rollz := yaw);
  ...
END;
END_PROGRAM;