Inclination measurement

The inclination measurement determines the inclination of the box in relation to the gravity. You can calculate the angle of inclination in a PLC program from the measured acceleration values.

If the box is tilted only in one axis, the calculation is possible with a simple formula.
If the box is tilted in several axes at the same time, the calculation is more complicated. Further information can be found, for example, on the Internet under the keyword "Euler angles".

The following examples show the calculation of the angle of inclination when tilting about one axis at a time.

Example: Inclination around the x-axis, "Roll"

Inclination measurement 1:

Formula:

Inclination measurement 2:

Implementation in TwinCAT:

IF NOT ((ax = 0) AND (az = 0)) THEN
    roll := ATAN(ay / (SQRT(ax * ax + az * az))) * 360/(2*3.14);
END_IF

(Note: the IF statement prevents division by zero)

Example: Inclination around the y-axis, "Pitch"

Inclination measurement 3:

Formula:

Inclination measurement 4:

Implementation in TwinCAT:

IF NOT ((ay = 0) AND (az = 0)) THEN
    pitch := ATAN(ax / (SQRT(ay * ay + az * az))) * 360/(2*3.14);
END_IF

(Note: the IF statement prevents division by zero)