How to delete movemets artefacts

Hi people, in the past few days I tried to filter a signal with no success. I'm here to understand which technique could help me at this point. I tried the madgwick, mahony and right now a simple low pass filter, but I am not able to delete (IN REAL TIME) the spikes that overpass 120 or go down 80.
My system is an arduino uno that reads the gravity vector of the imu bno055 during consecutive inclination, coming from quaternions. I attach the code and a pic to be complete.
Because of the turning on of a servo, that is not the cause of those spikes, the sample frequency is 0.2247. The resulted line is , indeed, not so smooth. I guess that this is another problem even if I don't like it.

    imu::Quaternion quat = bno.getQuat();

    q0 = quat.w();
    q1 = quat.x();
    q2 = quat.y();
    q3 = quat.z();
    gx = q1 * q3 - q0 * q2;
    gy = q0 * q1 + q2 * q3;
    gz = q0 * q0 + q3 * q3 - 0.5f;
    norm = sqrt(gx * gx + gy * gy + gz * gz);
    norm = 1.0 / norm;
    gx *= norm; gy *= norm; gz *= norm;
    phi = acos(gx); phi = phi * radtodeg;
    Yfiltered = (Yold + delta * Wc * phi) / (1 + delta * Wc);
    Yold = Yfiltered;

median filtering is effective or spikes (i.e. salt/pepper noise). it requires sorting an odd number of samples and taking the middle value

Can you not apply limiting to the values?

The median averaging can put a major delay I guess.
I can put a limit on the output, but then I have anyway those problems inside the circle

if a sample exceeds a limit, rather than reduce it to the limit value, replace its value with the previous sample value

Why not try to figure out where the spikes are coming from?

Given the poor performance of the BNO055, "phi" could easily be discontinuous.

How do you know it isn't the servo, just because you may not be moving it the servo is still controlling the output shaft to keep it in position.

If the shaft is under constant torque from the load on it, then the servo will be pulsing the motor to keep it in position.

If you unplug the servo does the noise go away?

What is your project?

Thanks.. Tom... :grinning: :+1: :coffee: :australia:

Is the problem evident in the raw, unprocessed data from the IMU?

Thank you to all. And honestly, sorry. Sorry for the loss of time. Indeed, continuing and testing it with other filters, because of all yours tips, I noticed that the problem was the soldering of the hardware, nothing else. Goodbye.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.