
Note: This function must be called before using the tilt library.
•void MotionTL_SetKnobs(MTL_knobs_t *knobs)
– sets the knobs
– the parameters for the structure type MTL_knobs_t are:
◦fullscale is the full scale of accelerometer (in g). It is recommended to set full scale >1g for
the sensor. A lower full scale can be selected if the tilt variation is limited and higher resolution is
required for the application.
◦k is the filtering coefficient. The range of k is [0.1 to ODR]. The lower value of k increases the
filtering and removes the noise. For systems with high vibration, it is recommended to reduce the
value of k.
◦orn[3] is the accelerometer data orientation string of three characters indicating the direction
of each positive orientation of the reference frame used for the accelerometer data output, in the
sequence x, y, z. Valid values are: n (north) or s (south), w (west) or e (east), u (up) or d (down)
(see Figure 1). The orn is defined to bring the sensor into the X-NUCLEO-IKS01A3 frame.
◦mode is the operational mode where:
•MODE_PITCH_ROLL_GRAVITY_INCLINATION enables angle representation in Euler
angles (Roll, Pitch and Phi) form
•MODE_THETA_PSI_PHI enables angle computation of theta, psi and phi angle which
measure the angle individually on each axis
Note: The API can be called after MotionTL_Initialize() but before MotionTL_Update()
•void MotionTL_GetKnobs(MTL_knobs_t *knobs)
– gets the knobs setting
– for the parameters for the structure type MTL_knobs_t refer to the MotionTL_SetKnobs() function
•void MotionTL_Update(MTL_input_t *data_in, uint64_t timestamp_ms, MTL_output_t
*data_out)
– executes the tilt algorithm
–*data_in parameter is a pointer to a structure with input data
–timestamp_ms is the time stamp in milliseconds
–*data_out parameter is a pointer to a structure with output data
– the parameters for the structure type MTL_input_t are:
◦acc_x is the accelerometer sensor value in X axis in g
◦acc_y is the accelerometer sensor value in Y axis in g
◦acc_z is the accelerometer sensor value in Z axis in g
– the parameters for the structure type MTL_output_t are:
◦theta_3x in Theta-Psi-Phi mode – the angle between X axis and the horizontal plane. The
range of angle is [-90, 90] degrees.
◦psi_3x in Theta-Psi-Phi mode – the angle between Y axis and the horizontal plane. The range of
angle is [-90, 90] degrees.
◦phi_3xin both modes – the angle between X-Y planes and the horizontal plane. The range of
angle is [0, 90] degrees.
◦roll_3x in Pitch-Roll-Gravity-Inclination – the roll angle. The range of angle is [-180, 180]
degrees.
◦pitch_3x in Pitch-Roll mode – the pitch angle. The range of angle is [-90, 90] degrees.
◦err_deg in both modes – the predicted angle error. The range of error in angle is [0, 90]
degrees. The output can be used to accept/reject the tilt angle.
◦valid in both modes, this flag is used to show if output is valid or not. If accelerometer reading is
showing high vibration or saturation at full scale, library will output ‘0’ in the valid field.
Note: In Pitch-Roll-Gravity-Inclination mode, the psi_3x value represents gravity_inclination_3x value.
UM2277
MotionTL library
UM2277 - Rev 8 page 4/20